/* =====================================================
   DeskPilot Monitor — Neumorphic / Clay UI
   ===================================================== */

:root {
    --bg:           #eef0f4;
    --shadow-dark:  #c8ccd4;
    --shadow-light: #ffffff;
    --text-primary: #2d3748;
    --text-muted:   #718096;
    --text-light:   #a0aec0;
    --sidebar-bg:   #2d3748;
    --sidebar-text: #e2e8f0;
    --sidebar-muted:#a0aec0;
    --green:        #48bb78;
    --blue:         #4299e1;
    --orange:       #ed8936;
    --navy:         #2b6cb0;
    --red:          #fc8181;
    --yellow:       #f6ad55;
    --radius-sm:    12px;
    --radius-md:    18px;
    --radius-lg:    24px;
    --radius-xl:    32px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    max-width: 100%;
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
}

img, svg, canvas, video { max-width: 100%; height: auto; }

/* =====================================================
   SIDEBAR
   ===================================================== */
.sidebar {
    width: 220px;
    min-height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    transition: width .3s ease;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px 28px;
}

.sidebar-logo .logo-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
}

.sidebar-logo span {
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    white-space: nowrap;
}

.nav-section-title {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--sidebar-muted);
    padding: 12px 16px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--sidebar-muted);
    font-size: 14px;
    font-weight: 500;
    transition: all .2s ease;
    margin-bottom: 2px;
}

.nav-item:hover {
    background: rgba(255,255,255,.08);
    color: #fff;
}

.nav-item.active {
    background: rgba(255,255,255,.12);
    color: #fff;
    box-shadow: inset 2px 2px 6px rgba(0,0,0,.2), inset -2px -2px 6px rgba(255,255,255,.05);
}

.nav-item .nav-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.nav-badge {
    margin-left: auto;
    background: var(--red);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
    min-width: 20px;
    text-align: center;
}

.nav-badge.green { background: var(--green); }
.nav-badge.orange { background: var(--orange); }

.sidebar-footer {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid rgba(255,255,255,.1);
}

/* =====================================================
   MAIN CONTENT
   ===================================================== */
.main {
    margin-left: 220px;
    flex: 1;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* =====================================================
   TOPBAR
   ===================================================== */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 32px;
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 50;
    border-bottom: 1px solid rgba(0,0,0,.04);
}

.topbar-title h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}

.topbar-title p {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.search-box {
    position: relative;
}

.search-box input {
    background: var(--bg);
    border: none;
    border-radius: var(--radius-md);
    padding: 9px 16px 9px 38px;
    font-size: 13px;
    color: var(--text-primary);
    width: 220px;
    outline: none;
    box-shadow: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light);
}

.search-box .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    width: 16px;
    height: 16px;
}

/* Neumorphic icon button */
.neu-btn {
    background: var(--bg);
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 4px 4px 8px var(--shadow-dark), -4px -4px 8px var(--shadow-light);
    transition: all .2s ease;
    position: relative;
    color: var(--text-muted);
}

.neu-btn:hover {
    box-shadow: 6px 6px 12px var(--shadow-dark), -6px -6px 12px var(--shadow-light);
    color: var(--text-primary);
}

.neu-btn:active,
.neu-btn.pressed {
    box-shadow: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light);
}

.neu-btn .notif-dot {
    position: absolute;
    top: 6px; right: 6px;
    width: 8px; height: 8px;
    background: var(--red);
    border-radius: 50%;
    border: 2px solid var(--bg);
}

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 4px 4px 8px var(--shadow-dark), -4px -4px 8px var(--shadow-light);
    cursor: pointer;
}

.avatar-placeholder {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    box-shadow: 4px 4px 8px var(--shadow-dark), -4px -4px 8px var(--shadow-light);
}

/* =====================================================
   PAGE CONTENT
   ===================================================== */
.page-content {
    padding: 24px 32px 40px;
    flex: 1;
}

/* =====================================================
   NEUMORPHIC CARD
   ===================================================== */
.card {
    background: var(--bg);
    border-radius: var(--radius-lg);
    box-shadow: 8px 8px 20px var(--shadow-dark), -8px -8px 20px var(--shadow-light);
    padding: 24px;
}

