:root {
    /* TEMA CLARO PREMIUM */
    --bg-base: #f8fafc;
    --bg-panel: rgba(255, 255, 255, 0.7);
    --bg-card: rgba(255, 255, 255, 0.95);
    --bg-input: #ffffff;
    --bg-hover: rgba(15, 23, 42, 0.04);

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --border-color: rgba(15, 23, 42, 0.08);
    --border-focus: rgba(79, 70, 229, 0.5);

    --primary: #15394c;
    --primary-hover: #4338ca;
    --secondary: #0ea5e9;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;

    --gradient-primary: linear-gradient(135deg, var(--primary), var(--secondary));

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-glass: 0 8px 32px 0 rgba(31, 38, 135, 0.07);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;

    --sidebar-width: 280px;
    --header-height: 70px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
}

.bg-decoration {
    position: fixed;
    top: -10%;
    right: -10%;
    width: 50%;
    height: 50%;
    background: radial-gradient(circle, rgba(79, 70, 229, 0.05) 0%, rgba(255, 255, 255, 0) 70%);
    z-index: -1;
    pointer-events: none;
}

.hidden {
    display: none !important;
}

/* --- BOTONES --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.95rem;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}

.btn-primary:active {
    transform: scale(0.98);
    opacity: 0.9;
}

.btn-secondary {
    background: white;
    color: var(--text-primary);
    border-color: var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

/* --- FORMULARIOS --- */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.form-select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem;
    padding-right: 2.5rem;
}

.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--border-focus);
}

.form-select:valid:not([value=""]) {
    border-color: var(--success);
}

input,
select,
textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.2s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--border-focus);
}

.input-error {
    border-color: var(--danger) !important;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.2) !important;
    animation: shake 0.4s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.animate-in {
    animation: fadeSlideIn 0.3s ease-out;
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.incident-card.updating {
    animation: pulse 0.5s ease-in-out;
}

@keyframes pulse {
    0%, 100% { box-shadow: var(--shadow-sm); }
    50% { box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.2); }
}

select:active {
    border-color: var(--primary);
}

select:hover {
    border-color: var(--border-focus);
}

/* --- LOGIN --- */
#login-page {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-card);
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-glass);
    text-align: center;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.login-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

#login-hint {
    animation: fadeIn 0.5s ease-out 1s both;
}

#login-pin {
    transition: all 0.3s ease;
}

#login-btn {
    transition: all 0.3s ease;
}

#login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.3);
}

/* --- APP LAYOUT --- */
#app-container {
    display: flex;
    min-height: 100vh;
}

#sidebar {
    width: var(--sidebar-width);
    background: var(--bg-panel);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-header {
    padding: 2rem;
    font-size: 1.5rem;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1rem;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    font-weight: 500;
    margin-bottom: 0.25rem;
    transition: all 0.2s;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: white;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 1rem;
}

#main-content {
    flex: 1;
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.page-header {
    margin-bottom: 2rem;
}

.page-title {
    font-size: 1.8rem;
    font-weight: 800;
}

.page-subtitle {
    color: var(--text-secondary);
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

/* --- STATS --- */
.stat-card {
    padding: 1rem 0.5rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 0;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stat-card:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-md);
}

.stat-card .stat-value {
    transition: all 0.3s ease;
}

.stat-card .stat-value.changed {
    animation: countUp 0.4s ease-out;
}

