/* ========================================================================
   Xtream Sync System — "Control Room" theme
   Palette: near-black console background, teal-green ON-AIR accent,
   coral for OFF-AIR/errors, monospace for tokens/urls/logs.
   ======================================================================== */

:root{
    --bg:        #0B0F14;
    --surface:   #131A22;
    --surface-2: #182330;
    --border:    #1F2A35;
    --text:      #E8EDF2;
    --muted:     #7C8B99;
    --accent:    #35D8B0;
    --accent-dim:#1E6E5C;
    --warn:      #FF6B5D;
    --warn-dim:  #6E2B26;
    --radius:    10px;
}

*{ box-sizing:border-box; }

body{
    margin:0;
    background:var(--bg);
    color:var(--text);
    font-family:'Inter', system-ui, -apple-system, sans-serif;
    font-size:15px;
}

h1,h2,h3{
    font-family:'Space Grotesk', 'Inter', sans-serif;
    font-weight:600;
    margin:0 0 4px;
}

code, .mono, .token-box, .cron-cmd, .m3u-link{
    font-family:'JetBrains Mono', ui-monospace, monospace;
}

a{ color:var(--accent); text-decoration:none; }
a:hover{ text-decoration:underline; }

/* ---------- Layout ---------- */
.app{
    display:flex;
    min-height:100vh;
}

.sidebar{
    width:230px;
    flex-shrink:0;
    background:var(--surface);
    border-right:1px solid var(--border);
    padding:24px 0;
    display:flex;
    flex-direction:column;
}

.brand{
    padding:0 20px 20px;
    border-bottom:1px solid var(--border);
    margin-bottom:12px;
}
.brand .dot{
    display:inline-block;
    width:8px; height:8px;
    border-radius:50%;
    background:var(--accent);
    margin-right:8px;
    box-shadow:0 0 8px var(--accent);
    animation:pulse 1.6s infinite;
}
.brand h1{ font-size:16px; display:inline; vertical-align:middle; }
.brand p{ color:var(--muted); font-size:12px; margin:6px 0 0; }

.nav a{
    display:flex;
    align-items:center;
    gap:10px;
    padding:11px 20px;
    color:var(--muted);
    font-size:14px;
    border-left:3px solid transparent;
}
.nav a:hover{ color:var(--text); text-decoration:none; background:var(--surface-2); }
.nav a.active{
    color:var(--text);
    border-left-color:var(--accent);
    background:var(--surface-2);
}

.sidebar-footer{
    margin-top:auto;
    padding:16px 20px 0;
    border-top:1px solid var(--border);
}
.sidebar-footer .user{ font-size:13px; color:var(--muted); margin-bottom:8px; }
.logout-btn{ color:var(--warn); font-size:13px; }

.main{
    flex:1;
    padding:32px 40px;
    max-width:1100px;
}

.page-header{
    display:flex;
    justify-content:space-between;
    align-items:flex-end;
    margin-bottom:28px;
}
.page-header p{ color:var(--muted); margin:4px 0 0; font-size:14px; }

/* ---------- Cards ---------- */
.grid{
    display:grid;
    grid-template-columns:repeat(auto-fit, minmax(220px, 1fr));
    gap:16px;
    margin-bottom:28px;
}

.card{
    background:var(--surface);
    border:1px solid var(--border);
    border-radius:var(--radius);
    padding:20px;
}

.stat-card .label{ color:var(--muted); font-size:12px; text-transform:uppercase; letter-spacing:.05em; }
.stat-card .value{ font-size:28px; font-family:'Space Grotesk',sans-serif; margin-top:6px; }

.panel{
    background:var(--surface);
    border:1px solid var(--border);
    border-radius:var(--radius);
    margin-bottom:20px;
    overflow:hidden;
}
.panel-header{
    padding:16px 20px;
    border-bottom:1px solid var(--border);
    display:flex;
    justify-content:space-between;
    align-items:center;
}
.panel-header h3{ font-size:15px; }
.panel-body{ padding:20px; }

/* ---------- Status badges (signature element) ---------- */
.status{
    display:inline-flex;
    align-items:center;
    gap:6px;
    font-size:12px;
    font-weight:600;
    padding:3px 10px;
    border-radius:999px;
    letter-spacing:.03em;
}
.status .pip{ width:7px; height:7px; border-radius:50%; }
.status.on-air{ background:rgba(53,216,176,.12); color:var(--accent); }
.status.on-air .pip{ background:var(--accent); box-shadow:0 0 6px var(--accent); animation:pulse 1.6s infinite; }
.status.off-air{ background:rgba(255,107,93,.12); color:var(--warn); }
.status.off-air .pip{ background:var(--warn); }
.status.idle{ background:rgba(124,139,153,.12); color:var(--muted); }
.status.idle .pip{ background:var(--muted); }

@keyframes pulse{
    0%,100%{ opacity:1; }
    50%{ opacity:.35; }
}

/* ---------- Tables ---------- */
table{ width:100%; border-collapse:collapse; }
th{
    text-align:left;
    font-size:11px;
    text-transform:uppercase;
    letter-spacing:.06em;
    color:var(--muted);
    padding:10px 12px;
    border-bottom:1px solid var(--border);
}
td{
    padding:12px;
    border-bottom:1px solid var(--border);
    font-size:14px;
    vertical-align:middle;
}
tr:last-child td{ border-bottom:none; }

