/* ====================================================
   AKATSUKI OS — v6 HUD Stylesheet
   Matches the DOM structure actually produced by
   index.html + hud.js (widget grid, service rows,
   terminal block, sidebar nav).
==================================================== */

:root{
    --bg: #05060a;
    --panel: rgba(14, 17, 24, .72);
    --panel-border: rgba(255, 255, 255, .08);
    --text: #f2f2f2;
    --muted: #a9adb8;
    --red: #d31823;
    --red2: #ff4b4b;
    --green: #35e07a;
    --shadow: 0 12px 40px rgba(0, 0, 0, .45);
    --radius: 18px;
    --sidebar-w: 210px;
}

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

html, body{
    width: 100%;
    min-height: 100%;
    font-family: "Inter", "Segoe UI", Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
}

/* ---------- Animated Background Layer ---------- */

#background{
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    background: #000 url("../akatsuki.jpg") center/cover fixed no-repeat;
}

#background::after{
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(rgba(0, 0, 0, .45), rgba(0, 0, 0, .72));
}

#rain, #particles{
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#fog{
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(circle at 50% 100%, rgba(211, 24, 35, .08), transparent 60%);
}

/* ---------- Layout Shell ---------- */

#sidebar,
#desktop{
    position: relative;
    z-index: 2;
}

body{
    display: flex;
}

/* ---------- Sidebar ---------- */

#sidebar{
    width: var(--sidebar-w);
    min-height: 100vh;
    flex-shrink: 0;
    padding: 28px 18px;
    background: rgba(8, 9, 13, .55);
    border-right: 1px solid var(--panel-border);
    backdrop-filter: blur(18px);
}

#sidebar .logo{
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: .12em;
    margin-bottom: 28px;
    color: #fff;
    text-shadow: 0 0 18px rgba(211, 24, 35, .5);
}

#sidebar nav{
    display: flex;
    flex-direction: column;
    gap: 6px;
}

#sidebar button{
    all: unset;
    cursor: pointer;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: .92rem;
    color: var(--muted);
    transition: background .2s ease, color .2s ease;
}

#sidebar button:hover{
    background: rgba(255, 255, 255, .06);
    color: #fff;
}

#sidebar button.active{
    background: linear-gradient(90deg, rgba(211, 24, 35, .35), rgba(211, 24, 35, .08));
    color: #fff;
    font-weight: 600;
}

/* ---------- Main Desktop ---------- */

#desktop{
    flex: 1;
    min-width: 0;
    padding: 28px 32px 60px;
}

header{
    display: flex;
    align-items: baseline;
    gap: 18px;
    margin-bottom: 28px;
}

#clock{
    font-size: 1rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

#server-status{
    font-weight: 700;
    letter-spacing: .05em;
    font-size: .9rem;
}

#server-status.online{ color: var(--green); }
#server-status.offline{ color: var(--red2); }

/* ---------- Widget Grid ---------- */

#widgets{
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 22px;
}

#terminal-widget,
#services-widget,
#activity-widget{
    grid-column: span 1;
}

@media (min-width: 900px){
    #terminal-widget{ grid-column: span 2; }
}

/* ---------- Glass Widget Card ---------- */

.glass.widget{
    padding: 22px 24px;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    backdrop-filter: blur(18px);
    box-shadow: var(--shadow);
    transition: transform .2s ease, border-color .2s ease;
}

.glass.widget:hover{
    border-color: rgba(255, 80, 80, .3);
}

.glass.widget h3{
    font-size: .82rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 14px;
}

/* ---------- Metrics ---------- */

.metric{
    font-size: .95rem;
    color: var(--text);
    margin-bottom: 4px;
}

.metric.large{
    font-size: 2rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 10px;
}

.metric-small{
    font-size: .82rem;
    color: var(--muted);
    margin-top: 6px;
    line-height: 1.5;
}

/* ---------- Progress Bar ---------- */

.progress{
    height: 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .07);
    overflow: hidden;
    margin: 6px 0;
}

.progress .fill{
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--red), var(--red2));
    transition: width .5s ease;
}

hr{
    border: none;
    border-top: 1px solid var(--panel-border);
    margin: 12px 0;
}

/* ---------- Services Widget ---------- */

.service-row{
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 0;
    border-bottom: 1px solid rgba(255, 255, 255, .05);
    font-size: .88rem;
}

.service-row:last-child{
    border-bottom: none;
}

.service-left{
    display: flex;
    align-items: center;
    gap: 10px;
}