@keyframes countUp {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.stats-grid {
    margin-bottom: 2rem;
}

/* --- INCIDENT CARDS --- */
.incident-card {
    border-left: 4px solid var(--text-muted);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.incident-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

/* FILTROS */
.filters-container {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 0.5rem 0 1rem 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.filters-container::-webkit-scrollbar {
    display: none;
}

.filter-chip {
    padding: 0.5rem 1rem;
    border-radius: 100px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-chip.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}

.incident-card-img-container {
    width: 120px;
    height: 120px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #f1f5f9;
    margin: 0.5rem 0;
    cursor: pointer;
    transition: transform 0.2s ease;
    align-self: flex-start;
}

.incident-card-img-container:hover {
    transform: scale(1.05);
}

.incident-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.status-PENDIENTE {
    border-left-color: var(--warning);
}

.status-EN_PROGRESO {
    border-left-color: var(--secondary);
}

.status-RESUELTA {
    border-left-color: var(--success);
}

.status-CERRADA {
    border-left-color: var(--text-muted);
    opacity: 0.8;
}

.badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    font-weight: 700;
    display: inline-block;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge.status-PENDIENTE {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge.status-EN_PROGRESO {
    background: rgba(6, 182, 212, 0.1);
    color: var(--secondary);
    border: 1px solid rgba(6, 182, 212, 0.2);
}

.badge.status-RESUELTA {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.sort-controls {
    margin-bottom: 1rem;
    display: flex;
    gap: 0.5rem;
    align-items: center;
    padding: 0.75rem;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.sort-controls label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

.sort-controls select {
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.9rem;
    min-width: 150px;
}

.sort-controls select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* --- MOBILE ELEMENTS (Hidden on desktop) --- */
.mobile-header,
.sidebar-overlay,
.bottom-nav {
    display: none;
}

/* --- MOBILE --- */
/* En móviles, ocultar header, menu desplegable. */


@media (max-width: 768px) {
    #sidebar {
        display: none !important;
    }

    .sidebar-overlay {
        display: none !important;
    }

    .sidebar-overlay.active {
        opacity: 1;
        transition: all 0.2s ease-in-out;
        visibility: visible;
    }

    #main-content {
        padding: 0.75rem;
        padding-bottom: 80px;
    }

    .mobile-header {
        display: none !important;
    }

    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        width: 100%;
        background: var(--bg-card);
        border-top: 1px solid var(--border-color);
        padding: 0.75rem 1rem;
        justify-content: space-around;
        z-index: 50;
    }

    .bnav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        font-size: 0.7rem;
        color: var(--text-secondary);
        gap: 2px;
    }

    .bnav-item.active {
        color: var(--primary);
    }

    /* --- ESTILOS ESPECÍFICOS PARA LISTA EN MÓVILES --- */

    .page-header {
        margin-bottom: 1rem;
        padding: 0;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .page-header .btn {
        align-self: flex-end;
        padding: 0.5rem;
    }

    .page-title {
        font-size: 1.25rem;
        margin-bottom: 0.5rem;
        word-break: break-word;
    }

    .filters-container {
        gap: 0.375rem;
        padding: 0.5rem 0 1rem 0;
        margin-bottom: 1rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: wrap;
        justify-content: flex-start !important;
    }

    .filter-chip {
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
        white-space: nowrap;
        flex-shrink: 1;
        flex: 1 1 auto;
        min-width: 0;
    }

    .sort-controls {
        margin-bottom: 1rem;
        padding: 0.75rem;
        flex-wrap: wrap;
        gap: 0.5rem;
        align-items: flex-start;
        flex-direction: column !important;
    }

    .sort-controls label {
        font-size: 0.85rem;
        margin-bottom: 0.25rem;
        width: 100% !important;
    }

    .sort-controls select {
        min-width: 120px;
        flex: 1;
        font-size: 0.85rem;
        width: 100% !important;
        max-width: none !important;
    }

    .incident-card {
        padding: 1rem;
        margin-bottom: 1rem;
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-sm);
        word-break: break-word;
    }

    .incident-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .incident-card-header > div:last-child {
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
    }

    .incident-card-header > div:first-child {
        width: 100%;
    }

    .incident-card-header > div:last-child {
        width: 100% !important;
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
    }

    .incident-card-header select {
        font-size: 0.8rem;
        padding: 0.375rem 0.5rem;
        min-width: auto;
        width: auto;
        max-width: 140px;
        max-width: 100% !important;
    }

    .incident-card-img-container {
        width: 100%;
        height: 200px;
        margin: 0.5rem 0;
        align-self: stretch !important;
        max-width: 100%;
    }

    .incident-card-img-container:hover {
        transform: none;
    }

    /* Ajustes para toast en móvil */
    #toast-container {
        left: 0.75rem;
        right: 0.75rem;
        top: 1rem;
    }

    .toast {
        margin-bottom: 0.5rem;
        font-size: 0.9rem;
    }
}

/* --- TOAST --- */
#toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 1rem 1.5rem;
    background: #0f172a;
    color: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s forwards;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 200px;
    max-width: 350px;
}

.toast::before {
    font-family: 'Material Symbols Rounded';
    font-size: 1.2rem;
}

.toast.success::before {
    content: '✓';
    color: var(--success);
}

.toast.error::before {
    content: '!';
    color: var(--danger);
}

.toast:not(.success):not(.error)::before {
    content: 'ℹ';
    color: var(--secondary);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

/* Image Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    background: white;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1001;
    transition: background 0.2s ease;
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.9);
}

#modal-image {
    max-width: 100%;
    max-height: 100%;
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Skeleton Loaders */
.skeleton-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
}

.skeleton-line {
    height: 1rem;
    background: linear-gradient(90deg, var(--bg-hover) 25%, var(--border-color) 50%, var(--bg-hover) 75%);
    background-size: 200% 100%;
    border-radius: 4px;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* Enhanced Toast */
.toast.success {
    border-left: 4px solid var(--success);
}

.toast.error {
    border-left: 4px solid var(--danger);
}

/* Interactive card improvements */
.incident-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.incident-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Loading button state */
.btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-primary:disabled {
    background: linear-gradient(135deg, #94a3b8, #64748b);
}

/* Filter chip active animation */
.filter-chip:active {
    transform: scale(0.95);
}

/* Status change highlight */
.status-changed {
    animation: statusFlash 0.6s ease-out;
}

@keyframes statusFlash {
    0% { background-color: rgba(79, 70, 229, 0.2); }
    100% { background-color: transparent; }
}