/* ===== Variáveis CSS para Tema Dark/Light ===== */
:root {
    /* Light Theme (padrão) */
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-sidebar: #0f172a;
    --text-primary: #333;
    --text-secondary: #666;
    --text-muted: #999;
    --border-color: #ddd;
    --card-shadow: rgba(0, 0, 0, 0.1);
    --table-hover: #f9f9f9;
    --input-bg: #ffffff;
    --input-border: #e5e7eb;
    --alert-success-bg: #d4edda;
    --alert-success-border: #28a745;
    --alert-success-text: #155724;
    --alert-error-bg: #f8d7da;
    --alert-error-border: #dc3545;
    --alert-error-text: #721c24;
    --stat-card-bg: #ffffff;
    --sidebar-nav-hover: rgba(55, 65, 81, 0.75);
    --sidebar-nav-active: rgba(79, 70, 229, 0.18);
}

/* Dark Theme */
[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2a2a2a;
    --bg-sidebar: #0a0f1e;
    --text-primary: #e5e7eb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --border-color: #374151;
    --card-shadow: rgba(0, 0, 0, 0.3);
    --table-hover: #374151;
    --input-bg: #374151;
    --input-border: #4b5563;
    --alert-success-bg: rgba(34, 197, 94, 0.15);
    --alert-success-border: #22c55e;
    --alert-success-text: #86efac;
    --alert-error-bg: rgba(239, 68, 68, 0.15);
    --alert-error-border: #ef4444;
    --alert-error-text: #fca5a5;
    --stat-card-bg: #2a2a2a;
    --sidebar-nav-hover: rgba(55, 65, 81, 0.5);
    --sidebar-nav-active: rgba(99, 102, 241, 0.25);
}

/* Estilos gerais da aplicação */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Tabela principal */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-secondary);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px var(--card-shadow);
    font-size: 0.95rem;
}

/* Cabeçalho da tabela */
.data-table thead {
    background: #2c3e50;
    color: #ecf0f1;
}

.data-table thead th {
    padding: 0.9rem 1rem;
    text-align: left;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.04em;
}

/* Corpo da tabela */
.data-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.15s ease, transform 0.08s ease;
}

.data-table tbody tr:last-child {
    border-bottom: none;
}

.data-table tbody tr:hover {
    background-color: var(--table-hover);
    transform: translateY(-1px);
}

.data-table td {
    padding: 0.8rem 1rem;
    color: var(--text-primary);
    vertical-align: middle;
}

/* Colunas numéricas alinhadas à direita (Orçamento / Créditos) */
.data-table td:nth-child(3),
.data-table td:nth-child(4) {
    text-align: left;
}

/* Nome da campanha em destaque */
.data-table td strong {
    font-weight: 600;
    color: var(--text-primary);
}

/* Estados / badges dentro da tabela */
.status-online,
.status-offline,
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.7rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    white-space: nowrap;
}

/* Ativa */
.status-online {
    background: rgba(46, 204, 113, 0.12);
    color: #27ae60;
    border: 1px solid rgba(39, 174, 96, 0.4);
}

/* Concluída */
.status-offline {
    background: rgba(231, 76, 60, 0.12);
    color: #c0392b;
    border: 1px solid rgba(192, 57, 43, 0.4);
}

/* Pausada / Rascunho genérico */
.badge {
    background: rgba(44, 62, 80, 0.06);
    color: #e99c10;
    border: 1px solid #e99c1075;
}

