/* app/static/css/style.css */

:root {
    --color-bg: #F6F8F8;
    --color-surface: #FFFFFF;
    --color-primary: #0F5257;
    --color-primary-dark: #0A3A3E;
    --color-primary-light: #E4EEEE;
    --color-text: #1A2B2E;
    --color-text-muted: #5C6B6D;
    --color-border: #E1E6E5;
    --color-estado-abierto: #3B7DD8;
    --color-estado-en_progreso: #C08A1E;
    --color-estado-resuelto: #2F9E64;
    --color-estado-cerrado: #6B7280;
    --color-urgencia-baja: #5A8F68;
    --color-urgencia-media: #C08A1E;
    --color-urgencia-alta: #D97A3D;
    --color-urgencia-critica: #C94A3B;
    --color-alerta-bg: #FDEAEA;
    --color-alerta-border: #E8A3A3;
    --radius: 8px;
    --shadow-sm: 0 1px 2px rgba(15, 82, 87, 0.06);
    --shadow-md: 0 2px 8px rgba(15, 82, 87, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: -apple-system, "Segoe UI", system-ui, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

h1, h2, h3 {
    font-family: "Manrope", -apple-system, "Segoe UI", sans-serif;
    color: var(--color-primary-dark);
    font-weight: 700;
    letter-spacing: -0.01em;
}

a {
    color: var(--color-primary);
    text-decoration: none;
}

    a:hover {
        text-decoration: underline;
    }

/* --- Header / navegación --- */
.app-header {
    background: var(--color-primary-dark);
    color: white;
    padding: 0.9rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

    .app-header .brand {
        font-family: "Manrope", sans-serif;
        font-weight: 800;
        font-size: 1.1rem;
        color: white;
        letter-spacing: -0.01em;
    }

        .app-header .brand:hover {
            text-decoration: none;
            opacity: 0.9;
        }

.app-nav {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
    align-items: center;
}

    .app-nav a {
        color: #D8E8E8;
        font-size: 0.92rem;
        font-weight: 500;
    }

        .app-nav a:hover {
            color: white;
            text-decoration: none;
        }

    .app-nav .user-chip {
        color: #9FC2C2;
        font-size: 0.85rem;
        border-left: 1px solid rgba(255,255,255,0.2);
        padding-left: 1.25rem;
    }

/* --- Layout general --- */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.75rem 1.5rem 3rem;
}

.page-title {
    margin: 0 0 1.25rem;
}

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
}

/* --- Formularios --- */
label {
    display: block;
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--color-text-muted);
    margin-bottom: 0.3rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="file"],
select,
textarea {
    width: 100%;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--color-text);
    background: var(--color-surface);
    margin-bottom: 1rem;
}

    input:focus, select:focus, textarea:focus {
        outline: 2px solid var(--color-primary);
        outline-offset: 1px;
    }

.field-row {
    margin-bottom: 1rem;
}

button, .btn {
    display: inline-block;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    padding: 0.6rem 1.1rem;
    font-size: 0.92rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
}

    button:hover, .btn:hover {
        background: var(--color-primary-dark);
        text-decoration: none;
    }

.btn-secondary {
    background: transparent;
    color: var(--color-primary);
    border: 1px solid var(--color-border);
}

    .btn-secondary:hover {
        background: var(--color-primary-light);
    }

.btn-danger {
    background: var(--color-urgencia-critica);
}

    .btn-danger:hover {
        background: #A83B2E;
    }

.error-msg {
    background: var(--color-alerta-bg);
    border: 1px solid var(--color-alerta-border);
    color: #8A2E2E;
    padding: 0.7rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

/* --- Tablas --- */
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

th {
    background: var(--color-primary-light);
    color: var(--color-primary-dark);
    text-align: left;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.7rem 0.9rem;
    border-bottom: 1px solid var(--color-border);
}

td {
    padding: 0.65rem 0.9rem;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.92rem;
}

tr:last-child td {
    border-bottom: none;
}

tr.fila-estancada {
    background: var(--color-alerta-bg);
}

/* --- Badges de estado / urgencia --- */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    color: white;
    white-space: nowrap;
}

.badge-estado-abierto {
    background: var(--color-estado-abierto);
}

.badge-estado-en_progreso {
    background: var(--color-estado-en_progreso);
}

.badge-estado-resuelto {
    background: var(--color-estado-resuelto);
}

.badge-estado-cerrado {
    background: var(--color-estado-cerrado);
}

.badge-urgencia-baja {
    background: var(--color-urgencia-baja);
}

.badge-urgencia-media {
    background: var(--color-urgencia-media);
}

.badge-urgencia-alta {
    background: var(--color-urgencia-alta);
}

.badge-urgencia-critica {
    background: var(--color-urgencia-critica);
}

