/* ============================================================
   GLOBAL BASE STYLES
============================================================ */
body {
    margin: 0;
    background: radial-gradient(circle at top, #20232b, #0d0f14);
    font-family: var(--font-sans);
    color: #eceff4;
    height: 100vh;
    overflow: hidden;
    font-size: .9em;
}

:root {
    --bg-primary: #041323;
    --bg-secondary: #07102b;
    --accent: #b3322e; /* classification red */
    --accent-weak: rgba(179,29,34,0.15);
    --text-on-accent: #ffffff;
    --muted: #88c0d0;
    --card-bg: rgba(27,30,36,0.8);
    --font-sans: 'IBM Plex Sans', 'Segoe UI', Roboto, Arial, sans-serif;
}

/* Classification levels: unclassified = green, confidential = yellow, secret = red, top-secret = purple */
.classification-unclassified { --accent: #2e8b57; }
.classification-confidential { --accent: #d4b21b; }
.classification-secret { --accent: #b3322e; }
.classification-topsecret { --accent: #5b2ea6; }

/* Subtle background watermark for the classified interface */
body.dashboard-page::after {
    content: 'CLASSIFIED';
    position: fixed;
    left: 50%;
    top: 40%;
    transform: translate(-50%,-50%) rotate(-18deg);
    font-size: 6rem;
    color: rgba(179,29,34,0.06);
    letter-spacing: 10px;
    pointer-events: none;
    z-index: 0;
}
h1 {
    font-size: 1.2em;
}
h2 {
    font-size: 1em;
}

hr {
    max-width: 70%;
}
/* ============================================================
   SIDEBAR
============================================================ */
.sidebar {
    width: 260px;
    background: linear-gradient(180deg, #041323, #07102b); /* deep navy */
    position: fixed;
    top: 0; left: 0;
    bottom: 0;
    padding: 20px;
    box-shadow: 3px 0 10px rgba(0,0,0,0.3);
}

.sidebar h2 {
    margin: 0 0 10px;
    color: #dfe7ee; /* light steel */
    text-align: center;
    font-size: 1.05em;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.sidebar a {
    display: block;
    position: relative; /* allow absolute-positioned pseudo elements */
    z-index: 1; /* ensure link content stays above pseudo elements */
    border-radius: 8px;
    margin-bottom: 8px;
    text-decoration: none;
    color: #d8dee9;
    transition: 0.2s;
    padding-left: 14px; /* keep a gap for the left accent */
}

.sidebar a:hover {
    background: rgba(255,255,255,0.02);
    color: #ffffff;
}

/* Active link style for the currently viewed page */
.sidebar a.active {
    background: linear-gradient(90deg, rgba(255,255,255,0.04), rgba(255, 255, 255, 0.236));
    color: #ffffff;
    font-weight: 700;
    box-shadow: 0 6px 20px rgba(0,0,0,0.65);
    padding-left: 20px; /* ensure text doesn't overlap with the left accent */
    transform: translateX(0px);
}

.sidebar a.active:hover {
    filter: brightness(0.98);
}

/* Alternative: show a subtle accent line on the left for strong emphasis */
.sidebar a.active:before {
    content: '';
    display: block;
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 8px;
    background: linear-gradient(180deg, rgba(200,33,45,1), rgba(170,20,34,1)); /* classification red accent */
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
    z-index: 0; /* behind the link content */
}

/* CLASSIFICATION BAR */
.classification-banner {
    background: linear-gradient(90deg, var(--accent), #9b1d24);
    color: #fff;
    padding: 8px 10px;
    border-radius: 6px;
    text-align: center;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 12px;
    box-shadow: 0 6px 20px var(--accent-weak);
}

/* subtle classified text */
.classification-banner small {
    display: block;
    font-size: 11px;
    opacity: 0.9;
    font-weight: 600;
}

/* ============================================================
   MAIN CONTENT
============================================================ */
.main {
    margin-left: 280px; /* match sidebar width + spacing */
    padding: 30px;
    position: relative;
    z-index: 1;
}

.top-classification {
    display:inline-block;
    background: linear-gradient(90deg, #b3322e, #9b1d24);
    color: white;
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-right: 8px;
}

/* ============================================================
   PAGE HEADER
============================================================ */
.page-header {
    background: linear-gradient(90deg, #07102b, #0a1930);
    padding: 10px;
    border-radius: 12px;
    margin-bottom: 25px;
    box-shadow: 0px 0px 20px rgba(0,0,0,0.5);
    width: auto;
    border-left: 6px solid rgba(200,33,45,0.9); /* classification accent */

}

.page-header h1 {
    margin: 0;
    color: #eceff4;
    font-size:1.6em;
}

/* ============================================================
   CARDS
============================================================ */
.card {
    background: rgba(27,30,36,0.8);
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 25px;
    box-shadow: 0px 4px 14px rgba(0,0,0,0.4);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.06);
    max-width:98%;
}

/* ============================================================
   INPUTS & FORMS
============================================================ */
input,
select {
    width: 33%%;
    padding: 12px;
    margin: 8px 0 20px;
    border-radius: 8px;
    border: 1px solid #4c566a;
    background: #2e3440;
    color: white;
    font-size:.75em;
    transition: 0.2s;
}

input:focus {
    outline: none;
    border-color: #81a1c1;
    box-shadow: 0 0 8px rgba(129,161,193,0.4);
}

/* ============================================================
   BUTTONS
============================================================ */
button,
.btn {
    padding: 10px 10px;
    background: linear-gradient(90deg, #5e81ac, #81a1c1);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: .75em;
    text-decoration: none;
    display: inline-block;
    transition: 0.2s;
}

button:hover,
.btn:hover {
    filter: brightness(1.1);
}

/* Special login button override */
button.login-submit {
    width: 100%;
    border-radius: 10px;
}

button.login-submit:hover {
    filter: brightness(1.15);
    box-shadow: 0 0 12px rgba(94,129,172,0.5);
}

/* ============================================================
   TABLES
============================================================ */
table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    background: rgba(46,52,64,0.6);
    border-radius: 12px;
    overflow: hidden;
}

table th {
    background: #4c566a;
    padding: 12px;
    color: white;
}

table td {
    padding: 12px;
    border-bottom: 1px solid #3b4252;
}

table td pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 300px;
    overflow-y: auto;
}

/* ============================================================
   JSON OUTPUT
============================================================ */
pre {
    background: #2e3440 !important;
    padding: 20px;
    border-radius: 10px;
    color: #45cf30 !important;
    overflow-x: auto;
}

/* ============================================================
   MAP BLOCKS
============================================================ */
.map-block {
    background: #242830;
    padding: 15px;
    border-radius: 12px;
    margin: 20px 0;
    border-left: 4px solid #5e81ac;
}

.map-block h3 {
    margin: 0 0 8px;
    color: #88c0d0;
}

iframe {
    border-radius: 12px;
    width: 100%;
    height: 300px;
    border: none;
}

/* ============================================================
   LOGIN PAGE (GLASS EFFECT)
============================================================ */
.login-box {
    background: rgba(27, 30, 36, 0.75);
    padding: 40px;
    border-radius: 16px;
    width: 380px;
    backdrop-filter: blur(12px);
    box-shadow: 0 0 35px rgba(0,0,0,0.6);
    border: 1px solid rgba(255,255,255,0.07);
    position: relative;
    z-index: 5;
}

.login-box h2 {
    text-align: center;
    margin-top: 0;
    color: #88c0d0;
}

.error {
    margin-top: 10px;
    padding: 10px;
    background: #3b4252;
    color: #bf616a;
    border-radius: 8px;
    text-align: center;
}

/* ============================================================
   FLOATING ORBS (BACKGROUND DECORATION)
============================================================ */
.orb {
    position: absolute;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.25;
    animation: float 14s infinite alternate ease-in-out;
}

.orb.blue {
    background: #5e81ac;
    top: -120px;
    left: -120px;
}

.orb.purple {
    background: #b48ead;
    bottom: -100px;
    right: -120px;
}

@keyframes float {
    from { transform: translate(0, 0); }
    to { transform: translate(40px, -40px); }
}

/* ============================================================
   MOBILE RESPONSIVE (max-width: 900px)
============================================================ */
@media (max-width: 900px) {

    /* Make body scrollable again */
    body {
        overflow: auto;
        height: auto;
    }

    /* Sidebar collapses into top bar */
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        padding: 15px 20px;
        box-shadow: none;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .sidebar h2 {
        font-size: 20px;
        margin-bottom: 0;
    }

    /* Convert sidebar links to horizontal nav */
    .sidebar a {
        display: inline-block;
        margin: 0 5px;
        padding: 10px 12px;
        font-size: 14px;
    }

    /* Ensure active links in collapsed sidebar are still visible */
    .sidebar a.active {
        background: linear-gradient(90deg, #81a1c1 0%, #88c0d0 100%);
        color: #0f1116;
        box-shadow: none;
        border-left: none;
        border-radius: 8px;
    }

    /* Main content shifts up under new top bar */
    .main {
        margin-left: 0;
        padding: 15px;
        margin-top: 20px;
    }

    /* Page Header */
    .page-header {
        padding: 18px;
        text-align: center;
    }

    .page-header h1 {
        font-size: 22px;
    }

    /* Cards */
    .card {
        padding: 18px;
        margin-bottom: 20px;
    }

    /* Inputs */
    input,
    select {
        font-size: 14px;
        padding: 10px;
    }

    /* Buttons */
    button,
    .btn {
        width: 100%;
        margin-top: 10px;
        font-size: 15px;
        padding: 12px 15px;
    }

    /* Tables */
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    table th,
    table td {
        padding: 10px;
        font-size: 14px;
    }

    /* JSON viewer */
    pre,
    .json-viewer {
        font-size: 12px;
        padding: 12px;
        max-height: 350px;
    }

    /* Map Blocks */
    iframe {
        height: 220px;
    }

    .map-block {
        padding: 12px;
    }

    .map-block h3 {
        font-size: 16px;
    }

    /* Login Box */
    .login-box {
        width: 90%;
        padding: 25px;
        margin: 40px auto;
    }

    .login-box h2 {
        font-size: 22px;
    }

    /* Orbs (background decoration) */
    .orb {
        width: 250px;
        height: 250px;
        filter: blur(80px);
    }
}

/* ============================================================
   EXTRA SMALL DEVICES (max-width: 600px)
============================================================ */
@media (max-width: 600px) {

    .sidebar {
        flex-direction: column;
        align-items: flex-start;
    }

    .sidebar a {
        display: block;
        margin: 6px 0;
        width: 100%;
        text-align: left;
    }

    .page-header h1 {
        font-size: 18px;
    }

    .card {
        padding: 15px;
    }

    pre,
    .json-viewer {
        font-size: 11px;
        line-height: 1.3em;
    }

    iframe {
        height: 200px;
    }

    .login-box {
        padding: 20px;
        width: 92%;
    }
}

body.dashboard-page {
    overflow: auto !important;
    height: auto !important;
}
/* ============================================
   REQUIRED iPHONE FIXES
============================================ */

/* Remove hard 100vh + overflow hidden that breaks scrolling on iOS */
body {
    height: auto !important;
    min-height: 100vh;
    overflow-x: hidden !important;
}

/* Ensure Safari does not produce sideways scroll */
* {
    max-width: 100%;
    box-sizing: border-box;
}

/* Fix sidebar/link overflow in horizontal mode */
.sidebar a {
    white-space: normal !important;
}

/* Fix pre blocks overflowing screen width */
pre {
    white-space: pre-wrap !important;
    word-break: break-word !important;
}

/* Fix table overflow (iOS Safari is picky) */
table {
    display: block;
    width: 100% !important;
    overflow-x: auto !important;
}

/* Better responsive sidebar for phones */
@media (max-width: 900px) {
    .sidebar {
        flex-wrap: wrap;
        gap: 10px;
    }
}

/* Extra-small screens (iPhones) */
@media (max-width: 600px) {

    /* Force clean vertical layout */
    .sidebar {
        width: 100% !important;
        overflow: visible;
    }

    .sidebar a {
        width: 100%;
        margin: 5px 0;
        text-align: left;
    }

    /* Fix card & header padding */
    .card, .page-header {
        padding: 15px !important;
    }

    /* Fix pre/json viewer sizes */
    pre, .json-viewer {
        font-size: 12px !important;
        max-width: 100% !important;
    }

    /* Prevent horizontal scrolling from map iframe */
    iframe {
        width: 100% !important;
    }
}

/* ============================================
   MOBILE TABLE EXPANSION FIX
============================================ */
@media (max-width: 900px) {

    /* Make table naturally expand instead of shrinking */
    table {
        width: 100% !important;
        table-layout: auto !important;
        display: table !important;     /* prevent block overflow behavior */
        white-space: normal !important;
    }

    /* Make headers + cells wrap instead of forcing long width */
    table th,
    table td {
        white-space: normal !important;
        word-break: break-word !important;
    }

    /* If pre blocks inside table cells are causing overflow */
    table td pre {
        max-width: 100% !important;
        white-space: pre-wrap !important;
        word-break: break-word !important;
    }
}