/* Estado vazio da tabela */
.empty-state {
    padding: 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* Responsividade básica da tabela */
@media (max-width: 768px) {
    .data-table {
        font-size: 0.85rem;
    }

    .data-table thead th,
    .data-table td {
        padding: 0.6rem 0.7rem;
    }
}


/* Login Page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
}

.login-box h1 {
    text-align: center;
    color: #667eea;
    margin-bottom: 10px;
    font-size: 32px;
}

.login-box h2 {
    text-align: center;
    margin-bottom: 30px;
    color: #666;
    font-size: 24px;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--input-border);
    background: var(--input-bg);
    color: var(--text-primary);
    border-radius: 5px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: all 0.3s;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-warning {
    background: #ffc107;
    color: #212529;
}

.btn-warning:hover {
    background: #e0a800;
}

.btn-block {
    width: 100%;
    display: block;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

/* Alerts */
.alert {
    padding: 12px 20px;
    margin-bottom: 20px;
    border-radius: 5px;
    border-left: 4px solid;
}

.alert-success {
    background: var(--alert-success-bg);
    border-color: var(--alert-success-border);
    color: var(--alert-success-text);
}

.alert-error {
    background: var(--alert-error-bg);
    border-color: var(--alert-error-border);
    color: var(--alert-error-text);
}

.alert-info {
    background: #d1ecf1;
    border-color: #17a2b8;
    color: #0c5460;
}

.alert-warning {
    background: #fff3cd;
    border-color: #ffc107;
    color: #856404;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    background: var(--bg-secondary);
    box-shadow: 0 2px 4px var(--card-shadow);
    margin-bottom: 30px;
    padding: 15px 0;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 24px;
    color: #667eea;
}

.nav {
    display: flex;
    gap: 20px;
}

.nav a {
    text-decoration: none;
    color: #555;
    font-weight: 600;
    transition: color 0.3s;
}

.nav a:hover,
.nav a.active {
    color: #667eea;
}

/* Tables */
.table {
    width: 100%;
    background: var(--bg-secondary);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 10px var(--card-shadow);
}

.table table {
    width: 100%;
    border-collapse: collapse;
}

.table thead {
    background: #667eea;
    color: white;
}

.table th,
.table td {
    padding: 12px;
    text-align: left;
}

.table tbody tr:hover {
    background: var(--table-hover);
}

.table tbody tr {
    border-bottom: 1px solid var(--border-color);
}

/* Cards */
.card {
    background: var(--bg-secondary);
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 10px var(--card-shadow);
    margin-bottom: 20px;
}

.card h3 {
    margin-bottom: 15px;
    color: var(--text-primary);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--stat-card-bg);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px var(--card-shadow);
    text-align: center;
}

.stat-card h4 {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 10px;
}

.stat-card .value {
    font-size: 32px;
    font-weight: bold;
    color: #667eea;
}

.stat-value {
    font-size: 32px;
    font-weight: bold;
    color: #667eea;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 8px;
}

/* Utilities */
.text-center {
    text-align: center;
}

.text-muted {
    color: #999;
}

.mt-3 {
    margin-top: 1rem;
}

.mb-3 {
    margin-bottom: 1rem;
}

.flex {
    display: flex;
}

.justify-between {
    justify-content: space-between;
}

.gap-2 {
    gap: 0.5rem;
}

/* Player */
#player-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

#media-player {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* ===== Layout do formulário de campanha ===== */

/* Título / header */
.content-header {
    margin-bottom: 1.5rem;
}

.content-header h1 {
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Centraliza e limita a largura dos formulários dentro do card */
.main-content .card .card-body > form {
    max-width: 720px;
    margin: 0 auto;
}

/* Grupos de campos */
.form-group {
    margin-bottom: 1.4rem;
}

.form-group:last-of-type {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Inputs / selects */
.form-group .form-control {
    width: 100%;
    background: var(--input-bg);
    border-radius: 8px;
    border: 1px solid var(--input-border);
    color: var(--text-primary);
    padding: 0.65rem 0.75rem;
    font-size: 0.9rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group .form-control:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 1px rgba(102, 126, 234, 0.15);
}

/* Textos auxiliares abaixo dos campos */
.form-group small {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ===== Categorias alvo (checkboxes) ===== */

.checkbox-group {
    margin-top: 0.5rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.6rem;
    border-radius: 6px;
    border: 1px solid var(--input-border);
    background: var(--input-bg);
    font-size: 0.88rem;
    color: var(--text-primary);
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

/* ===== Área de botões ===== */

.form-actions {
    margin-top: 1.8rem;
    padding-top: 1.2rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: flex-end;
}

.form-actions .btn {
    min-width: 130px;
}

/* ===== Responsivo ===== */

@media (max-width: 768px) {
    .main-content .card .card-body > form {
        max-width: 100%;
    }

    .form-actions {
        justify-content: stretch;
    }

    .form-actions .btn {
        flex: 1 1 100%;
        text-align: center;
    }
}

/* ===== Layout geral ===== */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    padding: 2rem 2.5rem;
    background: var(--bg-primary);
}

/* ===== Tipografia utilitária ===== */
.text-sm {
    font-size: 0.8rem;
    color: #9ca3af;
}

/* ===== Sidebar Advertiser ===== */
.sidebar {
    width: 260px;
    background: var(--bg-sidebar); /* azul bem escuro */
    color: #e5e7eb;
    padding: 1.5rem 1.25rem;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 10px rgba(15, 23, 42, 0.35);
}

/* Header (logo + tenant) */
.sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 2.25rem;
}

.app-avatar {
    width: 40px;
    height: 40px;
    border-radius: 999px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    color: #f9fafb;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.6);
}

.app-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.app-name {
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: #f9fafb;
}

.tenant-row {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.8rem;
    color: #9ca3af;
}

.tenant-name {
    font-weight: 500;
    color: #e5e7eb;
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #22c55e;
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.25);
}

.status-text {
    color: #6ee7b7;
}

/* ===== Navegação ===== */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 1.5rem;
}

