/* ============================================================
   CRMSANIA — Design System
   Premium Dark Sidebar + Light Content
   ============================================================ */

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

/* ---- CSS Variables ---- */
:root {
    --sidebar-bg: #1a1f2e;
    --sidebar-hover: #2d3548;
    --sidebar-active: #364156;
    --sidebar-width: 260px;
    --primary: #4e7cff;
    --primary-dark: #3a63d8;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --info: #17a2b8;
    --bg-main: #f0f2f5;
    --bg-card: #ffffff;
    --text-dark: #1a1f2e;
    --text-muted: #6c757d;
    --text-light: #adb5bd;
    --border-color: #e0e4e8;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-main);
    color: var(--text-dark);
    font-size: 14px;
    line-height: 1.6;
    overflow-x: hidden;
}

a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-dark); }

/* ---- LOGIN PAGE ---- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: rgba(255,255,255,0.05);
    top: -200px;
    right: -200px;
}

.login-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    text-align: center;
    animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-logo {
    width: 64px;
    height: 64px;
    background: var(--sidebar-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 24px;
    color: white;
    font-weight: 800;
}

.login-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--sidebar-bg);
    margin-bottom: 4px;
    letter-spacing: 2px;
}

.login-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 32px;
}

.login-card .form-group { margin-bottom: 20px; text-align: left; }

.login-card .form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.login-card .form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
    background: #fafbfc;
}

.login-card .form-group input:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(78,124,255,0.15);
}

.btn-login {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 8px;
}

.btn-login:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(78,124,255,0.4); }

.login-footer { margin-top: 24px; font-size: 13px; color: var(--text-muted); }
.login-footer a { font-weight: 600; }

/* ---- LAYOUT ---- */
.app-wrapper { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #c8cfd8;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    overflow-y: auto;
}

.sidebar-header {
    padding: 24px 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand {
    font-size: 20px;
    font-weight: 800;
    color: white;
    letter-spacing: 2px;
}

.sidebar-role {
    font-size: 11px;
    color: var(--text-light);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sidebar-nav { flex: 1; padding: 12px 0; }

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 24px;
    color: #c8cfd8;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    border-left: 3px solid transparent;
    text-decoration: none;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: white;
    border-left-color: rgba(78,124,255,0.5);
}

.nav-item.active {
    background: var(--sidebar-active);
    color: white;
    border-left-color: var(--primary);
}

.nav-item i {
    width: 20px;
    margin-right: 12px;
    font-size: 16px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 14px;
}

.sidebar-user-info { flex: 1; }
.sidebar-user-name { font-size: 13px; font-weight: 600; color: white; }
.sidebar-user-role { font-size: 11px; color: var(--text-light); }

.btn-logout {
    color: var(--text-light);
    font-size: 18px;
    cursor: pointer;
    transition: var(--transition);
    background: none;
    border: none;
    padding: 4px;
}
.btn-logout:hover { color: var(--danger); }

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 0;
    min-height: 100vh;
}

.content-header {
    padding: 24px 32px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.content-title { font-size: 22px; font-weight: 700; color: var(--text-dark); }
.content-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.content-body { padding: 24px 32px; }

/* ---- CARDS KPI ---- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.kpi-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.kpi-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

.kpi-value { font-size: 32px; font-weight: 800; color: var(--text-dark); }
.kpi-label { font-size: 13px; color: var(--text-muted); font-weight: 500; margin-top: 4px; }

.kpi-card.primary .kpi-value { color: var(--primary); }
.kpi-card.success .kpi-value { color: var(--success); }
.kpi-card.warning .kpi-value { color: var(--warning); }
.kpi-card.info .kpi-value { color: var(--info); }

/* ---- TABLES ---- */
.table-container {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    overflow: hidden;
    margin-bottom: 24px;
}

.table-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
}

.table-title { font-size: 16px; font-weight: 700; }
.table-count { font-size: 13px; color: var(--text-muted); }

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    background: var(--sidebar-bg);
    color: white;
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
}

tbody tr:hover { background: #f8f9fb; }
tbody tr:last-child td { border-bottom: none; }

/* ---- BUTTONS ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

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

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); color: white; box-shadow: 0 4px 12px rgba(78,124,255,0.3); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #218838; color: white; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #c82333; color: white; }

.btn-warning { background: var(--warning); color: var(--text-dark); }

.btn-sm { padding: 6px 12px; font-size: 12px; }

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

.action-btns { display: flex; gap: 6px; }

/* ---- FORMS ---- */
.form-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 32px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.form-group { margin-bottom: 20px; }

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
    background: #fafbfc;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(78,124,255,0.1);
}

.form-group textarea { min-height: 100px; resize: vertical; }