.service-dot{
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.service-dot.green{
    background: var(--green);
    box-shadow: 0 0 8px rgba(53, 224, 122, .7);
}

.service-dot.red{
    background: var(--red2);
    box-shadow: 0 0 8px rgba(255, 75, 75, .6);
}

.service-dot.grey{
    background: #6b7280;
    box-shadow: none;
}

.service-name{
    color: var(--text);
}

.service-state{
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .05em;
    color: var(--muted);
}

/* ---------- Activity Widget ---------- */

.activity-row{
    display: flex;
    gap: 12px;
    padding: 8px 0;
    font-size: .85rem;
    border-bottom: 1px solid rgba(255, 255, 255, .05);
}

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

.activity-time{
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

/* ---------- Terminal Widget ---------- */

.terminal{
    font-family: "SFMono-Regular", Consolas, "Courier New", monospace;
    font-size: .82rem;
    line-height: 1.7;
    color: #d6f5da;
    white-space: pre-wrap;
    background: rgba(0, 0, 0, .35);
    border-radius: 12px;
    padding: 14px 16px;
    border: 1px solid rgba(255, 255, 255, .06);
}

/* ---------- App Directory Cards (sidebar tabs) ---------- */

.app-grid{
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 18px;
}

.app-card-link{
    display: block;
    text-decoration: none;
    color: inherit;
}

.app-card{
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 20px;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    backdrop-filter: blur(18px);
    box-shadow: var(--shadow);
    transition: transform .2s ease, border-color .2s ease;
}

.app-card-link:hover .app-card{
    transform: translateY(-3px);
    border-color: rgba(255, 80, 80, .3);
}

.app-icon{
    font-size: 1.8rem;
    flex-shrink: 0;
}

.app-info{
    min-width: 0;
}

.app-name{
    font-weight: 600;
    font-size: .95rem;
    color: #fff;
    margin-bottom: 4px;
}

.app-status{
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .72rem;
    letter-spacing: .05em;
    color: var(--muted);
}

/* ---------- Active Users Widget ---------- */

.user-count-row{
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, .05);
}

.user-count-row:last-child{
    border-bottom: none;
}

.user-count-label{
    font-size: .85rem;
    color: var(--muted);
}

.user-count-value{
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
}

.user-count-value.muted{
    font-size: .8rem;
    font-weight: 500;
    color: var(--muted);
}

/* ---------- Responsive ---------- */

@media (max-width: 900px){
    body{
        flex-direction: column;
    }

    /* Sticky top bar: logo + status row, with nav as a horizontally
       scrollable strip beneath it — no wrapping, no awkward grid. */
    #sidebar{
        position: sticky;
        top: 0;
        z-index: 10;
        width: 100%;
        min-height: auto;
        display: flex;
        flex-direction: column;
        gap: 0;
        padding: 12px 0 0;
        border-right: none;
        border-bottom: 1px solid var(--panel-border);
        background: rgba(8, 9, 13, .88);
    }

    #sidebar .logo{
        margin-bottom: 10px;
        padding: 0 16px;
        font-size: 1.05rem;
    }

    #sidebar nav{
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 6px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding: 0 16px 12px;
    }

    #sidebar nav::-webkit-scrollbar{
        display: none;
    }

    #sidebar button{
        flex-shrink: 0;
        padding: 8px 14px;
        font-size: .85rem;
        white-space: nowrap;
    }

    #desktop{
        padding: 16px 14px 32px;
    }

    header{
        margin-bottom: 18px;
        gap: 12px;
    }

    #clock{
        font-size: .85rem;
    }

    #server-status{
        font-size: .8rem;
    }

    #widgets{
        grid-template-columns: 1fr;
        gap: 14px;
    }

    #terminal-widget{
        grid-column: span 1;
    }

    .glass.widget{
        padding: 16px 18px;
    }

    .glass.widget h3{
        font-size: .74rem;
        margin-bottom: 10px;
    }

    .metric.large{
        font-size: 1.6rem;
        margin-bottom: 8px;
    }

    .metric-small{
        font-size: .78rem;
    }

    .app-grid{
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 12px;
    }

    .app-card{
        padding: 14px 16px;
        gap: 10px;
    }

    .app-icon{
        font-size: 1.4rem;
    }

    .app-name{
        font-size: .85rem;
    }

    .terminal{
        font-size: .74rem;
        padding: 12px 14px;
    }
}

@media (max-width: 420px){
    #sidebar button{
        padding: 7px 11px;
        font-size: .8rem;
    }

    .metric.large{
        font-size: 1.4rem;
    }
}
