/**
 * Sistema de Auditoría de Condominios
 * Custom CSS - Professional Theme
 */

:root {
    --primary: #1a237e;
    --primary-light: #283593;
    --primary-dark: #0d1654;
    --secondary: #0d47a1;
    --accent: #2962ff;
    --sidebar-width: 260px;
    --sidebar-collapsed: 0px;
    --topbar-height: 60px;
    --bg-body: #f0f2f5;
    --bg-card: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --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 10px 30px rgba(0,0,0,0.12);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============ RESET ============ */
* { box-sizing: border-box; }
body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-primary);
    margin: 0;
    min-height: 100vh;
}

/* ============ LOGIN PAGE ============ */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 50%, var(--accent) 100%);
    padding: 1rem;
}

.login-container {
    width: 100%;
    max-width: 420px;
}

.login-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 2.5rem 2rem;
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.login-logo {
    width: 80px;
    height: 80px;
    object-fit: contain;
}

.login-logo-placeholder {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 2.5rem;
}

.login-footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

/* ============ SIDEBAR ============ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 100%);
    color: #fff;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    overflow: hidden;
}

.sidebar-header {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: #fff;
}

.sidebar-logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
    border-radius: 10px;
}

.sidebar-logo-icon {
    font-size: 1.8rem;
    color: #82b1ff;
}

.sidebar-brand-text {
    font-size: 1.05rem;
    font-weight: 600;
    white-space: nowrap;
}

.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) transparent;
}

.sidebar-menu::-webkit-scrollbar {
    width: 4px;
}
.sidebar-menu::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 4px;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1.25rem;
    color: rgba(255,255,255,0.7);
    font-size: 0.88rem;
    white-space: nowrap;
    transition: var(--transition);
    border-left: 3px solid transparent;
}

.sidebar .nav-link:hover {
    color: #fff;
    background: rgba(255,255,255,0.08);
    border-left-color: var(--accent);
}

.sidebar .nav-link.active {
    color: #fff;
    background: rgba(255,255,255,0.12);
    border-left-color: var(--accent);
    font-weight: 600;
}

.sidebar .nav-link i {
    font-size: 1.15rem;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar .nav-link .badge {
    font-size: 0.65rem;
    padding: 0.2em 0.5em;
}

.sidebar-separator {
    margin-top: 0.75rem;
}

.sidebar-heading {
    display: block;
    padding: 0.5rem 1.25rem 0.25rem;
    font-size: 0.68rem;
    letter-spacing: 0.1em;
    color: rgba(255,255,255,0.35);
    font-weight: 700;
    text-transform: uppercase;
}

.sidebar-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    text-align: center;
    flex-shrink: 0;
}

.sidebar-footer .text-muted {
    color: rgba(255,255,255,0.3) !important;
    font-size: 0.7rem;
}

/* ============ MAIN CONTENT ============ */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

.top-navbar {
    height: var(--topbar-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    position: sticky;
    top: 0;
    z-index: 1020;
    box-shadow: var(--shadow-sm);
}

.sidebar-toggle {
    color: var(--text-primary);
    text-decoration: none;
    padding: 0.25rem;
}

.page-title {
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 600;
}

.page-content {
    flex: 1;
    padding: 1.25rem;
}

/* ============ AVATAR ============ */
.avatar-placeholder {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
}

/* ============ CARDS ============ */
.card {
    border: none;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
    font-weight: 600;
}

/* ============ STAT CARDS (Dashboard) ============ */
.stat-card {
    border-radius: 12px;
    padding: 1.25rem;
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

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

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #fff;
    flex-shrink: 0;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1;
    color: var(--text-primary);
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* ============ TABLES ============ */
.table-responsive {
    border-radius: 8px;
}

.table thead th {
    background: #f8fafc;
    border-bottom: 2px solid var(--border-color);
    font-weight: 600;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-secondary);
    white-space: nowrap;
}

.table td {
    vertical-align: middle;
    font-size: 0.88rem;
}

/* DataTables overrides */
.dataTables_wrapper .dataTables_filter input {
    border-radius: 8px;
    border: 1px solid var(--border-color);
    padding: 0.4rem 0.75rem;
}

.dataTables_wrapper .dataTables_length select {
    border-radius: 8px;
}

/* ============ RISK GAUGE ============ */
.risk-gauge {
    text-align: center;
    padding: 1rem;
}

.risk-percentage {
    font-size: 3rem;
    font-weight: 800;
    line-height: 1;
}

.risk-percentage.risk-bajo    { color: #28a745; }
.risk-percentage.risk-medio   { color: #ffc107; }
.risk-percentage.risk-alto    { color: #dc3545; }
.risk-percentage.risk-critico { color: #6f0000; }

/* ============ CHECKLIST ============ */
.checklist-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
}

.checklist-item:hover {
    background: #f8fafc;
}

.checklist-item:last-child {
    border-bottom: none;
}

/* ============ TIMELINE (Hallazgos/Respuestas) ============ */
.timeline {
    position: relative;
    padding-left: 30px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border-color);
}

.timeline-item {
    position: relative;
    margin-bottom: 1.5rem;
    padding-left: 1rem;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -24px;
    top: 6px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px var(--primary);
}

/* ============ BADGES CUSTOM ============ */
.badge { font-weight: 500; }

/* ============ BUTTONS ============ */
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}
.btn-primary:hover {
    background: var(--primary-light);
    border-color: var(--primary-light);
}

.btn-sm {
    font-size: 0.8rem;
    padding: 0.3rem 0.65rem;
    border-radius: 6px;
}

/* ============ FORMS ============ */
.form-control:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 0.2rem rgba(41, 98, 255, 0.15);
}

/* ============ EMPTY STATE ============ */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 4rem;
    opacity: 0.3;
    display: block;
    margin-bottom: 1rem;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.show {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0 !important;
    }
    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 1040;
        display: none;
    }
    .sidebar-overlay.show {
        display: block;
    }
}

