@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@500;600;700;800&display=swap");

:root {
    --bg: #f6f8fc;
    --surface: rgba(255, 255, 255, 0.94);
    --surface-strong: #ffffff;
    --surface-soft: #f9fbff;
    --line: #dfe6f2;
    --line-strong: #cbd8ec;
    --text: #162033;
    --muted: #73819b;
    --primary: #0f46ff;
    --primary-dark: #0a35c8;
    --primary-soft: #eaf1ff;
    --sidebar: #fbfcff;
    --sidebar-line: #e4eaf5;
    --success: #0d8a5f;
    --danger: #df3c5f;
    --warning: #db7b11;
    --shadow-soft: 0 18px 50px rgba(33, 52, 96, 0.07);
    --shadow-card: 0 12px 30px rgba(38, 63, 122, 0.06);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Manrope", "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(15, 70, 255, 0.08), transparent 24%),
        linear-gradient(180deg, #fbfcff 0%, var(--bg) 35%, #f4f7fc 100%);
}

.login-screen {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-panel {
    width: min(420px, 100%);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 28px;
    padding: 36px;
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(18px);
}

.login-panel h1 {
    margin: 18px 0 6px;
    font-size: 28px;
}

.login-panel p {
    color: var(--muted);
    margin-bottom: 24px;
}

.login-panel label span {
    display: block;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 6px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    border-radius: 18px;
    background: #fff;
    border: 1px solid var(--line);
    overflow: hidden;
}

.brand-mark img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 6px;
}

.admin-shell {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--sidebar);
    color: var(--text);
    padding: 24px 16px;
    border-right: 1px solid var(--sidebar-line);
    box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.7);
}

.sidebar-brand {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 6px 10px 22px;
    border-bottom: 1px solid var(--sidebar-line);
}

.sidebar-brand strong {
    font-size: 17px;
    letter-spacing: -0.02em;
}

.sidebar-brand span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-top: 3px;
}

.sidebar nav {
    display: grid;
    gap: 8px;
    margin-top: 24px;
}

.sidebar a {
    color: #5f6f8a;
    text-decoration: none;
    padding: 13px 14px;
    border-radius: 16px;
    font-weight: 700;
    border: 1px solid transparent;
    transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.sidebar a.active,
.sidebar a:hover {
    background: var(--primary-soft);
    border-color: #d4e1ff;
    color: var(--primary);
    transform: translateX(2px);
}

.content {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100vh;
    padding: 30px;
}

.site-footer {
    margin-top: auto;
    padding: 22px 0 4px;
    color: var(--muted);
    font-size: 12px;
}

.site-footer a {
    color: inherit;
    text-decoration: none;
}

.site-footer a:hover {
    color: var(--primary);
}

.login-footer {
    position: fixed;
    left: 24px;
    bottom: 20px;
    padding: 0;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 26px;
    padding: 8px 4px 2px;
}

.topbar h1 {
    font-size: 34px;
    letter-spacing: -0.04em;
    margin: 0;
}

.topbar p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.user-box {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--surface-strong);
    border: 1px solid var(--line);
    border-radius: 22px;
    padding: 12px 14px;
    box-shadow: var(--shadow-card);
    backdrop-filter: blur(16px);
}

.user-box span,
.user-box small {
    display: block;
}

.user-box small {
    color: var(--muted);
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(140px, 1fr));
    gap: 16px;
    margin-bottom: 26px;
}

.metric-card,
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 24px;
    box-shadow: var(--shadow-card);
    backdrop-filter: blur(18px);
}

.metric-card {
    padding: 20px 22px;
}

.metric-card span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.metric-card strong {
    display: block;
    margin-top: 10px;
    font-size: 32px;
    letter-spacing: -0.05em;
}

.panel {
    padding: 24px;
    margin-bottom: 22px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.panel-header h2 {
    font-size: 24px;
    letter-spacing: -0.03em;
    margin: 0;
}

.panel-header p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 7px 12px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.status-pill.online {
    background: #e7fbf3;
    color: var(--success);
}

.status-pill.offline {
    background: #fff0f3;
    color: var(--danger);
}

.status-pill.warning {
    background: #fff4df;
    color: var(--warning);
}

.success-text {
    color: var(--success);
}

.danger-text {
    color: var(--danger);
}

.grid-two {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 20px;
}

.list-stack {
    display: grid;
    gap: 10px;
}

.activity-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
}

.activity-row:last-child {
    border-bottom: 0;
}

.activity-row strong,
.activity-row span,
.activity-row small {
    display: block;
}

.activity-row span,
.activity-row small,
.empty-state {
    color: var(--muted);
}

