:root {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-surface: #f1f5f9;
    --bg-card: #f8fafc;
    --sidebar-bg: #1e293b;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --accent: #3b82f6;
    --accent-dark: #2563eb;
    --border: #e2e8f0;
    --card-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

body.dark-mode {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-surface: #334155;
    --bg-card: #0f172a;
    --sidebar-bg: #020617;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border: #334155;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    overflow-x: hidden;
    transition: background-color 0.3s ease;
}

.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    color: white;
    padding: 24px;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
}

.sidebar.collapsed {
    transform: translateX(-100%);
    opacity: 1;
}

.btn-sidebar-tab {
    position: absolute;
    right: -24px;
    top: 30px;
    width: 24px;
    height: 48px;
    background: var(--sidebar-bg);
    border: none;
    border-radius: 0 24px 24px 0;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    transition: all 0.3s;
    box-shadow: 4px 0 8px rgba(0,0,0,0.1);
}

.btn-sidebar-tab:hover {
    color: white;
    width: 30px;
    right: -30px;
}

.sidebar.collapsed .btn-sidebar-tab {
    background: var(--accent);
    color: white;
    right: -32px;
    width: 32px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 18px;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    margin-bottom: 40px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.brand-logo {
    font-size: 2.2rem;
    filter: drop-shadow(0 0 10px rgba(59, 130, 246, 0.5)) drop-shadow(0 0 15px rgba(167, 119, 227, 0.3));
    animation: owlPulse 4s infinite ease-in-out;
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes owlPulse {
    0%, 100% { transform: scale(1); filter: drop-shadow(0 0 10px rgba(59, 130, 246, 0.5)); }
    50% { transform: scale(1.1); filter: drop-shadow(0 0 20px rgba(167, 119, 227, 0.6)); }
}

.brand-text {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.brand-main {
    font-weight: 800;
    font-size: 1.2rem;
    letter-spacing: -0.5px;
    color: #ffffff;
    line-height: 1;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.brand-sub {
    font-weight: 500;
    font-size: 0.7rem;
    letter-spacing: 5px;
    color: #a777e3;
    margin-top: 4px;
    text-transform: uppercase;
}

.sidebar.collapsed .sidebar-brand {
    padding: 10px;
    justify-content: center;
}

.sidebar.collapsed .brand-text {
    display: none;
}

.nav-menu {
    flex: 1;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: #94a3b8;
    text-decoration: none;
    border-radius: 8px;
    margin-bottom: 8px;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-link:hover,
.nav-link.active {
    background-color: #334155;
    color: white;
}

.nav-link.active {
    background-color: var(--accent);
}

/* Main Content */
.main-content {
    margin-left: 260px;
    flex: 1;
    padding: 32px;
    min-width: 0; /* Crucial para flexbox não esticar */
    max-width: calc(100vw - 260px);
    overflow-x: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.main-content.expanded {
    margin-left: 0;
    max-width: 100vw;
}

.top-bar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 40px;
}

.search-container input {
    width: 400px;
    padding: 12px 20px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.search-container input:focus {
    border-color: var(--accent);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 16px;
}

.avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
}

/* Stats */
.dashboard-header h2 {
    margin-bottom: 0;
    font-weight: 700;
    letter-spacing: -1px;
}

.header-with-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.global-filters {
    display: flex;
    align-items: center;
    gap: 12px;
}

.global-filters label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.badge-bimestre {
    padding: 8px 16px;
    background: rgba(139, 92, 246, 0.08);
    color: #8b5cf6;
    border: 1px solid rgba(139, 92, 246, 0.15);
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 700;
    margin-right: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    animation: fadeInBim 0.5s ease;
}

@keyframes fadeInBim {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

.badge-bimestre::before {
    content: '📅';
    font-size: 0.9rem;
}

.select-premium {
    padding: 10px 48px 10px 20px !important;
    min-width: 160px;
    border-radius: 50px; /* Estilo Pílula como os botões */
    border: 1px solid var(--border);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.9rem;
    outline: none;
    cursor: pointer;
    transition: all 0.3s ease;
    appearance: none !important; 
    -webkit-appearance: none !important; /* Forçar Chrome/Safari */
    -moz-appearance: none !important;    /* Forçar Firefox */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%238b5cf6'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 16px center !important;
    background-size: 16px !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.select-premium:hover {
    border-color: #8b5cf6;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.1);
}

.select-premium:focus {
    border-color: #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

/* Ajustes específicos para Input de Data Premium */
input[type="date"].select-premium {
    background-image: none !important; /* Remove a seta de select */
    padding: 10px 16px 10px 20px !important;
    cursor: text;
    text-align: left;
    min-width: 200px;
}

/* Estilização do ícone nativo do calendário */
input[type="date"].select-premium::-webkit-calendar-picker-indicator {
    cursor: pointer;
    padding: 5px;
    border-radius: 6px;
    transition: all 0.2s;
    margin-left: 10px;
}

input[type="date"].select-premium::-webkit-calendar-picker-indicator:hover {
    background-color: rgba(139, 92, 246, 0.15);
    transform: scale(1.1);
}

/* Inverter ícone no modo escuro para visibilidade */
body.dark-mode input[type="date"].select-premium::-webkit-calendar-picker-indicator {
    filter: invert(1) brightness(1.5);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.stat-card, .card-premium {
    min-width: 0;
    background-color: var(--bg-secondary);
    padding: 24px;
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.card-premium {
    min-width: 0;
    gap: 12px;
}

.card-premium h4 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-premium p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 32px; /* Altura fixa para alinhar botões */
}

.card-premium .btn-primary, .card-premium .btn-premium {
    margin-top: auto;
}

.stat-label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 8px;
}

.stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 8px;
}

.stat-delta {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 20px;
}

.stat-delta.positive {
    background-color: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.stat-delta.negative {
    background-color: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.btn-sync {
    margin-top: 12px;
    width: 100%;
    padding: 12px 24px;
    border-radius: 50px;
    border: none;
    background: linear-gradient(135deg, #8b5cf6 0%, #d946ef 100%);
    color: white;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.btn-sync:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(139, 92, 246, 0.5);
    filter: brightness(1.1);
}

/* Table & Section Headers */
.table-section {
    background-color: var(--bg-secondary);
    border-radius: 20px;
    border: 1px solid var(--border);
    padding: 0; /* Removido padding global para permitir que o header encoste no topo */
    box-shadow: var(--card-shadow);
    margin-bottom: 32px;
    overflow: hidden; /* Garante que o header respeite o border-radius do card */
}

/* Conteúdo interno que não é o header deve manter o padding */
.table-section > div:not(.card-header-premium),
.table-section > section:not(.card-header-premium),
.table-section > table {
    padding: 32px;
}

.table-section > .table-responsive {
    padding: 0 32px 32px 32px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    gap: 24px;
}

.card-header-premium {
    background: rgba(139, 92, 246, 0.05);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    padding: 24px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0;
    width: 100%;
}

.header-text h3 {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.header-text .hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0;
}

.filters, .actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.filters label, .filter-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 16px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
}

tbody tr,
tbody tr td {
    background-color: transparent;
    transition: background-color 0.2s ease;
}

tbody tr:hover {
    background-color: rgba(59, 130, 246, 0.1) !important;
}

.badge-date {
    display: inline-block;
    padding: 4px 8px;
    background-color: rgba(30, 41, 59, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    margin: 2px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.badge-date-just {
    display: inline-block;
    padding: 4px 8px;
    background-color: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 6px;
    margin: 2px;
    font-size: 0.75rem;
    color: var(--accent);
    font-weight: 600;
}

body.dark-mode .badge-date {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

.btn-ghost {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
}

/* Charts Area */
.charts-section {
    margin-bottom: 24px;
}

.chart-card {
    background-color: var(--bg-secondary);
    padding: 24px;
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: var(--card-shadow);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.chart-card h3 {
    margin-bottom: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.chart-controls {
    display: flex;
    gap: 8px;
}

.btn-icon {
    background-color: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:hover {
    border-color: var(--accent);
    color: var(--accent);
}


.chart-container {
    height: 350px;
    width: 100%;
    position: relative;
    display: flex;
    justify-content: center;
}

/* View Management */
.hidden {
    display: none !important;
}

.view-active {
    display: flex !important;
    flex-direction: column;
}

.table-section, .dashboard-content {
    width: 100%;
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.table-section {
    background-color: var(--bg-secondary);
    max-width: 100%;
    overflow: hidden; /* Garante que nada saia da seção */
}

.card-header-premium {
    width: 100%;
    flex-shrink: 0; /* Não permite que o header diminua ou mude de tamanho */
}

/* Diary Table Specifics */
.compact-table {
    font-size: 0.85rem;
    border-collapse: separate;
    border-spacing: 0;
}

.compact-table th,
.compact-table td {
    border: 1px solid var(--border);
    text-align: center;
    padding: 8px 4px;
}

.compact-table th:first-child,
.compact-table td:first-child {
    text-align: left;
    padding-left: 12px;
    position: sticky;
    left: 0;
    background-color: var(--bg-secondary);
    min-width: 250px;
    z-index: 2;
}

.col-date {
    width: 40px;
    font-weight: 700;
    background-color: rgba(59, 130, 246, 0.05);
}

.cell-fail {
    color: #ef4444 !important;
    font-weight: 800 !important;
    background-color: rgba(239, 68, 68, 0.05);
}

.cell-justified {
    color: var(--accent) !important;
    font-weight: 800 !important;
    background-color: rgba(59, 130, 246, 0.05);
}

.cell-empty {
    color: #e2e8f0;
}

body.dark-mode .cell-empty {
    color: #334155;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.modal-content {
    background-color: var(--bg-secondary);
    padding: 32px;
    border-radius: 20px;
    width: 400px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border);
}

.modal-content h3 {
    margin-bottom: 8px;
    font-size: 1.5rem;
}

.modal-content p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 24px;
}

.input-group {
    margin-bottom: 16px;
}

.input-group label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text-secondary);
}

.input-group input, .input-premium {
    width: 100%;
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: all 0.2s;
}

.glass-input {
    width: 100%;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(139, 92, 246, 0.03);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.glass-input:focus {
    outline: none;
    background: var(--bg-secondary);
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

body.dark-mode .glass-input {
    background: rgba(255, 255, 255, 0.03);
    border-color: var(--border);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

/* Console & Progress */
.wide-modal {
    width: 600px !important;
}

.console-box {
    background-color: #020617;
    color: #10b981;
    font-family: 'Courier New', Courier, monospace;
    padding: 16px;
    border-radius: 12px;
    height: 300px;
    overflow-y: auto;
    font-size: 0.85rem;
    line-height: 1.5;
    border: 1px solid #1e293b;
}

.console-line {
    margin-bottom: 4px;
    border-left: 2px solid #064e3b;
    padding-left: 8px;
}

.badge-status {
    background-color: var(--accent);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.console-line.error {
    color: #ef4444;
    border-left-color: #7f1d1d;
}






/* --- ESTILOS UNIFICAÇÃO V2 --- */
.auth-modal {
    text-align: center;
    max-width: 450px;
}

.auth-header {
    margin-bottom: 32px;
}

.auth-header .logo-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
}

.full-width {
    width: 100%;
}

.error-msg {
    color: #ef4444;
    font-size: 0.85rem;
    margin-top: 16px;
    font-weight: 600;
}

.premium-table thead th {
    background-color: var(--bg-secondary);
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 1px 0 var(--border); /* Linha sutil para separar o header */
}

.input-phone {
    background: transparent;
    border: 1px solid var(--border);
    padding: 6px 10px;
    border-radius: 6px;
    color: var(--text-primary);
    width: 140px;
}

.btn-save-phone {
    background: linear-gradient(135deg, #8b5cf6 0%, #d946ef 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 50px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.8rem;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.2);
    transition: all 0.2s;
}

.btn-save-phone:hover {
    transform: scale(1.05);
    filter: brightness(1.1);
}

.badge-status-wa {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 700;
    background: #334155;
}

.status-online {
    background: #22c55e;
    color: white;
}

.status-offline {
    background: #ef4444;
    color: white;
}

.disparos-actions {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
}

.btn-premium, .btn-primary {
    background: linear-gradient(135deg, #8b5cf6 0%, #d946ef 100%);
    border: none;
    padding: 12px 24px;
    border-radius: 50px;
    color: white;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
    text-decoration: none;
    width: 100%;
    font-size: 0.9rem;
}

.btn-premium:hover, .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(139, 92, 246, 0.5);
    filter: brightness(1.1);
}

.btn-premium-print {
    background: linear-gradient(135deg, #3b82f6 0%, #10b981 100%);
    border: none;
    padding: 10px 20px;
    border-radius: 50px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.2);
    font-size: 0.85rem;
}

.btn-premium-print:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
    filter: brightness(1.1);
}

.premium-form {
    background: var(--bg-secondary);
    padding: 32px;
    border-radius: 16px;
    border: 1px solid var(--border);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 8px;
}

textarea.premium-textarea {
    width: 100%;
    padding: 16px;
    border-radius: 12px;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    font-family: inherit;
}

.text-error {
    color: #ef4444;
    font-weight: 700;
}

/* --- CONFIGURAÇÕES --- */
.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 32px;
}

.config-card {
    background: var(--bg-primary);
    padding: 32px;
    border-radius: 20px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.config-card h4 {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
}

.input-premium, textarea.input-premium {
    width: 100%;
    padding: 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.input-premium:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    outline: none;
}

.hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0;
}

.row-modified {
    background-color: rgba(139, 92, 246, 0.12) !important;
}

.row-modified td {
    border-bottom: 1px solid #8b5cf6 !important;
}

.row-modified .input-phone {
    border-color: #8b5cf6 !important;
    box-shadow: 0 0 8px rgba(139, 92, 246, 0.3);
    background-color: var(--bg-secondary) !important;
}

.report-a4-preview-content table {
    border-collapse: collapse;
    width: auto !important; /* Permite scroll horizontal na prévia */
    min-width: 100%;
}

.report-a4-preview-content th, .report-a4-preview-content td {
    border: 1px solid #ddd;
    padding: 4px 2px;
    text-align: center;
}

.report-a4-preview-content .student-name {
    text-align: left;
    position: sticky;
    left: 0;
    background: #fff;
    z-index: 10;
    border-right: 2px solid #000;
}

/* Config Tabs System */
.config-tabs-nav {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    background: var(--bg-primary);
    padding: 6px;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.config-tab-link {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
    white-space: nowrap;
}

.config-tab-link:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
}

.config-tab-link.active {
    background: var(--accent);
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.config-tab-pane {
    display: none;
}

.config-tab-pane.active {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Report Tabs System */
.report-tab-link {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
    white-space: nowrap;
}

.report-tab-link:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
}

.report-tab-link.active {
    background: var(--accent);
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.report-tab-pane {
    display: none;
}

.report-tab-pane.active {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

/* Frequência Indicators */
.freq-yellow {
    color: #eab308 !important; /* Amarelo */
    font-weight: 700;
}

.freq-red {
    color: #ef4444 !important; /* Vermelho */
    font-weight: 700;
}

/* Badge de Contato Premium */
.contact-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.2);
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s;
    white-space: nowrap;
}

.contact-badge:hover {
    background: rgba(34, 197, 94, 0.2);
    transform: translateY(-1px);
}

.risk-matricula {
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.7;
    margin-top: 4px;
    display: block;
}

/* Ajuste de Espaçamento na Tabela */
.premium-table td {
    padding: 16px 12px !important;
    vertical-align: middle;
}

/* ========================================================
   ESTILOS DE IMPRESSÃO UNIFICADOS (DIÁRIO A4 RETRATO)
   ======================================================== */
@media print {
    @page {
        size: A4 portrait;
        margin: 0;
    }

    html, body {
        background: #fff !important;
        color: #000 !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100%;
    }
    
    /* Esconde elementos de interface */
    .sidebar, .top-nav, .navbar, .btn-premium, .no-print, 
    #sidebar, #header, .header-dashboard, button, .sidebar-trigger {
        display: none !important;
    }
    
    /* Esconde absolutamente tudo exceto o container de impressão oficial */
    body > *:not(#printableJournal) {
        display: none !important;
    }
    
    #printableJournal {
        display: block !important;
        visibility: visible !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #fff !important;
        position: static !important;
    }

    /* Permitir que o conteúdo do diário gerencie seu próprio preenchimento e largura */
    .report-page {
        margin: 0 !important;
        padding: 10mm !important; /* Forçar a margem interna de segurança */
        width: 210mm !important;
        height: 297mm !important;
        page-break-after: always !important;
        background: #fff !important;
        box-sizing: border-box !important;
    }

    table {
        page-break-inside: auto;
        width: 100% !important;
    }

    tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }

    .page-break {
        page-break-after: always !important;
        break-after: page !important;
    }

    .print-header {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        border-bottom: 2px solid #000 !important;
        padding-bottom: 5px !important;
        margin-bottom: 10px !important;
        color: #000 !important;
    }

    .print-header h2 {
        margin: 0 !important;
        font-size: 16pt !important;
    }

    /* Cores de fundo forçadas para impressão */
    tr:nth-child(even) {
        background-color: #f2f2f2 !important;
        -webkit-print-color-adjust: exact;
    }
}

.freq-yellow {
    background-color: #fef3c7 !important;
    color: #92400e !important;
    font-weight: 600;
}

.freq-red {
    background-color: #fee2e2 !important;
    color: #991b1b !important;
    font-weight: 600;
}

body.dark-mode .freq-yellow {
    background-color: rgba(245, 158, 11, 0.2) !important;
    color: #fbbf24 !important;
}

body.dark-mode .freq-red {
    background-color: rgba(239, 68, 68, 0.2) !important;
    color: #fca5a5 !important;
}

.risk-matricula {
    display: block;
    font-size: 0.75rem;
    opacity: 0.6;
    font-weight: normal;
}

.print-only {
    display: none;
}

/* Bloco secundário removido - unificado acima */

.print-only {
    display: none;
}


/* Custom Multiselect Dropdown */
.custom-multiselect {
    position: relative;
    width: 220px;
    user-select: none;
}

.multiselect-selected {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 50px;
    padding: 10px 40px 10px 20px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    position: relative;
}

.multiselect-selected::after {
    content: '▼';
    font-size: 0.6rem;
    color: var(--accent);
    position: absolute;
    right: 18px;
}

.multiselect-selected:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.1);
}

.multiselect-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    margin-top: 8px;
    max-height: 250px;
    overflow-y: auto;
    z-index: 1000;
    padding: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.multiselect-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    font-size: 0.9rem;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
    color: var(--text-primary);
    min-height: 40px; /* Garante altura mínima para facilitar o clique */
    width: 100%;
    box-sizing: border-box;
}

.multiselect-option:hover {
    background-color: rgba(139, 92, 246, 0.1);
}

.multiselect-option input[type="checkbox"] {
    appearance: auto !important; /* Força a aparência padrão se estiver sendo resetada */
    -webkit-appearance: checkbox !important;
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent);
    margin: 0 !important;
    padding: 0 !important;
    flex-shrink: 0;
    display: inline-block;
    vertical-align: middle;
}

.multiselect-option span {
    display: inline-block;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-bottom: 1px; /* Ajuste óptico para alinhar com o checkbox */
}

body.dark-mode .multiselect-options {
    box-shadow: 0 10px 40px rgba(0,0,0,0.4);
}

.grade-input {
    background-color: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 6px;
    width: 65px;
    text-align: center;
    font-weight: 500;
    color: var(--text-primary);
    transition: all 0.2s;
}

.grade-input:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
    background-color: #fff;
}

body.dark-mode .grade-input:focus {
    background-color: rgba(255, 255, 255, 0.1);
}

.grade-input::-webkit-inner-spin-button, 
.grade-input::-webkit-outer-spin-button { 
    -webkit-appearance: none; 
    margin: 0; 
}

.avg-display {
    display: inline-block;
    min-width: 45px;
    padding: 4px 8px;
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
    border-radius: 6px;
    font-weight: 700;
}
/* --- Módulo de Comunicados (Broadcast) --- */
.broadcast-layout {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-top: 2rem;
    align-items: stretch;
}

.message-textarea {
    width: 100%;
    min-height: 300px;
    padding: 1.25rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.6;
    resize: none;
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

.message-textarea:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1), inset 0 2px 4px rgba(0,0,0,0.02);
}

.editor-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    padding: 0 4px;
}

.variable-tip {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.variable-tip code {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
}

.char-counter {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.scrollable-table {
    max-height: 500px;
    overflow-y: auto;
    border-radius: 8px;
    border: 1px solid var(--border);
}

/* Ajustes para Scrollbar Customizada (Opcional, mas Premium) */
.scrollable-table::-webkit-scrollbar {
    width: 6px;
}

.scrollable-table::-webkit-scrollbar-track {
    background: transparent;
}

.scrollable-table::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

.scrollable-table::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.section-header-mini h4 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.selection-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Modal de Confirmação customizado (opcional, usando styles existentes) */
.modal-content.broadcast-confirm {
    max-width: 450px;
    text-align: center;
}

@media (max-width: 1024px) {
    .broadcast-layout {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-top: 2rem;
    align-items: stretch;
}
}


/* --- SISTEMA DE IMPRESS�O PREMIUM --- */
@media print {
    body {
        background: white !important;
        color: black !important;
        padding: 0 !important;
    }

    .sidebar, 
    .card-header-premium, 
    .actions, 
    .btn-save-phone, 
    .btn-premium,
    .btn-premium-print,
    .input-premium,
    .select-premium,
    .app-header,
    nav {
        display: none !important;
    }

    .main-content {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }

    .table-section {
        display: block !important;
        padding: 0 !important;
        margin: 0 !important;
        box-shadow: none !important;
        background: transparent !important;
    }

    .card-premium {
    min-width: 0;
        box-shadow: none !important;
        border: none !important;
        padding: 0 !important;
    }

    .premium-table {
        width: 100% !important;
        border-collapse: collapse !important;
        font-size: 10pt !important;
    }

    .premium-table th, 
    .premium-table td {
        border: 1px solid #ddd !important;
        padding: 8px !important;
        color: black !important;
    }

    .print-only {
        display: block !important;
        visibility: visible !important;
    }

    /* Ocultar elementos interativos mas manter os dados */
    .input-phone {
        border: none !important;
        background: transparent !important;
        padding: 0 !important;
        font-weight: bold !important;
    }

    @page {
        margin: 1.5cm;
    }
}

.print-only {
    display: none;
}



/* --- SISTEMA DE POPUP CENTRALIZADO --- */
.popup-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
    max-width: 90vw;
}

.popup-message {
    min-width: 300px;
    padding: 16px 24px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
    backdrop-filter: blur(12px);
    animation: slideDownPopup 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: auto;
    color: white;
}

.popup-message.success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.popup-message.warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    border: 1px solid rgba(245, 158, 11, 0.2);
    color: #fff;
}

.popup-message.error {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.popup-close {
    background: transparent;
    border: none;
    color: currentColor;
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.7;
    margin-left: 15px;
}

@keyframes slideDownPopup {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes fadeOutPopup {
    from { transform: scale(1); opacity: 1; }
    to { transform: scale(0.9); opacity: 0; }
}



/* Utilidade para truncar texto em tabelas */
.truncate-text {
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

@media (max-width: 1400px) {
    .broadcast-layout {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 900px) {
    .broadcast-layout {
        grid-template-columns: 1fr;
    }
}



/* --- Boto Back to Top (Glassmorphism Premium) --- */
.btn-back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(217, 70, 239, 0.2));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 999;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    opacity: 0;
    pointer-events: none;
    transform: translateX(50px) scale(0.8);
}

.btn-back-to-top.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0) scale(1);
}

.btn-back-to-top:hover {
    background: linear-gradient(135deg, #8b5cf6 0%, #d946ef 100%);
    box-shadow: 0 15px 45px rgba(139, 92, 246, 0.5);
    transform: translateY(-5px) scale(1.1);
}

.btn-back-to-top:active {
    transform: scale(0.95);
}

@media (max-width: 768px) {
    .btn-back-to-top {
        bottom: 20px;
        right: 20px;
        width: 48px;
        height: 48px;
        z-index: 100; /* Evita cobrir elementos críticos de modais mas fica acima do conteúdo */
    }
}


/* --- Wizard de Importação --- */
.wizard-steps {
    display: flex;
    justify-content: space-between;
    margin-bottom: 30px;
    padding: 0 50px;
    position: relative;
}

.wizard-steps::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 100px;
    right: 100px;
    height: 2px;
    background: var(--border);
    z-index: 0;
}

.step {
    background: var(--bg-primary);
    border: 2px solid var(--border);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 600;
    position: relative;
    z-index: 1;
    transition: all 0.3s;
}

.step.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.4);
}

.wizard-pane {
    padding: 10px 5px;
    animation: fadeIn 0.3s ease-out;
}

.drop-zone {
    border: 2px dashed var(--border);
    border-radius: 16px;
    padding: 60px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: rgba(255, 255, 255, 0.02);
}

.drop-zone:hover, .drop-zone--over {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.05);
}

.drop-zone__input { display: none; }

.drop-zone__prompt {
    font-weight: 500;
    color: var(--text-secondary);
}

.mapping-select {
    width: 100%;
}

/* --- Search Utilities --- */
.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.btn-clear-search {
    position: absolute;
    right: 16px;
    width: 26px;
    height: 26px;
    background: rgba(148, 163, 184, 0.15);
    color: var(--text-secondary);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    transition: all 0.2s ease;
    opacity: 0.8;
    z-index: 5;
    padding: 0;
}

.btn-clear-search:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    opacity: 1;
    transform: scale(1.1);
}

.btn-clear-search.hidden {
    display: none !important;
}

#printableJournal { display: none; }

