/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:          #0f1117;
    --surface:     #1a1d27;
    --surface2:    #23273a;
    --accent:      #e8433e;
    --accent-dark: #b53330;
    --text:        #e2e5f0;
    --muted:       #7b82a0;
    --radius:      10px;
    --dj-bubble:   #2b3050;
    --listener-bubble: #1e2235;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', system-ui, sans-serif;
    font-size: 15px;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

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

/* ── Layout ───────────────────────────────────────────────────────────────── */
.app-header {
    background: var(--surface);
    border-bottom: 1px solid #2a2e42;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.app-header .logo {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--accent);
    letter-spacing: .04em;
}
.app-header .dj-name { font-weight: 600; }
.app-header .badge {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 99px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
}
.badge-live    { background: #1e4d2b; color: #4ade80; }
.badge-offline { background: #3d1f1f; color: var(--accent); }
.badge-dj      { background: var(--accent); color: #fff; }
.spacer { flex: 1; }

/* ── Chat window ──────────────────────────────────────────────────────────── */
.chat-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 720px;
    width: 100%;
    margin: 0 auto;
    padding: 0 16px 16px;
}

#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 300px;
    max-height: calc(100dvh - 200px);
}

/* ── Message bubbles ──────────────────────────────────────────────────────── */
.msg {
    display: flex;
    flex-direction: column;
    max-width: 80%;
}
.msg.dj      { align-self: flex-end; align-items: flex-end; }
.msg.listener{ align-self: flex-start; }

.msg .meta {
    font-size: 0.72rem;
    color: var(--muted);
    margin-bottom: 3px;
    padding: 0 4px;
}
.msg.dj .meta { text-align: right; }
.msg .meta .role-dj { color: var(--accent); font-weight: 600; }

.msg .bubble {
    padding: 8px 13px;
    border-radius: var(--radius);
    line-height: 1.45;
    word-break: break-word;
    position: relative;
}
.msg.dj      .bubble { background: var(--dj-bubble);      border-bottom-right-radius: 2px; }
.msg.listener .bubble { background: var(--listener-bubble); border-bottom-left-radius: 2px; }

.msg .del-btn {
    visibility: hidden;
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 0.75rem;
    padding: 0 4px;
    align-self: flex-end;
}
.msg:hover .del-btn { visibility: visible; }
.msg .del-btn:hover  { color: var(--accent); }

/* ── Input bar ────────────────────────────────────────────────────────────── */
.input-bar {
    display: flex;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px solid #2a2e42;
}
.input-bar input[type=text] {
    flex: 1;
    background: var(--surface2);
    border: 1px solid #2a2e42;
    border-radius: var(--radius);
    color: var(--text);
    padding: 10px 14px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color .2s;
}
.input-bar input[type=text]:focus { border-color: var(--accent); }
.input-bar button {
    background: var(--accent);
    border: none;
    border-radius: var(--radius);
    color: #fff;
    font-weight: 700;
    padding: 10px 20px;
    cursor: pointer;
    transition: background .2s;
}
.input-bar button:hover { background: var(--accent-dark); }
.input-bar button:disabled { opacity: .5; cursor: default; }

/* ── Login / info cards ───────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid #2a2e42;
    border-radius: var(--radius);
    padding: 28px 32px;
    max-width: 420px;
    width: 100%;
    margin: 60px auto;
}
.card h2 { margin-bottom: 18px; font-size: 1.2rem; }
.card label { display: block; margin-bottom: 6px; font-size: 0.85rem; color: var(--muted); }
.card input {
    width: 100%;
    background: var(--surface2);
    border: 1px solid #2a2e42;
    border-radius: 7px;
    color: var(--text);
    padding: 9px 13px;
    font-size: 0.95rem;
    margin-bottom: 14px;
    outline: none;
}
.card input:focus { border-color: var(--accent); }
.card button {
    width: 100%;
    background: var(--accent);
    border: none;
    border-radius: 7px;
    color: #fff;
    font-weight: 700;
    padding: 11px;
    cursor: pointer;
    font-size: 1rem;
    transition: background .2s;
}
.card button:hover { background: var(--accent-dark); }
.card .error { color: var(--accent); font-size: 0.85rem; margin-top: 8px; }

/* ── Offline / notice ─────────────────────────────────────────────────────── */
.notice {
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
}
.notice h2 { font-size: 1.5rem; margin-bottom: 10px; color: var(--text); }

/* ── Admin panel ──────────────────────────────────────────────────────────── */
.admin-wrap {
    max-width: 860px;
    margin: 0 auto;
    padding: 24px 20px;
}
.admin-wrap h1 { margin-bottom: 24px; font-size: 1.4rem; }
.admin-wrap h2 { margin: 28px 0 14px; font-size: 1.1rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-size: .8rem; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
table th, table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #2a2e42;
}
table th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; }

.btn {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 0.83rem;
    font-weight: 600;
    transition: opacity .15s;
}
.btn:hover { opacity: .85; }
.btn-primary { background: var(--accent);  color: #fff; }
.btn-danger  { background: #5c1f1f; color: #f87171; }
.btn-sm      { padding: 4px 10px; font-size: 0.78rem; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid #2a2e42; }

.form-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.form-row label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: 4px; }
.form-row input, .form-row select {
    background: var(--surface2);
    border: 1px solid #2a2e42;
    border-radius: 7px;
    color: var(--text);
    padding: 8px 12px;
    font-size: 0.9rem;
    width: 100%;
    outline: none;
}
.form-row input:focus { border-color: var(--accent); }
.form-group { flex: 1; min-width: 160px; }

.flash-success { background: #1a3a28; color: #4ade80; padding: 10px 16px; border-radius: 7px; margin-bottom: 16px; font-size: .9rem; }
.flash-error   { background: #3d1f1f; color: #f87171; padding: 10px 16px; border-radius: 7px; margin-bottom: 16px; font-size: .9rem; }

.status-active   { color: #4ade80; }
.status-inactive { color: var(--muted); }