.form-panel label {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    gap: 16px;
}

.compact-form {
    grid-template-columns: repeat(3, minmax(180px, 1fr));
}

.form-grid .form-control,
.form-grid .form-select {
    margin-top: 6px;
}

.full-span,
.form-actions {
    grid-column: 1 / -1;
}

.form-actions,
.button-row,
.actions-cell {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.actions-cell form {
    display: inline-flex;
    margin: 0;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
}

.field-label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 8px;
}

.weekday-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
}

.pairing-input {
    text-transform: uppercase;
    font-weight: 800;
    letter-spacing: 0;
}

.table {
    margin-bottom: 0;
}

.filter-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.filter-pill {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
    font-size: 13px;
    background: rgba(255, 255, 255, 0.85);
    transition: all 0.18s ease;
}

.filter-pill.active,
.filter-pill:hover {
    background: var(--primary-soft);
    border-color: #cbdcff;
    color: var(--primary);
}

.media-thumb {
    width: 76px;
    height: 48px;
    border-radius: 12px;
    object-fit: cover;
    border: 1px solid var(--line);
    background: #eef2f6;
}

.media-thumb.placeholder {
    display: inline-grid;
    place-items: center;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
}

.table-subtext {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-top: 2px;
}

.media-edit-layout {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 18px;
    align-items: start;
}

.media-preview-large .media-thumb {
    width: 180px;
    height: 112px;
}

.playlist-item-form {
    display: grid;
    grid-template-columns: 88px 140px 78px 130px 130px 130px 105px 74px;
    gap: 8px;
    align-items: center;
    min-width: 900px;
}

.playlist-preview {
    display: none;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.playlist-preview[data-orientation="vertical_right"],
.playlist-preview[data-orientation="vertical_left"] {
    width: min(360px, 100%);
    aspect-ratio: 9 / 16;
    margin-inline: auto;
    grid-template-columns: 1fr;
}

.playlist-preview[data-orientation="vertical_right"]::before,
.playlist-preview[data-orientation="vertical_left"]::before {
    display: block;
    grid-column: 1 / -1;
    padding: 8px 12px;
    border-radius: 8px;
    background: #ecfeff;
    color: #155e75;
    font-size: .82rem;
    font-weight: 700;
}

.playlist-preview[data-orientation="vertical_right"]::before { content: "Prévia vertical · rotação 90° à direita"; }
.playlist-preview[data-orientation="vertical_left"]::before { content: "Prévia vertical · rotação 90° à esquerda"; }

.preview-open .playlist-preview {
    display: grid;
}

.preview-frame {
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 12px;
    background: #f8fbff;
}

.preview-frame .media-thumb {
    width: 100%;
    height: 96px;
    margin-bottom: 8px;
}

.preview-frame strong,
.preview-frame span {
    display: block;
}

.preview-frame span {
    color: var(--muted);
    font-size: 12px;
}

.call-console-panel {
    border-color: rgba(15, 118, 110, 0.28);
}

.call-client-switch label {
    display: grid;
    min-width: min(360px, 100%);
    font-size: 13px;
    font-weight: 700;
    gap: 6px;
}

.call-send-form {
    display: grid;
    gap: 18px;
}

.call-primary-field {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) auto;
    gap: 14px;
    align-items: end;
}

.call-primary-field label {
    display: grid;
    gap: 8px;
    font-size: 13px;
    font-weight: 800;
}

.call-name-input {
    min-height: 64px;
    font-size: 30px;
    font-weight: 800;
}

.call-theme-grid {
    align-items: stretch;
}

.call-preview-panel {
    min-height: 100%;
}

.call-theme-preview {
    min-height: 280px;
    display: grid;
    align-content: center;
    justify-items: center;
    gap: 10px;
    padding: 28px;
    border-radius: 22px;
    color: #fff;
    text-align: center;
    overflow: hidden;
    background-color: #101820;
    background-size: cover;
    background-position: center;
    border: 1px solid rgba(255, 255, 255, 0.16);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.call-theme-preview img,
.call-preview-logo {
    width: 92px;
    height: 54px;
    object-fit: contain;
    display: grid;
    place-items: center;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.92);
    color: #1e2933;
    font-size: 12px;
    font-weight: 800;
}