.filtros-form {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: 1.25rem;
}

    .filtros-form .field-row {
        margin-bottom: 0;
        min-width: 160px;
    }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-box {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow-sm);
}

    .stat-box .stat-value {
        font-family: "Manrope", sans-serif;
        font-size: 1.8rem;
        font-weight: 800;
        color: var(--color-primary-dark);
    }

    .stat-box .stat-label {
        font-size: 0.8rem;
        color: var(--color-text-muted);
        text-transform: uppercase;
        letter-spacing: 0.03em;
    }

/* --- Toast de confirmación --- */
#toast-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.toast {
    background: var(--color-primary-dark);
    color: white;
    padding: 0.75rem 1.1rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: toast-in 0.25s ease-out;
    max-width: 320px;
}

    .toast.toast-error {
        background: var(--color-urgencia-critica);
    }

    .toast.toast-saliendo {
        animation: toast-out 0.25s ease-in forwards;
    }

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes toast-out {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

/* --- Modal de vista previa de adjuntos --- */
.adjunto-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0;
    cursor: pointer;
    color: var(--color-primary);
}

    .adjunto-item:hover {
        text-decoration: underline;
    }

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 43, 46, 0.75);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

    .modal-overlay.activo {
        display: flex;
    }

.modal-box {
    background: white;
    border-radius: var(--radius);
    max-width: 90vw;
    max-height: 88vh;
    width: 700px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.9rem 1.2rem;
    border-bottom: 1px solid var(--color-border);
}

    .modal-header strong {
        font-family: "Manrope", sans-serif;
    }

.modal-cerrar {
    background: none;
    border: none;
    color: var(--color-text-muted);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0 0.3rem;
    line-height: 1;
}

    .modal-cerrar:hover {
        color: var(--color-text);
        background: none;
    }

.modal-body {
    padding: 1.2rem;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
}

    .modal-body img {
        max-width: 100%;
        max-height: 70vh;
        border-radius: 4px;
    }

    .modal-body iframe {
        width: 100%;
        height: 70vh;
        border: none;
    }

    .modal-body .sin-vista-previa {
        text-align: center;
        color: var(--color-text-muted);
    }

/* --- Menú de navegación responsive --- */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.2rem 0.5rem;
    line-height: 1;
}

    .nav-toggle:hover {
        background: rgba(255, 255, 255, 0.1);
        border-radius: var(--radius);
    }

@media (max-width: 768px) {
    .app-header {
        padding: 0.9rem 1rem;
    }

    .nav-toggle {
        display: block;
    }

    .app-nav {
        display: none;
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        gap: 0;
        background: var(--color-primary-dark);
        margin-top: 0.75rem;
    }

        .app-nav.abierto {
            display: flex;
        }

        .app-nav a {
            width: 100%;
            padding: 0.65rem 0.25rem;
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        }

        .app-nav .user-chip {
            border-left: none;
            border-top: 1px solid rgba(255, 255, 255, 0.2);
            padding: 0.75rem 0.25rem 0.25rem;
            width: 100%;
            margin-top: 0.25rem;
        }

    .nav-dropdown-content {
        position: static;
        border: none;
        box-shadow: none;
        margin-top: 0;
        padding-left: 1rem;
        background: rgba(0, 0, 0, 0.15);
    }

    .nav-dropdown summary {
        padding: 0.65rem 0.25rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .container {
        padding: 1.25rem 1rem 2.5rem;
    }

    .filtros-form {
        flex-direction: column;
        align-items: stretch;
    }

        .filtros-form .field-row {
            min-width: 0;
        }

    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    .stat-grid {
        grid-template-columns: 1fr;
    }
}

/* --- Dropdowns del menú --- */
.nav-dropdown {
    position: relative;
}

    .nav-dropdown summary {
        color: #D8E8E8;
        font-size: 0.92rem;
        font-weight: 500;
        cursor: pointer;
        list-style: none;
        display: flex;
        align-items: center;
        gap: 0.3rem;
    }

        .nav-dropdown summary::-webkit-details-marker {
            display: none;
        }

        .nav-dropdown summary::after {
            content: "▾";
            font-size: 0.7rem;
        }

        .nav-dropdown summary:hover {
            color: white;
        }

    .nav-dropdown[open] summary::after {
        content: "▴";
    }

.nav-dropdown-content {
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--color-primary-dark);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius);
    padding: 0.4rem 0;
    min-width: 180px;
    box-shadow: var(--shadow-md);
    z-index: 10;
    margin-top: 0.5rem;
}

    .nav-dropdown-content a {
        display: block;
        padding: 0.5rem 1rem;
        white-space: nowrap;
    }

        .nav-dropdown-content a:hover {
            background: rgba(255, 255, 255, 0.08);
        }