/* Quantrex My CEO by Quantrex LLC — Admin Panel (mobile-first) */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', sans-serif;
    background: #0d0f14; color: #e0e0e0;
    min-height: 100vh; min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
}
a { color: #00d4aa; text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #1a1a1a; padding: 2px 6px; border-radius: 4px; font-size: 0.85em; color: #ccc; }
small { display: block; margin-top: 2px; }

/* ===== Layout ===== */
.container { max-width: 1200px; margin: 0 auto; padding: 16px; }

/* ===== Navigation ===== */
.nav {
    background: #0a0c12; padding: 12px 16px;
    display: flex; align-items: center; gap: 8px;
    border-bottom: 1px solid #1e2030;
    position: sticky; top: 0; z-index: 100;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav-brand { color: #00d4aa; font-weight: bold; font-size: 1em; white-space: nowrap; margin-right: 8px; }
.nav a {
    color: #888; font-size: 0.85em; white-space: nowrap;
    padding: 6px 10px; border-radius: 6px;
    transition: background 0.15s, color 0.15s;
    min-height: 36px; display: flex; align-items: center;
}
.nav a:hover, .nav a.active {
    color: #00d4aa; background: rgba(0,212,170,0.08);
    text-decoration: none;
}
.nav-logout { margin-left: auto !important; color: #e74c3c !important; }

/* Language Selector */
.lang-selector { display: flex; gap: 4px; margin-left: 8px; }
.lang-selector a {
    padding: 4px 8px; border-radius: 4px; font-size: 0.75em;
    color: #666; text-decoration: none; text-transform: uppercase;
    border: 1px solid transparent; transition: all 0.15s;
}
.lang-selector a:hover { color: #00d4aa; border-color: #00d4aa33; }
.lang-selector a.active-lang { color: #00d4aa; border-color: #00d4aa; background: rgba(0,212,170,0.08); }

/* Brand */
.brand-text { color: #f0f1f3; font-weight: 700; font-size: 1.15em; letter-spacing: -0.3px; white-space: nowrap; }
.brand-text span { background: linear-gradient(135deg, #00d4aa, #00b4ff, #00d4aa); background-size: 200% auto; -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; animation: brandShift 4s ease-in-out infinite; }
@keyframes brandShift { 0%,100%{background-position:0% center} 50%{background-position:200% center} }

/* Cosmic Background (login pages) */
.cosmic-bg {
    position: fixed; inset: 0; z-index: 0; overflow: hidden;
    background: radial-gradient(ellipse at 20% 50%, #0a1628 0%, #0d0f14 50%),
                radial-gradient(ellipse at 80% 20%, #0f1a2e 0%, transparent 50%);
}
.cosmic-bg::before, .cosmic-bg::after {
    content: ''; position: absolute; border-radius: 50%; filter: blur(100px); opacity: 0.12;
    animation: cosmicFloat 14s ease-in-out infinite alternate;
}
.cosmic-bg::before {
    width: 600px; height: 600px; top: -200px; right: -150px;
    background: radial-gradient(circle, #00d4aa 0%, transparent 70%);
}
.cosmic-bg::after {
    width: 500px; height: 500px; bottom: -150px; left: -100px;
    background: radial-gradient(circle, #0066ff 0%, transparent 70%);
    animation-delay: -7s; animation-duration: 18s;
}
@keyframes cosmicFloat {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(40px, -30px) scale(1.15); }
}
#cosmicCanvas { position: fixed; inset: 0; z-index: 1; }

/* Futuristic Login Box */
.login-box {
    max-width: 380px; margin: 0 auto; padding: 0 16px;
    position: relative; top: 50%; transform: translateY(-50%);
}
.login-hero { text-align: center; margin-bottom: 20px; }
.login-hero .brand-text { font-size: 1.8em; letter-spacing: -0.5px; display: inline-block; }
.login-hero .brand-sub { color: #556; font-size: 0.8em; margin-top: 6px; letter-spacing: 2px; text-transform: uppercase; }
.login-box .card {
    background: rgba(18,20,26,0.85); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(0,212,170,0.1);
    box-shadow: 0 0 40px rgba(0,212,170,0.03), 0 20px 60px rgba(0,0,0,0.4);
}
.login-box .btn-primary {
    background: linear-gradient(135deg, #00d4aa, #00a5ff);
    color: #000; font-weight: bold; position: relative; overflow: hidden;
}
.login-box .btn-primary::after {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(135deg, transparent 30%, rgba(255,255,255,0.15) 50%, transparent 70%);
    background-size: 200% 100%; animation: btnShine 3s ease-in-out infinite;
}
@keyframes btnShine { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

/* Futuristic Nav glow line */
.nav { position: relative; }
.nav::after {
    content: ''; position: absolute; bottom: -1px; left: 0; right: 0; height: 1px;
    background: linear-gradient(90deg, transparent 0%, #00d4aa33 30%, #00b4ff22 70%, transparent 100%);
}

/* Footer cosmic */
.footer-dev { text-align: center; color: #333; font-size: 0.68em; letter-spacing: 1.5px; text-transform: uppercase; }

/* ===== Cards ===== */
.card {
    background: #12141a; border: 1px solid #1e2030; border-radius: 10px;
    padding: 16px; margin-bottom: 14px;
    overflow: hidden;
}
.card h2 { color: #00d4aa; margin-bottom: 10px; font-size: 1.05em; }
.card h3 { color: #ccc; margin-bottom: 8px; font-size: 0.95em; }

/* ===== Page Header ===== */
.page-header {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 14px; flex-wrap: wrap;
}
.page-header h2 { color: #00d4aa; font-size: 1.2em; }
.page-header .back { color: #888; font-size: 0.9em; }

/* ===== Stats Grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px; margin-bottom: 16px;
}
.stat-card {
    background: #12141a; border: 1px solid #1e2030; border-radius: 10px;
    padding: 14px; text-align: center;
}
.stat-value { font-size: 1.6em; font-weight: bold; color: #00d4aa; margin: 4px 0; }
.stat-value.warning { color: #f1c40f; }
.stat-value.danger { color: #e74c3c; }
.stat-label { color: #888; font-size: 0.78em; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-detail { color: #666; font-size: 0.75em; margin-top: 2px; }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -16px; padding: 0 16px; }
table { width: 100%; border-collapse: collapse; min-width: 500px; }
th, td { padding: 10px 10px; text-align: left; border-bottom: 1px solid #1e1e1e; }
th { color: #666; font-size: 0.78em; text-transform: uppercase; white-space: nowrap; }
td { font-size: 0.9em; }
tr:hover { background: #1a1a1a; }
td.number, th.number { text-align: right; font-variant-numeric: tabular-nums; }

/* Mobile-friendly card rows (alternative to table on small screens) */
.mobile-card { display: none; }

/* ===== Status Dots ===== */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.dot-green { background: #00d4aa; }
.dot-red { background: #e74c3c; }
.dot-yellow { background: #f1c40f; }
.dot-blue { background: #3498db; }
.dot-orange { background: #e67e22; }

/* ===== Badges ===== */
.badge { display: inline-block; padding: 3px 8px; border-radius: 10px; font-size: 0.72em; font-weight: 600; white-space: nowrap; }
.badge-chat { background: #1a3a5c; color: #5dade2; }
.badge-tts { background: #1a3a2a; color: #00d4aa; }
.badge-transcription { background: #3a3a1a; color: #f1c40f; }
.badge-search { background: #3a2a1a; color: #e67e22; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 10px 16px; border-radius: 8px; border: none; cursor: pointer;
    font-size: 0.9em; color: #fff; font-weight: 500;
    min-height: 44px; /* Touch-friendly */
    transition: background 0.15s, transform 0.1s;
    text-decoration: none !important;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: #00d4aa; color: #000; font-weight: bold; }
.btn-primary:hover { background: #00b892; }
.btn-danger { background: #e74c3c; }
.btn-danger:hover { background: #c0392b; }
.btn-sm { padding: 6px 12px; font-size: 0.8em; min-height: 36px; border-radius: 6px; }
.btn-group { display: flex; gap: 6px; flex-wrap: wrap; }

/* ===== Forms ===== */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; margin-bottom: 4px; color: #aaa; font-size: 0.85em; }
.form-group input, .form-group textarea, .form-group select {
    width: 100%; padding: 10px 12px; background: #1a1a1a; border: 1px solid #333;
    border-radius: 8px; color: #e0e0e0; font-size: 1em;
    min-height: 44px; /* Touch-friendly */
    -webkit-appearance: none; appearance: none;
}
.form-group select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
.form-group textarea { min-height: 100px; resize: vertical; font-family: inherit; }
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
    outline: none; border-color: #00d4aa; box-shadow: 0 0 0 2px rgba(0,212,170,0.15);
}
.form-row { display: grid; grid-template-columns: 1fr; gap: 0; }
.form-group small { color: #555; font-size: 0.78em; }

/* Checkboxes */
.checkbox-list { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.checkbox-list label {
    display: flex; align-items: center; gap: 8px; color: #ccc;
    font-size: 0.9em; cursor: pointer; padding: 4px 0;
}
.checkbox-list input[type="checkbox"] { width: 18px; height: 18px; accent-color: #00d4aa; }

/* ===== QR Page ===== */
.qr-container { text-align: center; padding: 40px 16px; }
.qr-container img { max-width: 280px; width: 100%; border-radius: 12px; background: #fff; padding: 12px; }
.qr-status { margin-top: 16px; font-size: 1.2em; font-weight: bold; }
.qr-status.connected { color: #00d4aa; }
.qr-status.waiting { color: #f1c40f; }

/* ===== Flash Messages ===== */
.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 12px; font-size: 0.9em; }
.flash-success { background: #1a3a2a; border: 1px solid #00d4aa; color: #00d4aa; }
.flash-error { background: #3a1a1a; border: 1px solid #e74c3c; color: #e74c3c; }
.flash-warning { background: #3a3a1a; border: 1px solid #f1c40f; color: #f1c40f; }

/* ===== Login (overridden by futuristic styles above) ===== */
.login-box h1 { color: #00d4aa; text-align: center; margin-bottom: 24px; font-size: 1.4em; }

/* ===== Charts ===== */
.chart-container { margin: 12px 0; }
.chart-bar-row { display: flex; align-items: center; margin-bottom: 4px; gap: 6px; }
.chart-bar-label { width: 60px; text-align: right; font-size: 0.75em; color: #888; flex-shrink: 0; }
.chart-bar-track { flex: 1; height: 22px; background: #1a1a1a; border-radius: 4px; overflow: hidden; display: flex; }
.chart-bar-fill { height: 100%; transition: width 0.3s; }
.chart-bar-fill.chat { background: #5dade2; }
.chart-bar-fill.tts { background: #00d4aa; }
.chart-bar-fill.transcription { background: #f1c40f; }
.chart-bar-fill.search { background: #e67e22; }
.chart-bar-value { width: 64px; font-size: 0.75em; color: #aaa; font-variant-numeric: tabular-nums; text-align: right; }
.chart-legend { margin-top: 10px; display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; font-size: 0.8em; color: #888; }

/* ===== Section Separator ===== */
.section-title {
    color: #888; font-size: 0.8em; text-transform: uppercase; letter-spacing: 1px;
    margin: 20px 0 10px; padding-bottom: 6px; border-bottom: 1px solid #1e2030;
}

/* ===== Details/Summary ===== */
details summary { cursor: pointer; color: #00d4aa; font-size: 0.9em; }
details summary:hover { text-decoration: underline; }
details pre { margin-top: 8px; white-space: pre-wrap; color: #ccc; font-size: 0.82em; max-height: 200px; overflow: auto; }

/* ===== Action Bar (bottom sticky) ===== */
.action-bar {
    position: sticky; bottom: 0;
    background: #0a0c12; border-top: 1px solid #1e2030;
    padding: 12px 16px; margin: 0 -16px;
    display: flex; gap: 10px;
}
.action-bar .btn { flex: 1; }

/* ===== Utility ===== */
.text-muted { color: #666; }
.text-center { text-align: center; }
.text-sm { font-size: 0.85em; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.gap-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ================================================= */
/* Desktop (>=768px)                                  */
/* ================================================= */
@media (min-width: 768px) {
    .container { padding: 20px 24px; }
    .nav { padding: 12px 24px; gap: 6px; }
    .nav-brand { font-size: 1.1em; margin-right: 16px; }
    .nav a { font-size: 0.9em; padding: 8px 14px; }

    .card { padding: 20px; margin-bottom: 16px; }
    .card h2 { font-size: 1.1em; }

    .stats-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
    .stat-value { font-size: 2em; }

    .form-row { grid-template-columns: 1fr 1fr; gap: 16px; }

    table { min-width: auto; }
    th, td { padding: 10px 12px; }
    td { font-size: 0.95em; }

    .chart-bar-label { width: 80px; font-size: 0.8em; }
    .chart-bar-value { width: 70px; font-size: 0.8em; }

    .action-bar { position: static; background: none; border: none; padding: 0; margin: 8px 0 32px; }
    .action-bar .btn { flex: none; }
}

/* ================================================= */
/* Large Desktop (>=1024px)                           */
/* ================================================= */
@media (min-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(4, 1fr); }
}