.call-theme-preview small {
    padding: 5px 12px;
    border: 1px solid var(--call-preview-accent, #d6b56d);
    border-radius: 999px;
    color: var(--call-preview-accent, #d6b56d);
    font-weight: 800;
    text-transform: uppercase;
}

.call-theme-preview strong {
    font-size: 40px;
    line-height: 1.05;
}

.call-theme-preview em,
.call-preview-video {
    color: #d7dde6;
    font-style: normal;
}

.call-preview-video {
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.32);
    font-size: 12px;
    font-weight: 800;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 12px 24px rgba(15, 70, 255, 0.18);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn,
.btn-sm,
.form-control,
.form-select,
.form-check-input {
    border-radius: 14px;
}

.btn {
    font-weight: 800;
    letter-spacing: -0.01em;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease, border-color 0.18s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-outline-secondary,
.btn-outline-success,
.btn-outline-warning,
.btn-outline-danger {
    background: rgba(255, 255, 255, 0.92);
}

.form-control,
.form-select {
    min-height: 48px;
    border-color: var(--line-strong);
    background: rgba(255, 255, 255, 0.94);
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.02);
}

.form-control:focus,
.form-select:focus,
.btn:focus,
.form-check-input:focus {
    border-color: #b7cbff;
    box-shadow: 0 0 0 0.22rem rgba(15, 70, 255, 0.12);
}

.table {
    --bs-table-bg: transparent;
    --bs-table-striped-bg: rgba(244, 247, 255, 0.6);
    --bs-table-hover-bg: rgba(234, 241, 255, 0.6);
    --bs-table-border-color: var(--line);
}

.table thead th {
    color: #55647c;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 800;
    border-bottom-width: 1px;
    padding-top: 0;
}

.table tbody td {
    padding-top: 14px;
    padding-bottom: 14px;
    vertical-align: middle;
}

.table-responsive {
    border: 1px solid rgba(223, 230, 242, 0.8);
    border-radius: 20px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.72);
}

.alert {
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow-card);
}

@media (max-width: 1100px) {
    .admin-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
    }

    .metrics-grid {
        grid-template-columns: repeat(2, minmax(140px, 1fr));
    }

    .grid-two,
    .form-grid,
    .compact-form,
    .call-primary-field {
        grid-template-columns: 1fr;
    }

    .media-edit-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .topbar,
    .panel-header,
    .user-box {
        align-items: flex-start;
        flex-direction: column;
    }

    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .content {
        padding: 18px;
    }
}

