/* =====================================================
   GESTIÓN DE TESORERÍA POLÍTICA — ESTILOS PRINCIPALES
   Mobile-first responsive design
   ===================================================== */

:root {
    --primary:        #1a3a6b;
    --primary-dark:   #0f2547;
    --primary-light:  #2d5fa8;
    --secondary:      #c8a84b;
    --secondary-dark: #a8883b;
    --success:        #28a745;
    --danger:         #dc3545;
    --warning:        #ffc107;
    --info:           #17a2b8;
    --light:          #f8f9fa;
    --dark:           #343a40;
    --sidebar-width:  260px;
    --topbar-height:  58px;
    --border-radius:  10px;
    --shadow:         0 4px 20px rgba(0,0,0,0.12);
    --shadow-sm:      0 2px 8px rgba(0,0,0,0.08);
}

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

html { font-size: 15px; -webkit-text-size-adjust: 100%; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 1rem;
    color: #333;
    background: #f0f2f5;
    min-height: 100vh;
}

img { max-width: 100%; height: auto; }

/* ===================== LOGIN / PORTAL PAGE ===================== */
.login-page {
    min-height: 100vh;
    background:
        linear-gradient(135deg, rgba(26,58,107,0.93) 0%, rgba(15,37,71,0.89) 55%, rgba(200,168,75,0.72) 100%),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100%25' height='100%25'%3E%3Crect fill='%231a3a6b' width='100%25' height='100%25'/%3E%3C/svg%3E") center/cover no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    position: relative;
    overflow-x: hidden;
}

.login-page::after {
    content: '"Las políticas basadas en ética y moral hacen grande a un país"';
    position: fixed;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,0.30);
    font-style: italic;
    font-size: 11px;
    text-align: center;
    width: 90%;
    pointer-events: none;
    font-family: Georgia, serif;
    letter-spacing: 0.4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.login-overlay {
    width: 100%;
    max-width: 440px;
    z-index: 1;
}

.login-box {
    background: rgba(255,255,255,0.97);
    border-radius: 16px;
    padding: 32px 28px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
    border-top: 5px solid var(--secondary);
}

.login-box-wide { max-width: 520px; }

.login-logo {
    text-align: center;
    margin-bottom: 24px;
    color: var(--primary);
}
.login-logo i { color: var(--secondary); margin-bottom: 10px; display: block; }
.login-logo h1 { font-size: 20px; font-weight: 700; margin-bottom: 4px; line-height: 1.3; }
.login-subtitle { color: #666; font-size: 13px; }

.login-links {
    text-align: center;
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid #eee;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}
.login-links a {
    color: var(--primary-light);
    text-decoration: none;
    font-size: 13px;
    transition: color 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.login-links a:hover { color: var(--secondary); }

/* Portal aportante: acceso admin discreto al pie */
.admin-access-link {
    text-align: center;
    margin-top: 14px;
}
.admin-access-link a {
    color: rgba(255,255,255,0.45);
    font-size: 11px;
    text-decoration: none;
    transition: color 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.admin-access-link a:hover { color: rgba(255,255,255,0.75); }

/* ===================== APP LAYOUT ===================== */
.app-body { background: #f0f2f5; }

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

/* ===================== SIDEBAR ===================== */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 100%);
    color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1000;
    transition: transform 0.28s ease;
    display: flex;
    flex-direction: column;
    -webkit-overflow-scrolling: touch;
}

/* En móvil el sidebar se oculta por defecto */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: none;
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,0.35);
    }
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 999;
}
.sidebar-overlay.active { display: block; }

.sidebar-header {
    padding: 18px 16px;
    background: rgba(0,0,0,0.22);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 17px;
    font-weight: 700;
    border-bottom: 2px solid var(--secondary);
    flex-shrink: 0;
}
.sidebar-header i { color: var(--secondary); font-size: 20px; }

.sidebar-user {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255,255,255,0.07);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
}
.sidebar-user i { font-size: 26px; color: var(--secondary); flex-shrink: 0; }
.sidebar-user strong { display: block; font-size: 13px; word-break: break-word; }
.sidebar-user small { color: rgba(255,255,255,0.6); font-size: 11px; }