/* ---------- Forms ---------- */
label{ display:block; font-size:13px; color:var(--muted); margin-bottom:6px; }
input[type=text], input[type=password], input[type=number], input[type=url], select{
    width:100%;
    background:var(--bg);
    border:1px solid var(--border);
    color:var(--text);
    padding:10px 12px;
    border-radius:8px;
    font-size:14px;
    margin-bottom:16px;
}
input:focus, select:focus{ outline:2px solid var(--accent); outline-offset:1px; }

.field-row{ display:flex; gap:12px; }
.field-row > div{ flex:1; }

.btn{
    display:inline-flex;
    align-items:center;
    gap:8px;
    background:var(--accent);
    color:#02110D;
    border:none;
    padding:10px 18px;
    border-radius:8px;
    font-weight:600;
    font-size:14px;
    cursor:pointer;
}
.btn:hover{ filter:brightness(1.08); }
.btn.secondary{ background:var(--surface-2); color:var(--text); border:1px solid var(--border); }
.btn.danger{ background:var(--warn-dim); color:#FFDAD5; }
.btn:disabled{ opacity:.5; cursor:not-allowed; }

.icon-btn{
    background:none; border:none; color:var(--muted); cursor:pointer; font-size:16px;
}
.icon-btn:hover{ color:var(--text); }

/* ---------- M3U link / token boxes ---------- */
.token-box{
    display:flex;
    align-items:center;
    gap:10px;
    background:var(--bg);
    border:1px solid var(--border);
    border-radius:8px;
    padding:10px 14px;
    color:var(--accent);
    font-size:13px;
    word-break:break-all;
}
.token-box button{ flex-shrink:0; }

.cron-cmd{
    display:block;
    background:var(--bg);
    border:1px solid var(--border);
    border-radius:8px;
    padding:14px 16px;
    color:var(--accent);
    font-size:13px;
    white-space:pre-wrap;
    word-break:break-all;
    margin:10px 0 18px;
}

/* ---------- Countdown clock (signature element) ---------- */
.broadcast-clock{
    font-family:'JetBrains Mono', monospace;
    font-size:22px;
    letter-spacing:.05em;
    color:var(--accent);
}
.broadcast-clock.stale{ color:var(--warn); }

/* ---------- Alerts / toasts ---------- */
.alert{
    padding:12px 16px;
    border-radius:8px;
    font-size:14px;
    margin-bottom:16px;
}
.alert.error{ background:rgba(255,107,93,.1); color:var(--warn); border:1px solid var(--warn-dim); }
.alert.success{ background:rgba(53,216,176,.1); color:var(--accent); border:1px solid var(--accent-dim); }

.toast{
    position:fixed;
    bottom:24px;
    right:24px;
    background:var(--surface-2);
    border:1px solid var(--border);
    color:var(--text);
    padding:12px 18px;
    border-radius:8px;
    font-size:14px;
    box-shadow:0 8px 24px rgba(0,0,0,.4);
    display:none;
    z-index:999;
}

/* ---------- Login page ---------- */
.login-wrap{
    min-height:100vh;
    display:flex;
    align-items:center;
    justify-content:center;
    background:
        radial-gradient(circle at 20% 20%, rgba(53,216,176,.06), transparent 40%),
        var(--bg);
}
.login-box{
    width:360px;
    background:var(--surface);
    border:1px solid var(--border);
    border-radius:var(--radius);
    padding:36px 32px;
}
.login-box .brand-row{ display:flex; align-items:center; gap:10px; margin-bottom:6px; }
.login-box .dot{ width:9px; height:9px; border-radius:50%; background:var(--accent); box-shadow:0 0 8px var(--accent); animation:pulse 1.6s infinite; }
.login-box h1{ font-size:18px; }
.login-box p.sub{ color:var(--muted); font-size:13px; margin:6px 0 24px; }
.login-box .btn{ width:100%; justify-content:center; margin-top:6px; }

.empty-state{
    text-align:center;
    padding:48px 20px;
    color:var(--muted);
}
.empty-state .btn{ margin-top:14px; }

/* Modal */
.modal-backdrop{
    position:fixed; inset:0; background:rgba(0,0,0,.6);
    display:none; align-items:center; justify-content:center; z-index:100;
}
.modal-backdrop.open{ display:flex; }
.modal{
    background:var(--surface);
    border:1px solid var(--border);
    border-radius:var(--radius);
    padding:28px;
    width:440px;
    max-width:90vw;
    max-height:85vh;
    overflow-y:auto;
}
.modal h3{ margin-bottom:18px; }

@media (max-width: 760px){
    .app{ flex-direction:column; }
    .sidebar{ width:100%; border-right:none; border-bottom:1px solid var(--border); }
    .nav{ display:flex; overflow-x:auto; }
    .nav a{ border-left:none; border-bottom:3px solid transparent; white-space:nowrap; }
    .nav a.active{ border-bottom-color:var(--accent); border-left-color:transparent; }
    .sidebar-footer{ display:none; }
    .main{ padding:20px; }
    .field-row{ flex-direction:column; gap:0; }
}
