:root {
    color-scheme: dark;
    --bg: #101418;
    --panel: #1a2029;
    --input-bg: #0d1117;
    --border: #2a323d;
    --text: #e6e9ee;
    --muted: #8a94a3;
    --accent: #4f9dff;
    --danger: #ff5f5f;
    --ok: #43c17a;
}

:root[data-theme="light"] {
    color-scheme: light;
    --bg: #f4f5f7;
    --panel: #ffffff;
    --input-bg: #f7f8fa;
    --border: #dde1e7;
    --text: #1a1f28;
    --muted: #667085;
    --accent: #2563eb;
    --danger: #dc2626;
    --ok: #16a34a;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.wrap {
    max-width: 1320px;
    margin: 0 auto;
    padding: 24px 16px 64px;
}

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
}

h1, h2 { margin-top: 0; }

label { display: block; margin: 12px 0 4px; color: var(--muted); font-size: 0.9em; }

input[type=text], input[type=password], input[type=number], input[type=datetime-local], input[type=email] {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--input-bg);
    color: var(--text);
    font-size: 1em;
}

/* Só precisa da largura do próprio conteúdo (dd/mm/aaaa hh:mm + ícone). */
input[type=datetime-local] {
    width: auto;
}

button, .btn {
    display: inline-block;
    margin-top: 16px;
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-size: 1em;
    cursor: pointer;
    text-decoration: none;
    transition: filter 0.15s ease, box-shadow 0.15s ease;
}

button:hover, .btn:hover {
    filter: brightness(1.12);
    box-shadow: 0 0 14px rgba(79,157,255,.65);
}

button:active, .btn:active {
    filter: brightness(0.95);
    box-shadow: none;
}

button.danger, .btn.danger { background: var(--danger); }
button.secondary, .btn.secondary { background: #4b5563; }

button.danger:hover, .btn.danger:hover { box-shadow: 0 0 14px rgba(255,95,95,.65); }
button.secondary:hover, .btn.secondary:hover { box-shadow: 0 0 14px rgba(148,163,184,.55); }

.action-btn { margin: 0; padding: 6px 8px; font-size: 0.82em; min-width: 68px; text-align: center; }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; margin-top: 12px; }
th, td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--border); font-size: 0.88em; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; }

.badge { padding: 2px 8px; border-radius: 999px; font-size: 0.8em; }
.badge.ok { background: rgba(67,193,122,.15); color: var(--ok); }
.badge.expired { background: rgba(255,95,95,.15); color: var(--danger); }
.badge.scheduled { background: rgba(79,157,255,.15); color: var(--accent); }

.error { color: var(--danger); margin-top: 12px; }
.hint { color: var(--muted); font-size: 0.85em; }

.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.topbar a { color: var(--muted); text-decoration: none; }
.topbar a.btn { color: #fff; }

.topbar-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; }
.topbar-actions .dot { color: var(--muted); }

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: modal-fade-in 0.15s ease;
}

.modal-box {
    position: relative;
    margin: 0;
    max-width: 90%;
    text-align: center;
    font-size: 1.05em;
    animation: modal-pop-in 0.15s ease;
}

.modal-close {
    position: absolute;
    top: -12px;
    right: -12px;
    margin: 0;
    padding: 0;
    width: 28px;
    height: 28px;
    line-height: 28px;
    border-radius: 50%;
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 1.2em;
    box-shadow: none;
}

.modal-close:hover {
    background: var(--panel);
    color: var(--text);
    border-color: var(--muted);
    filter: none;
    box-shadow: none;
}

@keyframes modal-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modal-pop-in {
    from { opacity: 0; transform: scale(0.92); }
    to { opacity: 1; transform: scale(1); }
}

/* Modal do live feed do admin — flutuante, arrastável e redimensionável
   (ver assets/js/live-feed.js). Ao contrário do .modal-overlay genérico,
   não centra por flexbox: a caixa tem posição própria para poder ser
   arrastada livremente. */
.live-feed-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 1000;
    animation: modal-fade-in 0.15s ease;
}

.live-feed-box {
    position: fixed;
    top: 8%;
    left: 50%;
    transform: translateX(-50%);
    width: 720px;
    height: 480px;
    min-width: 320px;
    min-height: 220px;
    max-width: 96vw;
    max-height: 90vh;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    resize: both;
    box-shadow: 0 12px 40px rgba(0,0,0,.45);
    animation: modal-pop-in 0.15s ease;
}