@media (max-width: 575.98px) {
    .page-content {
        padding: 0.75rem;
    }
    .stat-card .stat-value {
        font-size: 1.4rem;
    }
    .login-card {
        padding: 1.5rem 1.25rem;
    }
}

/* ============ PRINT ============ */
@media print {
    .sidebar, .top-navbar, .sidebar-overlay { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .page-content { padding: 0; }
    .card { box-shadow: none; border: 1px solid #ddd; }
}

/* ============ PDF GENERATION STYLES ============ */
/* Applied via body.generating-pdf class during html2pdf capture */
body.generating-pdf .sidebar,
body.generating-pdf .top-navbar,
body.generating-pdf .sidebar-overlay {
    display: none !important;
}
body.generating-pdf .main-content {
    margin-left: 0 !important;
    padding: 0 !important;
    width: 100% !important;
}
body.generating-pdf .page-content {
    padding: 10px 0 !important;
}
body.generating-pdf .fade-in-up {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
}
body.generating-pdf .btn,
body.generating-pdf .btn-group,
body.generating-pdf .no-print,
body.generating-pdf .dataTables_length,
body.generating-pdf .dataTables_filter,
body.generating-pdf .dataTables_paginate,
body.generating-pdf .dataTables_info,
body.generating-pdf form:not(.print-keep) {
    display: none !important;
}
body.generating-pdf .card {
    box-shadow: none !important;
    border: 1px solid #dee2e6 !important;
    break-inside: avoid;
    page-break-inside: avoid;
}
body.generating-pdf .accordion-item {
    break-inside: avoid;
    page-break-inside: avoid;
}
body.generating-pdf .accordion-button::after {
    display: none !important;
}
body.generating-pdf .accordion-button {
    pointer-events: none;
}
body.generating-pdf .table {
    font-size: 0.78rem !important;
}
body.generating-pdf .table th,
body.generating-pdf .table td {
    padding: 4px 8px !important;
    font-size: 0.78rem !important;
}
body.generating-pdf .badge {
    border: 1px solid currentColor !important;
    font-size: 0.7rem !important;
    padding: 2px 6px !important;
}
body.generating-pdf h4 {
    font-size: 1.3rem !important;
}
body.generating-pdf h6 {
    font-size: 0.9rem !important;
}
body.generating-pdf .progress {
    height: 8px !important;
    background-color: #e9ecef !important;
    border: 1px solid #dee2e6;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
}
body.generating-pdf .progress-bar {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
}
body.generating-pdf .alert {
    break-inside: avoid;
    page-break-inside: avoid;
    border: 1px solid currentColor !important;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
}
body.generating-pdf .table-danger {
    background-color: #f8d7da !important;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
}
body.generating-pdf .table-warning {
    background-color: #fff3cd !important;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
}
body.generating-pdf .bg-success,
body.generating-pdf .bg-danger,
body.generating-pdf .bg-warning,
body.generating-pdf .bg-info,
body.generating-pdf .bg-primary,
body.generating-pdf .bg-secondary,
body.generating-pdf .bg-dark {
    print-color-adjust: exact !important;
    -webkit-print-color-adjust: exact !important;
}
/* Page break helpers */
.pdf-page-break-before { page-break-before: always; break-before: page; }
.pdf-page-break-after { page-break-after: always; break-after: page; }

/* ============ ANIMATIONS ============ */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in-up {
    animation: fadeInUp 0.4s ease-out;
}

/* ============ SCROLLBAR CUSTOM ============ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a1a1a1; }

/* ============ LOADING SPINNER ============ */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.8);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ============ MODAL SCROLL FIX ============ */
/* Ensure form.modal-content behaves identically to div.modal-content */
form.modal-content {
    display: flex;
    flex-direction: column;
    width: 100%;
    pointer-events: auto;
    outline: 0;
}

/* Also handle legacy <div.modal-content> > <form> pattern as fallback */
.modal-dialog-scrollable .modal-content > form {
    display: flex;
    flex-direction: column;
    max-height: 100%;
    overflow: hidden;
}

.modal-dialog-scrollable .modal-content > form > .modal-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.modal-dialog-scrollable .modal-content > form > .modal-header,
.modal-dialog-scrollable .modal-content > form > .modal-footer {
    flex-shrink: 0;
}