.sidebar-menu {
    list-style: none;
    padding: 8px 0;
    flex: 1;
}
.sidebar-menu li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    transition: all 0.2s;
    font-size: 14px;
    -webkit-tap-highlight-color: transparent;
}
.sidebar-menu li a:hover,
.sidebar-menu li a.active {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border-left: 3px solid var(--secondary);
    padding-left: 13px;
}
.sidebar-menu li a i { width: 18px; text-align: center; flex-shrink: 0; }

.menu-section {
    padding: 10px 16px 3px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.38);
    font-weight: 600;
}

/* ===================== MAIN CONTENT ===================== */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    min-width: 0;
    transition: margin-left 0.28s ease;
}

@media (max-width: 900px) {
    .main-content { margin-left: 0; }
}

/* ===================== TOPBAR ===================== */
.topbar {
    background: #fff;
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 2px solid var(--secondary);
}
.topbar h2 {
    font-size: 15px;
    color: var(--primary);
    font-weight: 600;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.badge-date {
    background: var(--light);
    color: var(--primary);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    border: 1px solid #ddd;
    white-space: nowrap;
}

.btn-toggle-sidebar {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--primary);
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 6px;
    transition: background 0.2s;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    line-height: 1;
}
.btn-toggle-sidebar:hover { background: var(--light); }

/* ===================== CARDS GRID ===================== */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    padding: 20px 20px 0;
}

