/* ─── BASE ─────────────────────────────────────────────────────────────────── */
body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f0f2f7;
}

/* ─── LOGIN ────────────────────────────────────────────────────────────────── */
#login-form.container {
    max-width: 380px;
    margin: 120px auto;
    background: white;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,.10);
}

/* ─── SYNOPTIC HEADER ──────────────────────────────────────────────────────── */
.synoptic-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: white;
    border-bottom: 1px solid #e6e8f0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.synoptic-logo {
    height: 36px;
}
.header-actions {
    display: flex;
    gap: 8px;
}

/* ─── TOPBAR ───────────────────────────────────────────────────────────────── */
.topbar {
    display: flex;
    gap: 14px;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: white;
    border-bottom: 1px solid #e6e8f0;
    flex-wrap: wrap;
}
.stats { display: flex; gap: 10px; flex-wrap: wrap; }

.stat-card {
    background: white;
    border: 1px solid #e6e8f0;
    border-radius: 12px;
    padding: 8px 16px;
    min-width: 90px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,.04);
    cursor: pointer;
    transition: transform .15s, box-shadow .15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(0,0,0,.10); }
.stat-card .n { font-size: 22px; font-weight: 700; line-height: 1; }
.stat-card .l { font-size: 11px; opacity: .65; margin-top: 3px; text-transform: uppercase; letter-spacing: .5px; }
.stat-card.ok    { border-left: 5px solid #2ecc71; }
.stat-card.alarm { border-left: 5px solid #e67e22; }
.stat-card.warn  { border-left: 5px solid #f1c40f; }
.stat-card.err   { border-left: 5px solid #e74c3c; }
.stat-card.off   { border-left: 5px solid #95a5a6; }

.controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.controls #search { width: 220px; }
.controls #filter { width: 160px; }

.refresh-countdown {
    font-size: 12px;
    color: #95a5a6;
    white-space: nowrap;
}

/* ─── CARD GRID ────────────────────────────────────────────────────────────── */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    padding: 20px;
}

/* ─── SITE CARD ────────────────────────────────────────────────────────────── */
.site-card {
    background: white;
    border-radius: 14px;
    border: 1px solid #e6e8f0;
    border-left: 5px solid #2ecc71;
    box-shadow: 0 2px 10px rgba(0,0,0,.05);
    overflow: hidden;
    transition: transform .18s, box-shadow .18s, opacity .3s;
    display: flex;
    flex-direction: column;
}
.site-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
}
.site-card.status-alarm { border-left-color: #e67e22; }
.site-card.status-warn  { border-left-color: #f1c40f; }
.site-card.status-err   { border-left-color: #e74c3c; }
.site-card.status-off   { border-left-color: #95a5a6; opacity: .85; }

.site-card.card-removing {
    transform: scale(.95);
    opacity: 0;
}

/* Inattivi: grigi, dimmed */
.site-card.card-inactive {
    border-left-color: #bdc3c7 !important;
    opacity: .55;
    filter: grayscale(.6);
}
.site-card.card-inactive:hover {
    opacity: .8;
    filter: grayscale(.3);
}

/* Badge RX online / offline */
.rx-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: .4px;
    white-space: nowrap;
    flex-shrink: 0;
}
.rx-online {
    background: rgba(46,204,113,.15);
    color: #27ae60;
}
.rx-offline {
    background: rgba(231,76,60,.15);
    color: #c0392b;
    animation: pulse-rx 1.6s ease-in-out infinite;
}
.rx-unknown {
    background: rgba(149,165,166,.15);
    color: #7f8c8d;
}
@keyframes pulse-rx {
    0%, 100% { background: rgba(231,76,60,.15); }
    50%       { background: rgba(231,76,60,.32); }
}

/* clickable area */
.card-main {
    padding: 16px 16px 10px;
    cursor: pointer;
    flex: 1;
}
.card-main:hover .card-name { color: #2980b9; }

/* head */
.card-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.card-name {
    font-weight: 700;
    font-size: 15px;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color .15s;
}
.badge-inactive {
    font-size: 10px;
    background: #ecf0f1;
    color: #7f8c8d;
    border-radius: 20px;
    padding: 2px 8px;
    white-space: nowrap;
}

/* stato pills */
.card-stato { margin-bottom: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.stato-pill {
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
}
.stato-pill.ok    { background: rgba(46,204,113,.14);  color: #27ae60; }
.stato-pill.alarm { background: rgba(230,126,34,.18);  color: #d35400; }
.stato-pill.warn  { background: rgba(241,196,15,.20);  color: #b7950b; }
.stato-pill.err   { background: rgba(231,76,60,.16);   color: #c0392b; }
.stato-pill.check { background: rgba(52,152,219,.14);  color: #2980b9; }
.stato-pill.time  { background: rgba(0,0,0,.05);       color: #666;    font-weight:400; }
.stato-pill.off   { background: rgba(0,0,0,.06);       color: #999;    font-weight:400; }

/* meta */
.card-meta {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 12px;
    color: #7f8c8d;
}
.card-meta span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-time { font-style: italic; }

/* action buttons (top-right icons) */
.card-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    padding: 6px 10px;
    border-top: 1px solid #f4f5f7;
    background: #fafbfc;
}
.btn-icon {
    background: none;
    border: 1px solid #dce1e7;
    border-radius: 8px;
    width: 32px;
    height: 32px;
    font-size: 14px;
    cursor: pointer;
    transition: background .15s, border-color .15s;
    display: flex; align-items: center; justify-content: center;
}
.btn-icon:hover   { background: #e8f0fe; border-color: #4285f4; }
.btn-icon.active  { background: #fff3e0; border-color: #f39c12; }
.btn-icon:disabled { opacity: .5; cursor: not-allowed; }

/* ─── EDIT PANEL ───────────────────────────────────────────────────────────── */
.card-edit {
    display: none;
    padding: 14px 16px;
    background: #f8f9fc;
    border-top: 2px dashed #d0d7e2;
}
.edit-row {
    margin-bottom: 8px;
}
.edit-row label {
    font-size: 11px;
    font-weight: 600;
    color: #7f8c8d;
    text-transform: uppercase;
    letter-spacing: .4px;
    margin-bottom: 2px;
    display: block;
}
.edit-buttons {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

/* ─── LED INDICATOR ────────────────────────────────────────────────────────── */
.led {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    flex-shrink: 0;
}
.led-ok    { background: #2ecc71; box-shadow: 0 0 0 2px rgba(46,204,113,.25); }
.led-alarm {
    background: #e67e22;
    box-shadow: 0 0 0 2px rgba(230,126,34,.25);
    animation: pulse-alarm 1.5s ease-in-out infinite;
}
.led-warn {
    background: #f1c40f;
    box-shadow: 0 0 0 2px rgba(241,196,15,.25);
    animation: pulse-warn 1.8s ease-in-out infinite;
}
.led-err  {
    background: #e74c3c;
    box-shadow: 0 0 0 2px rgba(231,76,60,.25);
    animation: pulse-err 1.2s ease-in-out infinite;
}
.led-off  { background: #bdc3c7; }

@keyframes pulse-alarm {
    0%, 100% { box-shadow: 0 0 0 2px rgba(230,126,34,.25); }
    50%       { box-shadow: 0 0 0 6px rgba(230,126,34,.42); }
}
@keyframes pulse-warn {
    0%, 100% { box-shadow: 0 0 0 2px rgba(241,196,15,.25); }
    50%       { box-shadow: 0 0 0 6px rgba(241,196,15,.40); }
}
@keyframes pulse-err {
    0%, 100% { box-shadow: 0 0 0 2px rgba(231,76,60,.25); }
    50%       { box-shadow: 0 0 0 7px rgba(231,76,60,.45); }
}

/* ─── RESPONSIVE ───────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
    .card-grid { grid-template-columns: 1fr; padding: 12px; gap: 12px; }
    .topbar { flex-direction: column; align-items: flex-start; }
    .controls #search { width: 100%; }
    .controls #filter { width: 100%; }
}

/* ─── CANTIERE PAGE (styles usati da cantiere.html) ────────────────────────── */
.custom-control { pointer-events: none; }
.custom-control-input { pointer-events: auto; }
.offline { background-color: #fde8e8 !important; }
.sick    { background-color: #fef9e7 !important; }

.table-responsive { display: block; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-container  { padding: 16px; }
.table { width: 100%; }
thead  { background: #f8f9fa; }
tbody tr:hover { background: #f5f7fa; }
.table th, .table td { text-align: center; vertical-align: middle; }

#button-container {
    display: flex;
    gap: 8px;
    justify-content: center;
    padding: 12px 16px;
    flex-wrap: wrap;
}
#main-content img { height: 38px; margin: 14px 0; display: block; margin-left: auto; margin-right: auto; }