.form-group input[readonly] {
    background: #e9ecef;
    cursor: not-allowed;
    color: var(--text-muted);
}

.form-group.full-width { grid-column: 1 / -1; }

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

/* Checkbox flags */
.flags-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.flag-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #f8f9fb;
    border-radius: var(--radius-sm);
    font-size: 13px;
}

.flag-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

/* ---- STATUS BADGES ---- */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-aberta { background: #e3f2fd; color: #1565c0; }
.badge-em_analise { background: #fff3e0; color: #ef6c00; }
.badge-em_andamento { background: #f3e5f5; color: #7b1fa2; }
.badge-concluida { background: #e8f5e9; color: #2e7d32; }
.badge-cancelada { background: #fce4ec; color: #c62828; }
.badge-agendado { background: #e3f2fd; color: #1565c0; }
.badge-realizado { background: #e8f5e9; color: #2e7d32; }

/* ---- CHART CONTAINERS ---- */
.chart-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.chart-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.chart-card h3 {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-dark);
}

.chart-card canvas {
    max-height: 300px;
}

/* ---- NEWS PORTAL ---- */
.news-portal { padding: 24px 32px; }

.news-hero {
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 32px;
    position: relative;
    height: 350px;
    background: linear-gradient(135deg, #1a1f2e, #2d3548);
    display: flex;
    align-items: flex-end;
}

.news-hero-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.6;
}

.news-hero-content {
    position: relative;
    z-index: 2;
    padding: 32px;
    color: white;
    width: 100%;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
}

.news-hero-badge {
    display: inline-block;
    background: var(--primary);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 12px;
}

.news-hero-title { font-size: 28px; font-weight: 800; margin-bottom: 8px; }
.news-hero-excerpt { font-size: 14px; opacity: 0.9; max-width: 600px; }

.news-section { margin-bottom: 40px; }
.news-section-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 3px solid var(--primary);
    display: inline-block;
}

.news-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

.news-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: var(--transition);
    cursor: pointer;
}

.news-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }

.news-card-img {
    height: 180px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 48px;
}

.news-card-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.news-card-body { padding: 20px; }

.news-card-badge {
    display: inline-block;
    background: rgba(78,124,255,0.1);
    color: var(--primary);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.news-card-title { font-size: 16px; font-weight: 700; margin-bottom: 8px; color: var(--text-dark); }
.news-card-excerpt { font-size: 13px; color: var(--text-muted); line-height: 1.5; }
.news-card-date { font-size: 11px; color: var(--text-light); margin-top: 12px; }

/* Search bar */
.news-search {
    display: flex;
    gap: 12px;
    margin-bottom: 32px;
    max-width: 500px;
}

.news-search input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
}

.news-search input:focus { outline: none; border-color: var(--primary); }

/* Avisos */
.avisos-bar {
    background: linear-gradient(135deg, #fff3e0, #fff8e1);
    border: 1px solid #ffe0b2;
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin-bottom: 24px;
}

.avisos-bar h4 { font-size: 14px; font-weight: 700; color: #e65100; margin-bottom: 8px; }
.avisos-bar p { font-size: 13px; color: #bf360c; margin-bottom: 4px; }

/* ---- MAP ---- */
#mapa-eleitoral {
    height: 450px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

/* ---- FLASH MESSAGES ---- */
.flash {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: fadeInUp 0.3s ease-out;
}

.flash-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.flash-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

/* ---- FILTER BAR ---- */
.filter-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-bar select {
    padding: 8px 14px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13px;
    background: white;
}

/* ---- 403 / 404 PAGES ---- */
.error-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.error-code { font-size: 96px; font-weight: 800; color: var(--primary); opacity: 0.3; }
.error-message { font-size: 20px; font-weight: 600; margin-top: 8px; }

/* ---- RESPONSIVE ---- */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 1100;
    background: var(--sidebar-bg);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    font-size: 20px;
    cursor: pointer;
}

@media (max-width: 768px) {
    .sidebar-toggle { display: flex; align-items: center; justify-content: center; }

    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open { transform: translateX(0); }

    .main-content { margin-left: 0; }

    .content-header { padding: 20px 16px; padding-left: 60px; }
    .content-body { padding: 16px; }

    .chart-grid { grid-template-columns: 1fr; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }

    .news-hero { height: 250px; }
    .news-hero-title { font-size: 20px; }
    .news-grid { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .login-card { margin: 16px; padding: 32px 24px; }
}

/* ---- SCROLLBAR ---- */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

/* ---- LOADING ---- */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---- TOOLTIP ---- */
[data-tooltip] {
    position: relative;
}

[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-dark);
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    z-index: 100;
}
