/* =========================================
   TITAN OS // MASTER STYLESHEET v3.0 (DATAPAD)
   ========================================= */

:root { 
    --bg: #050505; --panel: #0f0f0f; --border: #333; 
    --text: #eee; --dim: #666; 
    --gold: #f59e0b; --green: #10b981; --red: #ef4444; --cyan: #00ffff;
    --font: 'Segoe UI', sans-serif; 
    --mono: 'Consolas', 'Monaco', monospace; 
}

* { margin:0; padding:0; box-sizing:border-box; }
body { background: var(--bg); color: var(--text); font-family: var(--font); line-height: 1.6; overflow-x: hidden; }
a { color: inherit; text-decoration: none; transition: 0.2s; }
a:hover { color: var(--gold); }
.container { max-width: 1200px; margin: 0 auto; padding: 20px; }

/* --- BUTTONS & INPUTS --- */
.btn { display:inline-block; padding: 10px 20px; border: 1px solid #fff; background: transparent; color: #fff; font-family: var(--mono); text-transform: uppercase; font-size: 0.8rem; cursor: pointer; transition: 0.2s; text-align: center; }
.btn:hover { background: #fff; color: #000; }
.btn-gold { border-color: var(--gold); color: var(--gold); }
.btn-gold:hover { background: var(--gold); color: #000; }
.input-box { width: 100%; background: #000; border: 1px solid #333; color: #fff; padding: 12px; font-family: var(--mono); outline: none; }
.input-box:focus { border-color: var(--gold); }

/* --- HEADER --- */
header { border-bottom: 1px solid var(--border); padding: 15px 0; position: sticky; top: 0; background: rgba(5,5,5,0.95); z-index: 100; backdrop-filter: blur(10px); }
.nav { display: flex; justify-content: space-between; align-items: center; }
.logo { font-family: var(--mono); letter-spacing: 2px; font-weight: bold; font-size: 1.1rem; white-space: nowrap; }
.menu { display: flex; gap: 20px; font-size: 0.8rem; text-transform: uppercase; }

/* --- ALERTS --- */
.alert { padding: 15px; margin-bottom: 20px; border: 1px solid; font-family: var(--mono); font-size: 0.8rem; }
.error { border-color: var(--red); color: var(--red); background: rgba(255,51,51,0.05); }
.success { border-color: var(--green); color: var(--green); background: rgba(51,255,51,0.05); }

/* =========================================
   TITAN INTERFACE (DESKTOP DEFAULT)
   ========================================= */
.titan-interface {
    display: grid;
    grid-template-columns: 280px 1fr;
    height: 700px;
    margin-top: 20px;
    font-family: var(--mono);
    border: 1px solid var(--border);
    background: #050505;
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 50px rgba(0,0,0,0.8);
}
/* Scanlines */
.titan-interface::after {
    content: " "; display: block; position: absolute; top: 0; left: 0; bottom: 0; right: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.1) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    z-index: 10; background-size: 100% 2px, 3px 100%; pointer-events: none;
}

/* LEFT: Sidebar */
.titan-sidebar {
    background: #0a0a0a;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}
.sys-header {
    color: var(--gold); font-size: 0.7rem; letter-spacing: 2px;
    padding: 20px; border-bottom: 1px solid var(--border);
    position: sticky; top: 0; background: #0a0a0a; z-index: 2;
}
.module-btn {
    display: flex; justify-content: space-between; align-items: center;
    padding: 15px 20px; cursor: pointer; border-bottom: 1px solid #1a1a1a;
    color: #666; font-size: 0.75rem; transition: 0.2s; text-transform: uppercase;
}
.module-btn:hover { color: #fff; background: rgba(255,255,255,0.05); }
.module-btn.active { color: var(--gold); background: rgba(245, 158, 11, 0.05); border-left: 4px solid var(--gold); }
.status-dot { width: 6px; height: 6px; background: #333; border-radius: 50%; }
.module-btn.active .status-dot { background: var(--green); box-shadow: 0 0 5px var(--green); }

/* RIGHT: Viewport */
.titan-viewport {
    position: relative; padding: 30px;
    display: flex; flex-direction: column;
    background: radial-gradient(circle at center, #111 0%, #000 100%);
}
.screen-frame {
    flex-grow: 1; border: 1px solid #444; background: #000;
    position: relative; display: flex; align-items: center; justify-content: center;
    overflow: hidden; box-shadow: 0 0 30px rgba(0,0,0,0.5);
}
.screen-img {
    max-width: 100%; max-height: 100%; object-fit: contain;
    display: none; animation: flicker 0.2s infinite;
}
.screen-img.loaded { display: block; animation: none; }

/* Data Readout */
.data-panel {
    height: auto; min-height: 100px;
    border-top: 1px solid var(--border);
    margin-top: 20px; padding-top: 15px;
    color: #aaa; font-size: 0.9rem;
}
.data-title { color: var(--gold); font-size: 1.2rem; margin-bottom: 10px; text-transform: uppercase; }
.type-cursor::after { content: '█'; animation: blink 1s infinite; color: var(--gold); }

/* --- OTHER MODULES (Auth/Admin) --- */
.auth-box { max-width: 450px; margin: 40px auto; padding: 30px; border: 1px solid var(--border); background: var(--panel); }
.terminal-container { width: 100%; max-width: 600px; height: 500px; background: #050505; border: 1px solid var(--border); padding: 20px; font-family: var(--mono); color: #a1a1aa; overflow: hidden; display: flex; flex-direction: column; }
.output-log { flex-grow: 1; overflow-y: auto; margin-bottom: 10px; font-size: 0.8rem; }
.input-line { display: flex; border-top: 1px solid #333; padding-top: 10px; color: var(--gold); }
.term-input { background: transparent; border: none; color: #fff; font-family: inherit; font-size: 1rem; flex-grow: 1; outline: none; }

/* Admin/Dash Grid */
.dashboard-layout, .admin-grid { display: grid; grid-template-columns: 250px 1fr; gap: 0; min-height: 80vh; border: 1px solid var(--border); margin-top: 20px; }
.dash-side, .sidebar-panel { background: var(--panel); padding: 20px; border-right: 1px solid var(--border); }
.dash-main, .main-panel { background: var(--bg); padding: 30px; overflow-x: hidden; }

.key-table-wrapper { overflow-x: auto; width: 100%; border: 1px solid var(--border); }
.key-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; font-family: var(--mono); min-width: 600px; }
.key-table th, .key-table td { padding: 10px; border-bottom: 1px solid var(--border); text-align: left; }
.key-table th { color: var(--dim); background: #0a0a0a; }

/* ANIMATIONS */
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
@keyframes flicker { 0% { opacity: 0.8; transform: translateX(1px); } 100% { opacity: 1; transform: translateX(-1px); } }

/* ============================================================
   MOBILE DATAPAD MATRIX (SMART RESPONSIVE)
   ============================================================ */

@media (max-width: 900px) {
    .container { padding: 10px; width: 100%; }
    
    /* NAV: Stack vertically */
    .nav { flex-direction: column; gap: 15px; padding: 10px 0; }
    .menu { width: 100%; justify-content: center; font-size: 0.7rem; flex-wrap: wrap; gap: 10px; }
    .menu a { padding: 5px 10px; border: 1px solid #333; border-radius: 4px; }

    /* --- TITAN INTERFACE (DATAPAD MODE) --- */
    .titan-interface {
        grid-template-columns: 1fr; /* Single column */
        grid-template-rows: auto 1fr; /* Screen top, buttons bottom */
        height: auto; /* Flexible height */
        display: flex;
        flex-direction: column; /* Stack elements */
    }

    /* Viewport (Screen) goes TOP */
    .titan-viewport {
        order: 1; 
        padding: 15px;
        height: 60vh; /* Takes 60% of screen height */
        min-height: 400px;
    }
    
    /* Text Readout Compact */
    .data-panel {
        margin-top: 10px; padding-top: 10px;
        font-size: 0.8rem; line-height: 1.4;
        min-height: 80px;
    }
    .data-title { font-size: 1rem; margin-bottom: 5px; }

    /* Sidebar becomes Horizontal Scroll Deck (Bottom) */
    .titan-sidebar {
        order: 2;
        border-right: none;
        border-top: 1px solid var(--gold);
        flex-direction: row; /* Horizontal items */
        overflow-x: auto; /* Scrollable */
        overflow-y: hidden;
        height: 70px; /* Fixed bar height */
        white-space: nowrap;
        -webkit-overflow-scrolling: touch; /* Smooth scroll iOS */
    }
    
    .sys-header { display: none; } /* Hide "Available Modules" text */
    
    .module-btn {
        flex-direction: column;
        justify-content: center;
        min-width: 140px; /* Wide buttons for thumb */
        padding: 10px;
        border-bottom: none;
        border-right: 1px solid #222;
        font-size: 0.65rem;
        text-align: center;
    }
    
    .module-btn.active {
        border-left: none;
        border-bottom: 4px solid var(--gold); /* Indicator on bottom */
        background: #111;
    }
    
    .status-dot { display: none; } /* Hide dots on mobile */
    
    /* --- OTHER PAGES --- */
    .dashboard-layout, .admin-grid { display: block; border: none; }
    .dash-side, .sidebar-panel { 
        border-right: none; border-bottom: 1px solid var(--border); 
        padding: 15px; margin-bottom: 20px; 
    }
    .dash-main, .main-panel { padding: 0; background: transparent; }
    
    /* Stat Grid */
    .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-num { font-size: 1.5rem; }
    
    /* Auth Box */
    .auth-box { margin: 20px 0; width: 100%; border-left: none; border-right: none; border-radius: 0; }
    .terminal-container { height: 60vh; border-radius: 0; border-left: none; border-right: none; }
}