.billing-warning {
    margin-bottom: 18px;
    padding: 14px 16px;
    border: 1px solid #ffd39d;
    border-radius: 18px;
    background: linear-gradient(180deg, #fffaf1, #fff4df);
    color: #9a4f09;
    font-weight: 700;
}

.orientation-picker {
    display: grid;
    grid-template-columns: repeat(3, minmax(150px, 1fr));
    gap: 12px;
    border: 0;
    padding: 0;
}
.orientation-picker legend { grid-column: 1 / -1; font-weight: 800; }
.orientation-option { display: grid; justify-items: center; gap: 7px; padding: 18px; border: 1px solid #d9e3f3; border-radius: 18px; text-align: center; cursor: pointer; background: rgba(255,255,255,.88); transition: all .18s ease; }
.orientation-option:has(input:checked) { border-color: #bdd0ff; background: #eff5ff; box-shadow: 0 0 0 3px rgba(15,70,255,.10); }
.orientation-preview { display:grid;place-items:center;width:92px;height:54px;border:2px solid #8da0bc;border-radius:10px;font-size:28px;background:#17327f;color:#fff; }
.orientation-preview.vertical_right,.orientation-preview.vertical_left { width:54px;height:92px; }
.orientation-option small { color:#64748b; }
@media(max-width:700px){.orientation-picker{grid-template-columns:1fr}}

.license-summary .metric-card,
.license-summary {
    background: linear-gradient(180deg, rgba(255,255,255,.98), rgba(248,251,255,.96));
}

/* Responsive Sticky Actions & Options Dropdown */
.table-responsive {
    position: relative;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table th.sticky-actions-header,
.table td.sticky-actions-col {
    position: sticky;
    right: 0;
    z-index: 10;
    background: #ffffff;
    box-shadow: -5px 0 12px -3px rgba(22, 32, 51, 0.08);
    /* Permite que o dropdown saia para fora da celula sem ser clipado */
    overflow: visible;
}

.table tbody tr:nth-of-type(even) td.sticky-actions-col {
    background: #f8fbff;
}

.table tbody tr:hover td.sticky-actions-col {
    background: #eaf1ff;
}

/* ── Célula do nome da TV com Player + opções ───────────────────────────── */
.device-name-cell {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.device-name-text {
    display: block;
    font-size: 14px;
    letter-spacing: -0.01em;
}

.device-action-group {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

/* Botão Player — verde com gradiente e brilho */
.btn-device-player {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 11px 4px 9px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: #ffffff;
    text-decoration: none;
    white-space: nowrap;
    border-radius: 999px;
    background: linear-gradient(135deg, #0fa868, #0d7a50);
    box-shadow: 0 2px 8px rgba(13, 138, 95, 0.35), inset 0 1px 0 rgba(255,255,255,0.18);
    transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
    border: none;
    cursor: pointer;
}

.btn-device-player:hover {
    color: #fff;
    background: linear-gradient(135deg, #12c47b, #0d8a5f);
    box-shadow: 0 4px 14px rgba(13, 138, 95, 0.45), inset 0 1px 0 rgba(255,255,255,0.22);
    transform: translateY(-1px);
    text-decoration: none;
}

.btn-device-player:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(13, 138, 95, 0.3);
}

/* Botão de três pontinhos (⋮) */
.btn-device-more {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 1px solid var(--line-strong, #cbd8ec);
    border-radius: 999px;
    background: transparent;
    color: var(--muted, #73819b);
    cursor: pointer;
    transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
    line-height: 1;
}

.btn-device-more:hover,
.actions-dropdown.show .btn-device-more {
    background: var(--primary-soft, #eaf1ff);
    border-color: var(--primary, #0f46ff);
    color: var(--primary, #0f46ff);
}

/* Remove estilos antigos substituídos */
.action-btn-player,
.quick-player-btn,
.actions-btn-group,
.sticky-actions-header,
.sticky-actions-col {
    /* substituídos pelo novo layout na célula do nome */
}

/* O wrapper do dropdown precisa de position relative para o toggle de estado */
.actions-dropdown {
    position: relative;
    display: inline-block;
}


.dropdown-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 32px;
    padding: 0 10px;
    font-weight: 800;
    font-size: 15px;
    line-height: 1;
    border-radius: 10px;
    border-color: var(--line-strong, #cbd8ec);
    background: #ffffff;
    color: var(--text, #162033);
}

.dropdown-toggle-btn:hover,
.actions-dropdown.show .dropdown-toggle-btn {
    background: var(--primary-soft, #eaf1ff);
    border-color: #b7cbff;
    color: var(--primary, #0f46ff);
}

.actions-dropdown-menu {
    display: none;
    /* position e top/left/right sao definidos por JS via positionMenu() com fixed */
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    z-index: 9999;
    min-width: 220px;
    padding: 6px 0;
    margin: 0;
    list-style: none;
    background: #ffffff;
    border: 1px solid var(--line-strong, #cbd8ec);
    border-radius: 16px;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.16);
    backdrop-filter: blur(14px);
    text-align: left;
    /* Garante que nao e clipado por overflow de containers pai */
    pointer-events: auto;
}

.actions-dropdown.show .actions-dropdown-menu {
    display: block;
    animation: dropdownMenuShow 0.16s ease-out;
}

@keyframes dropdownMenuShow {
    from {
        opacity: 0;
        transform: translateY(-6px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.actions-dropdown-menu .dropdown-item {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text, #162033);
    text-decoration: none;
    background: transparent;
    border: 0;
    cursor: pointer;
    transition: background-color 0.12s ease, color 0.12s ease;
}

.actions-dropdown-menu .dropdown-item svg {
    flex-shrink: 0;
}

.actions-dropdown-menu .dropdown-item:hover {
    background-color: var(--primary-soft, #eaf1ff);
    color: var(--primary, #0f46ff);
}

.actions-dropdown-menu .dropdown-item.text-warning {
    color: var(--warning, #db7b11);
}

.actions-dropdown-menu .dropdown-item.text-warning:hover {
    background-color: #fff4df;
    color: var(--warning, #db7b11);
}

.actions-dropdown-menu .dropdown-item.text-danger {
    color: var(--danger, #df3c5f);
}

.actions-dropdown-menu .dropdown-item.text-danger:hover {
    background-color: #fff0f3;
    color: var(--danger, #df3c5f);
}

.actions-dropdown-menu .dropdown-divider {
    height: 1px;
    margin: 5px 0;
    background-color: var(--line, #dfe6f2);
}

.dropdown-item-form {
    margin: 0;
    padding: 0;
}

/* Linha de informação somente-leitura dentro do dropdown (ex: IP do dispositivo) */
.dropdown-item-info {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 700;
    color: var(--muted, #73819b);
    background: var(--surface-soft, #f9fbff);
    border-radius: 0;
    cursor: default;
    user-select: text;
    font-variant-numeric: tabular-nums;
}

.dropdown-item-info svg {
    flex-shrink: 0;
    opacity: 0.6;
}


.quick-player-btn {
    font-weight: 800;
    font-size: 11px;
    letter-spacing: -0.01em;
    border-radius: 8px;
    white-space: nowrap;
}