.live-feed-box:fullscreen {
    width: 100vw !important;
    height: 100vh !important;
    top: 0 !important;
    left: 0 !important;
    transform: none !important;
    max-width: none;
    max-height: none;
    border-radius: 0;
}

.live-feed-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--input-bg);
    border-bottom: 1px solid var(--border);
    cursor: move;
    user-select: none;
    flex-shrink: 0;
}

.live-feed-controls { display: flex; gap: 6px; }

.live-feed-controls button {
    margin: 0;
    padding: 4px 10px;
    font-size: 0.95em;
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: none;
}
.live-feed-controls button:hover { filter: brightness(1.3); box-shadow: none; }

.live-feed-body { flex: 1; background: #000; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.live-feed-body video { width: 100%; height: 100%; object-fit: contain; }

#player-wrap { background: #000; border-radius: 12px; overflow: hidden; aspect-ratio: 16/9; display: flex; align-items: center; justify-content: center; }
#player-wrap video { width: 100%; height: 100%; object-fit: contain; }
#status-msg { color: var(--muted); text-align: center; padding: 24px; }

/* Marca (logo + nome), usada no topo das páginas */
.brand-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    text-decoration: none;
    color: inherit;
    width: fit-content;
}
.brand-header:hover .brand-name { color: var(--accent); }
.brand-header img { height: 44px; width: auto; }
.brand-header .brand-name { font-size: 1.25em; font-weight: 700; letter-spacing: .3px; }

.brand-hero { text-align: center; }
.brand-hero img { height: 210px; width: auto; margin-bottom: 8px; }
.brand-hero .brand-name { display: block; font-size: 1.8em; font-weight: 700; letter-spacing: .5px; }
.brand-hero .brand-tagline { color: var(--muted); margin-top: 4px; }

/* Contactos, usados no rodapé da página de stream e na inicial */
.contact-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 20px; }
.contact-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 8px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text);
    text-decoration: none;
    font-size: 0.92em;
    transition: filter 0.15s ease, box-shadow 0.15s ease;
}
.contact-link:hover { filter: brightness(1.1); box-shadow: 0 0 12px rgba(79,157,255,.35); }
.contact-link svg { width: 18px; height: 18px; fill: currentColor; flex-shrink: 0; }

/* Botão de alternar tema claro/escuro */
#theme-toggle {
    position: fixed;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    margin: 0;
    padding: 0;
    border-radius: 50%;
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 1.1em;
    line-height: 38px;
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
    z-index: 900;
}
#theme-toggle:hover { filter: none; box-shadow: 0 2px 12px rgba(0,0,0,.35); }

.site-footer {
    text-align: center;
    color: var(--muted);
    font-size: 0.82em;
    margin-top: 32px;
    padding-bottom: 12px;
}

.link-btn {
    display: inline;
    margin: 0;
    padding: 0;
    border: none;
    background: none;
    color: var(--muted);
    text-decoration: underline;
    font-size: inherit;
    cursor: pointer;
    box-shadow: none;
}
.link-btn:hover { color: var(--accent); filter: none; box-shadow: none; }

@media (max-width: 700px) {
    .wrap { padding: 16px 12px 48px; }
    .card { padding: 16px; }
    .topbar { flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
    .topbar button { margin-top: 0; }
    .topbar > div { text-align: left !important; width: 100%; }
    .topbar-actions { justify-content: flex-start; }
    .topbar-actions .dot { display: none; }
    #theme-toggle { top: auto; bottom: 16px; right: 16px; }

    /* Tabela -> lista de "cartões" empilhados, para não haver scroll
       horizontal nem células cortadas em ecrãs estreitos. */
    table, thead, tbody, tr, th, td { display: block; width: 100%; }
    thead { display: none; }
    table { margin-top: 0; }

    tbody tr {
        background: var(--input-bg);
        border: 1px solid var(--border);
        border-radius: 10px;
        margin-bottom: 12px;
        padding: 4px 0;
    }

    td {
        border-bottom: none;
        white-space: normal;
        padding: 8px 12px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 10px;
    }

    td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 0.78em;
        flex-shrink: 0;
    }

    /* Colunas com conteúdo mais complexo (link + botão, acções) ficam
       melhor com a legenda por cima em vez de lado a lado. */
    td[data-label="Link"],
    td[data-label="Acções"] {
        flex-direction: column;
        align-items: stretch;
    }
    td[data-label="Link"] > div,
    td[data-label="Acções"] { gap: 8px; }
    td[data-label="Link"] input[type=text] { width: 100% !important; }
}