.card-sm {
    border-radius: var(--radius-md);
    box-shadow: 5px 5px 12px var(--shadow-dark), -5px -5px 12px var(--shadow-light);
    padding: 18px 20px;
}

.card-inset {
    background: var(--bg);
    border-radius: var(--radius-md);
    box-shadow: inset 5px 5px 12px var(--shadow-dark), inset -5px -5px 12px var(--shadow-light);
    padding: 16px 20px;
}

/* =====================================================
   KPI STATS GRID
   ===================================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg);
    border-radius: var(--radius-lg);
    box-shadow: 8px 8px 20px var(--shadow-dark), -8px -8px 20px var(--shadow-light);
    padding: 22px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform .2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon.green  { background: rgba(72,187,120,.15); color: var(--green); }
.stat-icon.blue   { background: rgba(66,153,225,.15); color: var(--blue); }
.stat-icon.orange { background: rgba(237,137,54,.15);  color: var(--orange); }
.stat-icon.navy   { background: rgba(43,108,176,.15);  color: var(--navy); }
.stat-icon.red    { background: rgba(252,129,129,.15); color: var(--red); }

.stat-info {}
.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}
.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: 500;
}
.stat-sub {
    font-size: 11px;
    color: var(--text-light);
    margin-top: 2px;
}

/* =====================================================
   CONTENT GRID
   ===================================================== */
.content-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 24px;
    margin-bottom: 24px;
}

.content-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

/* =====================================================
   TABLE
   ===================================================== */
.monitor-table {
    width: 100%;
    border-collapse: collapse;
}

.monitor-table thead th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    padding: 0 16px 12px;
    border-bottom: 1px solid rgba(0,0,0,.06);
}

.monitor-table tbody tr {
    transition: background .15s;
}

.monitor-table tbody tr:hover {
    background: rgba(0,0,0,.02);
    border-radius: var(--radius-sm);
}

.monitor-table tbody td {
    padding: 12px 16px;
    font-size: 13px;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(0,0,0,.04);
    vertical-align: middle;
}

.monitor-table tbody tr:last-child td { border-bottom: none; }

/* =====================================================
   STATUS BADGES
   ===================================================== */
.status-dot {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
}