.nav-label-title {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #6b7280;
    margin-bottom: 0.4rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.75rem;
    border-radius: 0.7rem;
    color: #e5e7eb;
    text-decoration: none;
    font-size: 0.9rem;
    opacity: 0.85;
    transition: background-color 0.18s ease, color 0.18s ease, transform 0.08s ease;
}

.nav-item:hover {
    background: var(--sidebar-nav-hover);
    transform: translateX(2px);
    opacity: 1;
}

.nav-item.active {
    background: var(--sidebar-nav-active);
    color: #fff;
    border-left: 3px solid #6366f1;
    padding-left: 0.65rem;
    opacity: 1;
}

.nav-item .nav-icon {
    width: 1.4rem;
    display: flex;
    justify-content: center;
    font-size: 1rem;
    opacity: 0.9;
}

.nav-item .nav-text {
    flex: 1;
}

/* ===== Rodapé / Logout ===== */
.sidebar-footer {
    margin-top: auto;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(55, 65, 81, 0.8);
}

.logout-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.75rem;
    border-radius: 0.7rem;
    text-decoration: none;
    font-size: 0.88rem;
    color: #fca5a5;
    transition: background-color 0.18s ease, transform 0.08s ease;
}

.logout-link .nav-icon {
    width: 1.3rem;
    display: flex;
    justify-content: center;
}

.logout-link:hover {
    background: rgba(248, 113, 113, 0.12);
    color: #fecaca;
    transform: translateX(2px);
}

/* ===== Sidebar responsivo ===== */
@media (max-width: 768px) {
    .sidebar {
        width: 220px;
        padding: 1.25rem 1rem;
    }

    .tenant-name {
        max-width: 120px;
    }
}

/* ===== Layout geral (anunciante) ===== */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    padding: 2rem 2.5rem;
    background: var(--bg-primary);
}

/* ===== Cards ===== */
.card {
    background: var(--bg-secondary);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
    margin-bottom: 1.5rem;
}

.card-body {
    padding: 1.5rem 1.75rem;
}

/* Limita largura do formulário principal dentro do card */
.main-content .card .card-body > form {
    max-width: 720px;
    margin: 0 auto;
}

/* ===== Grid de criativos ===== */
.campaign-creatives-card {
    margin-top: 2rem;
}

.creatives-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin: 1rem 0 2rem;
}

.creative-card {
    border: 1px solid var(--input-border);
    border-radius: 10px;
    padding: 0.75rem;
    text-align: center;
    background: var(--bg-secondary);
}

.creative-card img,
.creative-card video {
    width: 100%;
    height: 170px;
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

.creative-name {
    font-size: 0.78rem;
    margin: 0.35rem 0;
    color: var(--text-secondary);
    word-break: break-all;
}

.creative-duration {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

/* Form de edição de duração dentro do card */
.creative-duration-form {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
}

.creative-duration-label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.creative-duration-select {
    max-width: 80px;
}

/* Versão pequena do form-control para usar nos cards */
.form-control-sm {
    padding: 0.35rem 0.5rem;
    font-size: 0.78rem;
    border-radius: 6px;
}

/* Form de upload alinhado ao form principal */
.creative-upload-form {
    max-width: 720px;
    margin: 0 auto;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* ===== Botão de Toggle de Tema ===== */
.theme-toggle-container {
    margin-top: 1rem;
    padding: 0.75rem;
    border-top: 1px solid rgba(55, 65, 81, 0.6);
}

.theme-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.55rem 0.75rem;
    border-radius: 0.7rem;
    background: rgba(55, 65, 81, 0.4);
    border: none;
    color: #e5e7eb;
    font-size: 0.88rem;
    cursor: pointer;
    transition: background-color 0.18s ease, transform 0.08s ease;
}

.theme-toggle-btn:hover {
    background: rgba(55, 65, 81, 0.6);
    transform: translateX(2px);
}

.theme-toggle-label {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.theme-icon {
    width: 1.3rem;
    display: flex;
    justify-content: center;
    font-size: 1rem;
}

.theme-switch {
    position: relative;
    width: 42px;
    height: 22px;
    background: rgba(75, 85, 99, 0.6);
    border-radius: 999px;
    transition: background-color 0.3s ease;
}

.theme-switch::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    top: 2px;
    left: 2px;
    transition: transform 0.3s ease;
}

[data-theme="dark"] .theme-switch {
    background: rgba(99, 102, 241, 0.6);
}

[data-theme="dark"] .theme-switch::before {
    transform: translateX(20px);
}

.card-body {
    padding: 1.5rem 1.75rem;
}

.card-body h3 {
    color: var(--text-primary);
}