.card {
    background: #fff;
    border-radius: var(--border-radius);
    padding: 18px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
    border-left: 4px solid transparent;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
.card-info { min-width: 0; }
.card-info h3 { font-size: 11px; color: #888; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.card-amount { font-size: 17px; font-weight: 700; word-break: break-all; }
.card-info p { font-size: 14px; }
.card-info small { font-size: 11px; color: #888; }

.card-primary   { border-left-color: var(--primary); }
.card-primary   .card-icon { background: rgba(26,58,107,0.1); color: var(--primary); }
.card-primary   .card-amount { color: var(--primary); }

.card-success   { border-left-color: var(--success); }
.card-success   .card-icon { background: rgba(40,167,69,0.1); color: var(--success); }
.card-success   .card-amount { color: var(--success); }

.card-danger    { border-left-color: var(--danger); }
.card-danger    .card-icon { background: rgba(220,53,69,0.1); color: var(--danger); }
.card-danger    .card-amount { color: var(--danger); }

.card-warning   { border-left-color: var(--warning); }
.card-warning   .card-icon { background: rgba(255,193,7,0.15); color: #856404; }
.card-warning   .card-amount { color: #856404; }

.card-info-light { border-left-color: var(--info); }
.card-info-light .card-icon { background: rgba(23,162,184,0.1); color: var(--info); }
.card-info-light .card-amount { color: var(--info); }

/* ===================== CHART ===================== */
.chart-container {
    background: #fff;
    border-radius: var(--border-radius);
    padding: 20px;
    margin: 16px 20px 0;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.chart-container h3 { font-size: 14px; color: var(--primary); margin-bottom: 14px; }

/* ===================== TABLES ===================== */
.table-container {
    background: #fff;
    border-radius: var(--border-radius);
    padding: 20px;
    margin: 16px 20px;
    box-shadow: var(--shadow-sm);
}
.table-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.table-header h3 { flex: 1; font-size: 14px; color: var(--primary); margin: 0; min-width: 120px; }

.total-badge {
    background: #e8f5e9;
    color: var(--success);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    border: 1px solid #c8e6c9;
    white-space: nowrap;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -4px;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    min-width: 400px;
}
.table th {
    background: var(--primary);
    color: #fff;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    white-space: nowrap;
}
.table td {
    padding: 9px 12px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}
.table tbody tr:hover { background: #f8f9ff; }
.table tbody tr:last-child td { border-bottom: none; }
.table-footer td {
    background: #f0f4ff;
    font-weight: 600;
    border-top: 2px solid var(--primary);
}
.monto { font-weight: 600; font-family: 'Courier New', monospace; white-space: nowrap; }

/* ===================== FORMS ===================== */
.card-form {
    background: #fff;
    border-radius: var(--border-radius);
    padding: 20px;
    margin: 16px 20px 0;
    box-shadow: var(--shadow-sm);
    border-top: 3px solid var(--secondary);
}
.card-form h3 { font-size: 14px; color: var(--primary); margin-bottom: 16px; }

.form-group { margin-bottom: 14px; }
.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 5px;
    color: #444;
    font-size: 13px;
}
.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid #ddd;
    border-radius: 8px;
    font-size: 15px;   /* 15px evita zoom en iOS */
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fff;
    color: #333;
    -webkit-appearance: none;
    appearance: none;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(45,95,168,0.12);
}
select.form-control { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23666' d='M6 8L0 0h12z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
}
.form-text { font-size: 11px; color: #888; margin-top: 4px; display: block; }
.required { color: var(--danger); }

/* ===================== BUTTONS ===================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    line-height: 1.2;
}
.btn:hover   { opacity: 0.88; transform: translateY(-1px); }
.btn:active  { transform: translateY(0); opacity: 1; }

.btn-primary    { background: var(--primary);        color: #fff; }
.btn-secondary  { background: #6c757d;               color: #fff; }
.btn-success    { background: var(--success);         color: #fff; }
.btn-danger     { background: var(--danger);          color: #fff; }
.btn-warning    { background: var(--warning);         color: #333; }
.btn-info       { background: var(--info);            color: #fff; }
.btn-outline-light { background: transparent; color: #fff; border: 1.5px solid rgba(255,255,255,0.6); }
.btn-outline-light:hover { background: rgba(255,255,255,0.15); }
.btn-whatsapp   { background: #25D366; color: #fff; }
.btn-whatsapp:hover { background: #1ebe5d; }

.btn-block { width: 100%; padding: 13px; font-size: 15px; }
.btn-sm    { padding: 6px 11px; font-size: 12px; border-radius: 6px; }

/* ===================== BADGES ===================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 9px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}
.badge-success   { background: #d4edda; color: #155724; }
.badge-danger    { background: #f8d7da; color: #721c24; }
.badge-warning   { background: #fff3cd; color: #856404; }
.badge-primary   { background: #cce5ff; color: #004085; }
.badge-info      { background: #d1ecf1; color: #0c5460; }
.badge-secondary { background: #e2e3e5; color: #383d41; }

/* ===================== ALERTS ===================== */
.alert {
    padding: 11px 16px;
    border-radius: 8px;
    margin: 14px 20px;
    display: flex;
    align-items: flex-start;
    gap: 9px;
    font-size: 13.5px;
    line-height: 1.4;
}
.alert-success { background: #d4edda; color: #155724; border-left: 4px solid var(--success); }
.alert-danger  { background: #f8d7da; color: #721c24; border-left: 4px solid var(--danger); }
.alert-info    { background: #d1ecf1; color: #0c5460; border-left: 4px solid var(--info); }
.alert-warning { background: #fff3cd; color: #856404; border-left: 4px solid var(--warning); }

/* ===================== FILTER BAR ===================== */
.filter-bar {
    background: #fff;
    padding: 14px 20px;
    margin: 16px 20px 0;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
}
.filter-form {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: flex-end;
}
.filter-form .form-group { margin-bottom: 0; flex: 1; min-width: 120px; }
.filter-form .form-control { min-width: 0; }
.filter-form .btn { flex-shrink: 0; }

/* ===================== MODAL ===================== */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.52);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    -webkit-overflow-scrolling: touch;
}
.modal-content {
    background: #fff;
    border-radius: 14px;
    padding: 24px 22px;
    width: 100%;
    max-width: 460px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    border-top: 4px solid var(--secondary);
}
.modal-content h3 { font-size: 15px; color: var(--primary); margin-bottom: 18px; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; justify-content: flex-end; flex-wrap: wrap; }

/* ===================== CAPTCHA ===================== */
.captcha-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
.captcha-img {
    border-radius: 8px;
    border: 2px solid #ddd;
    height: 50px;
    cursor: pointer;
    flex-shrink: 0;
}
.btn-refresh-captcha {
    background: var(--primary-light);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}
.btn-refresh-captcha:hover { background: var(--primary); }

/* ===================== UPLOAD AREA ===================== */
.upload-area {
    border: 2px dashed var(--primary-light);
    border-radius: 10px;
    padding: 22px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--primary-light);
    background: #f8f9ff;
    -webkit-tap-highlight-color: transparent;
}
.upload-area:hover, .upload-area:active { background: #eef2ff; border-color: var(--primary); }
.upload-area i  { margin-bottom: 8px; display: block; }
.upload-area p  { font-size: 14px; margin-bottom: 4px; }
.upload-area small { color: #888; }

/* ===================== APORTANTE LAYOUT ===================== */
.aportante-body { background: #f0f2f5; }
.aportante-wrapper { min-height: 100vh; display: flex; flex-direction: column; }

.aportante-nav {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: #fff;
    padding: 0 20px;
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
    border-bottom: 3px solid var(--secondary);
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;
}
.aportante-nav-brand {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 15px;
    font-weight: 700;
    min-width: 0;
}
.aportante-nav-brand i { color: var(--secondary); font-size: 19px; flex-shrink: 0; }
.aportante-nav-brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.aportante-nav-user {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    flex-shrink: 0;
}
.aportante-nav-user > span { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.aportante-content {
    flex: 1;
    max-width: 860px;
    width: 100%;
    margin: 0 auto;
    padding: 16px;
}
.aportante-content .card-form,
.aportante-content .table-container,
.aportante-content .alert {
    margin-left: 0;
    margin-right: 0;
}
.aportante-content .cards-grid { padding: 0; margin-bottom: 16px; }

/* ===================== UTILITIES ===================== */
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger)  !important; }
.text-muted   { color: #888 !important; }
.text-center  { text-align: center; }
.coords-text  { font-size: 12px; color: #555; margin-top: 6px; font-family: monospace; }

/* ===================== FOOTER ===================== */
.footer {
    text-align: center;
    padding: 14px;
    color: #888;
    font-size: 12px;
    border-top: 1px solid #eee;
    margin-top: 16px;
}

/* ===================== SCROLLBAR ===================== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: var(--primary-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* =====================================================================
   RESPONSIVE BREAKPOINTS
   ===================================================================== */

/* --- Tablet landscape / small desktop (901px – 1100px) --- */
@media (min-width: 901px) {
    .sidebar { transform: translateX(0) !important; }
    .btn-toggle-sidebar { display: none; }
}

/* --- Tablet portrait (601px – 900px) --- */
@media (max-width: 900px) {
    .cards-grid {
        grid-template-columns: repeat(2, 1fr);
        padding: 14px 14px 0;
        gap: 12px;
    }
    .table-container,
    .card-form,
    .chart-container,
    .filter-bar,
    .alert {
        margin-left: 14px;
        margin-right: 14px;
        padding: 16px;
    }
    .topbar { padding: 0 14px; }
    .topbar h2 { font-size: 14px; }
    .badge-date { display: none; }
}

/* --- Mobile (≤ 600px) --- */
@media (max-width: 600px) {
    html { font-size: 14px; }

    .login-box { padding: 24px 18px; }
    .login-logo h1 { font-size: 18px; }

    .cards-grid {
        grid-template-columns: repeat(2, 1fr);
        padding: 12px 12px 0;
        gap: 10px;
    }
    .card { padding: 14px 12px; gap: 10px; }
    .card-icon { width: 40px; height: 40px; font-size: 17px; border-radius: 9px; }
    .card-amount { font-size: 15px; }

    .table-container,
    .card-form,
    .chart-container,
    .filter-bar,
    .alert {
        margin-left: 10px;
        margin-right: 10px;
        padding: 14px 12px;
    }

    .form-row { grid-template-columns: 1fr; gap: 12px; }

    .filter-form { flex-direction: column; }
    .filter-form .form-group { width: 100%; }
    .filter-form .btn { width: 100%; }

    .table { min-width: 340px; font-size: 12px; }
    .table th, .table td { padding: 8px 10px; }

    .topbar { padding: 0 12px; height: 52px; }
    .topbar h2 { font-size: 13px; }

    .aportante-nav { padding: 0 14px; height: 54px; }
    .aportante-nav-brand span { max-width: 130px; }
    .aportante-nav-user > span { display: none; }

    .modal-content { padding: 20px 16px; }
    .modal-actions { justify-content: stretch; }
    .modal-actions .btn { flex: 1; }

    .btn-block { font-size: 15px; padding: 13px; }

    .table-header { flex-direction: column; align-items: flex-start; }
}

/* --- Very small (≤ 360px) --- */
@media (max-width: 360px) {
    .cards-grid { grid-template-columns: 1fr; }
    .card-amount { font-size: 14px; }
}