.status-dot::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.up::before    { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.down::before  { background: var(--red);   box-shadow: 0 0 6px var(--red); }
.status-dot.degraded::before { background: var(--orange); box-shadow: 0 0 6px var(--orange); }
.status-dot.unknown::before  { background: var(--text-light); }

.status-dot.up     { color: var(--green); }
.status-dot.down   { color: var(--red); }
.status-dot.degraded { color: var(--orange); }
.status-dot.unknown  { color: var(--text-light); }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.badge-green  { background: rgba(72,187,120,.15);  color: #276749; }
.badge-red    { background: rgba(252,129,129,.15); color: #c53030; }
.badge-orange { background: rgba(237,137,54,.15);  color: #c05621; }
.badge-blue   { background: rgba(66,153,225,.15);  color: #2b6cb0; }
.badge-gray   { background: rgba(160,174,192,.15); color: #718096; }

.ssl-ok       { color: var(--green);  font-weight: 600; }
.ssl-warning  { color: var(--orange); font-weight: 600; }
.ssl-critical { color: var(--red);    font-weight: 600; }
.ssl-expired  { color: var(--red);    font-weight: 700; text-decoration: line-through; }

/* =====================================================
   SECTION HEADER
   ===================================================== */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.section-header h2 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.section-header p {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* =====================================================
   BUTTONS
   ===================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all .2s ease;
    text-decoration: none;
}

.btn-neu {
    background: var(--bg);
    color: var(--text-primary);
    box-shadow: 4px 4px 10px var(--shadow-dark), -4px -4px 10px var(--shadow-light);
}

.btn-neu:hover {
    box-shadow: 6px 6px 14px var(--shadow-dark), -6px -6px 14px var(--shadow-light);
}

.btn-neu:active {
    box-shadow: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light);
}

.btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    box-shadow: 4px 4px 12px rgba(102,126,234,.4);
}

.btn-primary:hover {
    box-shadow: 6px 6px 16px rgba(102,126,234,.5);
    transform: translateY(-1px);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 8px;
}

/* =====================================================
   CHART CONTAINER
   ===================================================== */
.chart-wrap {
    background: var(--bg);
    border-radius: var(--radius-md);
    box-shadow: inset 5px 5px 12px var(--shadow-dark), inset -5px -5px 12px var(--shadow-light);
    padding: 20px;
    max-height: 380px;
    overflow-y: auto;
    position: relative;
}

/* =====================================================
   ACTIVITY FEED
   ===================================================== */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(0,0,0,.04);
}

.activity-item:last-child { border-bottom: none; }

.activity-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}

.activity-dot.down      { background: rgba(252,129,129,.15); color: var(--red); }
.activity-dot.recovered { background: rgba(72,187,120,.15);  color: var(--green); }
.activity-dot.warning   { background: rgba(237,137,54,.15);  color: var(--orange); }
.activity-dot.info      { background: rgba(66,153,225,.15);  color: var(--blue); }

.activity-info { flex: 1; min-width: 0; }
.activity-name { font-size: 13px; font-weight: 600; color: var(--text-primary); truncate; }
.activity-detail { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.activity-time { font-size: 11px; color: var(--text-light); white-space: nowrap; }

/* =====================================================
   UPTIME BAR
   ===================================================== */
.uptime-bar-wrap {
    width: 100%;
    height: 6px;
    background: var(--bg);
    border-radius: 3px;
    box-shadow: inset 2px 2px 4px var(--shadow-dark), inset -2px -2px 4px var(--shadow-light);
    overflow: hidden;
}

.uptime-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width .5s ease;
}

/* =====================================================
   LOGIN PAGE
   ===================================================== */
.login-page {
    position: fixed;
    inset: 0;
    min-height: 100vh;
    width: 100%;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    background: var(--bg);
    border-radius: var(--radius-xl);
    box-shadow: 20px 20px 40px var(--shadow-dark), -20px -20px 40px var(--shadow-light);
    padding: 48px 40px;
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-logo {
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    box-shadow: 8px 8px 20px rgba(102,126,234,.3);
}

.login-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.login-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 36px;
}

.btn-microsoft {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 14px 24px;
    background: var(--bg);
    border: none;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    text-decoration: none;
    box-shadow: 6px 6px 14px var(--shadow-dark), -6px -6px 14px var(--shadow-light);
    transition: all .2s ease;
}

.btn-microsoft:hover {
    box-shadow: 8px 8px 18px var(--shadow-dark), -8px -8px 18px var(--shadow-light);
    transform: translateY(-1px);
}

.btn-microsoft:active {
    box-shadow: inset 6px 6px 12px var(--shadow-dark), inset -6px -6px 12px var(--shadow-light);
    transform: translateY(0);
}

.microsoft-logo {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.microsoft-logo span {
    display: block;
    border-radius: 1px;
}

.error-alert {
    background: rgba(252,129,129,.12);
    border: 1px solid rgba(252,129,129,.3);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-size: 13px;
    color: #c53030;
    margin-bottom: 20px;
    text-align: left;
}

/* =====================================================
   RESPONSIVE
   ===================================================== */

/* Hamburger + backdrop: hidden by default (desktop) */
.hamburger {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 8px;
    margin-right: 8px;
    cursor: pointer;
    border-radius: 10px;
}
.hamburger:hover { background: rgba(0,0,0,.05); }

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(45,55,72,.55);
    backdrop-filter: blur(2px);
    z-index: 99;
    opacity: 0;
    transition: opacity .25s ease;
}

/* TABLET — sidebar compatta a icone */
@media (max-width: 1024px) {
    .content-grid { grid-template-columns: 1fr; }
    .content-grid-3 { grid-template-columns: repeat(2, 1fr); }

    .sidebar { width: 72px; padding: 20px 10px; }
    .sidebar .nav-item span,
    .sidebar-logo span,
    .nav-section-title,
    .nav-badge { display: none; }
    .sidebar .nav-item { justify-content: center; padding: 12px; }
    .sidebar-logo { justify-content: center; padding: 8px 0 24px; }
    .main { margin-left: 72px; }
    .topbar { padding: 16px 20px; }
}

/* MOBILE — sidebar off-canvas drawer */
@media (max-width: 640px) {
    .sidebar {
        width: 240px;
        padding: 20px 14px;
        transform: translateX(-100%);
        transition: transform .28s ease;
        box-shadow: 20px 0 40px rgba(0,0,0,.25);
    }
    /* Restore full sidebar content on mobile drawer */
    .sidebar .nav-item { justify-content: flex-start; padding: 11px 14px; }
    .sidebar .nav-item span,
    .sidebar-logo span,
    .nav-section-title,
    .nav-badge { display: inline; }
    .sidebar-logo { justify-content: flex-start; padding: 8px 12px 24px; }

    body.sidebar-open .sidebar { transform: translateX(0); }
    body.sidebar-open .sidebar-backdrop { display: block; opacity: 1; }

    .main {
        margin-left: 0;
        width: 100%;
        min-width: 0;
        max-width: 100vw;
    }
    .main * { min-width: 0; }
    .page-content, .topbar { max-width: 100vw; }

    /* ---- Tabelle monitor → card layout ---- */
    .monitor-table, .monitor-table thead, .monitor-table tbody,
    .monitor-table tr, .monitor-table th, .monitor-table td {
        display: block;
        width: 100%;
    }
    .monitor-table thead { display: none; }
    .monitor-table tbody tr {
        border: 1px solid rgba(0,0,0,.05);
        border-radius: var(--radius-md);
        padding: 12px 14px;
        margin-bottom: 10px;
        background: var(--bg);
        box-shadow: 3px 3px 8px var(--shadow-dark), -3px -3px 8px var(--shadow-light);
    }
    .monitor-table tbody td {
        padding: 4px 0;
        border: 0;
        font-size: 13px;
        display: flex;
        align-items: center;
        gap: 8px;
        white-space: normal;
        word-break: normal;
        overflow-wrap: anywhere;
    }
    /* First cell = title block (name + subtitle) */
    .monitor-table tbody td:first-child {
        font-weight: 700;
        font-size: 14px;
        padding-bottom: 8px;
        margin-bottom: 6px;
        border-bottom: 1px dashed rgba(0,0,0,.06);
        display: block;
    }
    /* Inline label prefix for mobile — shown via data-label OR use a mini label chip */
    .monitor-table tbody td[data-label]::before {
        content: attr(data-label);
        font-size: 10px;
        text-transform: uppercase;
        letter-spacing: .05em;
        color: var(--text-muted);
        font-weight: 600;
        min-width: 78px;
        display: inline-block;
    }
    .monitor-table .status-dot,
    .monitor-table .http-code,
    .monitor-table .response-time,
    .monitor-table .ping-value,
    .monitor-table [class^="ssl-"] {
        white-space: nowrap;
    }

    .hamburger { display: inline-flex; align-items: center; justify-content: center; }

    .topbar {
        padding: 12px 14px;
        gap: 8px;
    }
    .topbar-title h1 { font-size: 17px; }
    .topbar-title p { font-size: 11px; display: none; }
    .topbar-right { gap: 8px; }
    .topbar-right .search-box { display: none; }
    #last-updated { display: none; }

    .page-content { padding: 14px; }

    .stats-grid { grid-template-columns: 1fr; gap: 14px; }
    .content-grid-3 { grid-template-columns: 1fr; }

    /* Cards più compatte su mobile */
    .neu-card { padding: 18px; border-radius: var(--radius-md); }
    .stat-card { padding: 18px; }
    .stat-value { font-size: 26px; }

    /* Login card su mobile */
    .login-card { padding: 32px 22px; max-width: 100%; }
    .login-title { font-size: 22px; }
}

/* EXTRA SMALL — iPhone SE etc. */
@media (max-width: 380px) {
    .topbar-title h1 { font-size: 15px; }
    .page-content { padding: 12px; }
    .stat-value { font-size: 22px; }
}

/* =====================================================
   PULSE ANIMATION FOR LIVE INDICATORS
   ===================================================== */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .4; }
}

.pulse { animation: pulse 2s infinite; }

@keyframes spin {
    to { transform: rotate(360deg); }
}

.spin { animation: spin .8s linear infinite; }

/* =====================================================
   SCROLLBAR
   ===================================================== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--shadow-dark);
    border-radius: 3px;
}

/* ===== Web Push status pill ===== */
.push-status.ok    { color: var(--green); }
.push-status.err   { color: var(--red); }
.push-status.muted { color: var(--text-muted); }
