/* ===== Reset y tipografía ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    overflow-x: hidden; /* evita scroll horizontal de toda la página */
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background-color: #f3f3f3;
    color: #0f172a;
}

/* ===== Paleta PortalEDI ===== */
:root {
    --color-primary: #1e9aa6;
    --color-primary-light: #3bc3d0;
    --color-primary-dark: #15727b;

    --color-bg: #f3f3f3;
    --color-surface: #ffffff;

    --color-text: #0f172a;
    --color-text-muted: #64748b;
    --color-border: #d4d4d8;

    --color-success: #22c55e;
    --color-warning: #eab308;
    --color-danger: #ef4444;
    --color-info: #1e9aa6;

    --radius-lg: 16px;
    --radius-md: 10px;
    --shadow-sm: 0 2px 6px rgba(15, 23, 42, 0.08);
    --shadow-md: 0 10px 30px rgba(15, 23, 42, 0.12);
}

/* ===== Pantalla de autenticación ===== */
.bg-auth {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top, rgba(30,154,166,0.15), transparent 55%),
                linear-gradient(135deg, #0f172a 0%, #1f2937 40%, #0b1120 100%);
}

.auth-wrapper {
    width: 100%;
    max-width: 420px;
    padding: 24px;
}

.auth-card {
    background-color: var(--color-surface);
    border-radius: 24px;
    padding: 32px 28px;
    box-shadow: var(--shadow-md);
}

.auth-logo-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}

.auth-logo {
    width: 72px;
    height: 72px;
    border-radius: 24px;
}

.auth-title {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--color-text);
}

.auth-subtitle {
    text-align: center;
    font-size: 0.9rem;
    color: var(--color-text-muted);
    margin-bottom: 24px;
}

/* ===== Formularios ===== */
.form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

.form-group input,
.form-group select,
.form-group textarea {
    border-radius: 10px;
    border: 1px solid var(--color-border);
    padding: 10px 12px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    background-color: #f9fafb;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 1px rgba(30,154,166,0.35);
    background-color: #ffffff;
}

/* ===== Botones ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    border: 1px solid transparent;
    padding: 8px 16px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease,
                border-color 0.15s ease, transform 0.05s ease;
    text-decoration: none;
    gap: 8px;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    color: #ffffff;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--color-primary-light), var(--color-primary));
}

.btn-outline {
    background: transparent;
    border-color: rgba(148,163,184,0.5);
    color: var(--color-text);
}

.btn-outline:hover {
    border-color: var(--color-primary);
    color: var(--color-primary-dark);
}

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

.btn-icon {
    border-radius: 999px;
    border: none;
    background: transparent;
    padding: 8px;
    cursor: pointer;
}

/* Utilidades */
.w-100 {
    width: 100%;
}

/* ===== Alerts ===== */
.alert {
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 0.85rem;
    margin-bottom: 12px;
}

.alert-danger {
    background-color: rgba(239, 68, 68, 0.08);
    color: #b91c1c;
    border: 1px solid rgba(248, 113, 113, 0.6);
}

/* ===== Layout principal (dashboard) ===== */
.app-body {
    min-height: 100vh;
}

.app-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    grid-template-rows: auto 1fr auto;
    min-height: 100vh;
    background-color: var(--color-bg);
}

.sidebar {
    grid-row: 1 / 4;
    grid-column: 1 / 2;
    background: linear-gradient(180deg, #0f172a, #0b1120);
    color: #e5e7eb;
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    height: 100vh;
    overflow-y: auto;
}


.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px;
}

.sidebar-logo img {
    width: 40px;
    height: 40px;
    border-radius: 14px;
}

.sidebar-logo span {
    font-weight: 700;
    letter-spacing: 0.03em;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 12px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 10px;
    color: #cbd5f5;
    font-size: 0.92rem;
    text-decoration: none;
    transition: background-color 0.12s ease, color 0.12s ease, transform 0.03s ease;
}

.sidebar-link i {
    width: 18px;
    text-align: center;
}

.sidebar-link:hover {
    background-color: rgba(148, 163, 184, 0.25);
    color: #ffffff;
}

.sidebar-link-active {
    background: var(--color-primary); /* tu verde PortalEDI */
    color: #fff;
}


.topbar {
    grid-column: 2 / 3;
    grid-row: 1 / 2;
    background-color: var(--color-surface);
    border-bottom: 1px solid rgba(148,163,184,0.2);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
    position: static;
    top: auto;
    z-index: 10;
}

.topbar-title h1 {
    font-size: 1.1rem;
    font-weight: 600;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
}

.topbar-user-name {
    font-weight: 600;
}

.topbar-user-role {
    color: var(--color-text-muted);
    font-size: 0.8rem;
}

.topbar-menu-btn {
    display: none;
    color: #0f172a;
}

.app-main {
    grid-column: 2 / 3;
    grid-row: 2 / 3;
    padding: 20px;
    min-height: calc(100vh - 60px); /* ajusta el 60px si tu topbar es más alta */
}

.app-footer {
    grid-column: 2 / 3;
    grid-row: 3 / 4;
    padding: 10px 20px;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

/* ===== Contenedores y cards ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
}

.card {
    background-color: var(--color-surface);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(148,163,184,0.25);
    box-shadow: var(--shadow-sm);
    padding: 16px 18px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
}

.card-body {
    font-size: 0.9rem;
}

/* KPIs */
.grid {
    display: grid;
    gap: 16px;
}

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

.grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.kpi-card .kpi-title {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
}

.kpi-card .kpi-icon {
    color: var(--color-primary);
    font-size: 1.1rem;
}

.kpi-card .kpi-value {
    display: block;
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.kpi-card .kpi-subtitle {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

/* Badges */
.badge {
    display: inline-flex;
    width: 10px;
    height: 10px;
    border-radius: 999px;
    margin-right: 6px;
}

.badge-success {
    background-color: var(--color-success);
}

.badge-warning {
    background-color: var(--color-warning);
}

.badge-danger {
    background-color: var(--color-danger);
}

.badge-info {
    background-color: var(--color-info);
}

/* ===== Tablas ===== */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    overflow-y: auto;
    max-height: calc(100vh - 220px);
    display: block;    /* asegura que respete el max-height */
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.table th,
.table td {
    padding: 8px 10px;
    border-bottom: 1px solid rgba(148,163,184,0.25);
    text-align: left;
}

.table th {
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    background-color: #f9fafb;
}

/* Margenes utilitarias */
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }

/* Listas */
.status-list {
    list-style: none;
    padding-left: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .app-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto 1fr auto;
    }

    .sidebar {
        grid-column: 1 / 2;
        grid-row: 2 / 3;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        position: fixed;
        left: 0;
        top: 56px;
        bottom: 0;
        width: 220px;
        z-index: 50;
    }

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

    .topbar {
        grid-column: 1 / 2;
    }

    .topbar-menu-btn {
        display: inline-flex;
    }

    .app-main {
        grid-column: 1 / 2;
        margin-top: 8px;
    }

    .app-footer {
        grid-column: 1 / 2;
    }

    .grid-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .grid-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 600px) {
    .grid-4,
    .grid-3,
    .grid-2 {
        grid-template-columns: 1fr;
    }

    .topbar-title h1 {
        font-size: 1rem;
    }

    .topbar-user {
        display: none;
    }

    .auth-card {
        padding: 24px 20px;
    }
}
/* ===== Chips de estado/prioridad (reclamos) ===== */
.chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
    gap: 4px;
    border: 1px solid transparent;
}

.chip-dot {
    width: 7px;
    height: 7px;
    border-radius: 999px;
}

.chip-estado-abierto {
    background-color: rgba(239,68,68,0.06);
    color: #991b1b;
    border-color: rgba(248,113,113,0.7);
}
.chip-estado-abierto .chip-dot {
    background-color: #ef4444;
}

.chip-estado-en_progreso {
    background-color: rgba(234,179,8,0.08);
    color: #92400e;
    border-color: rgba(250,204,21,0.7);
}
.chip-estado-en_progreso .chip-dot {
    background-color: #eab308;
}

.chip-estado-resuelto {
    background-color: rgba(34,197,94,0.08);
    color: #166534;
    border-color: rgba(52,211,153,0.7);
}
.chip-estado-resuelto .chip-dot {
    background-color: #22c55e;
}

.chip-estado-cerrado {
    background-color: rgba(148,163,184,0.1);
    color: #334155;
    border-color: rgba(148,163,184,0.8);
}
.chip-estado-cerrado .chip-dot {
    background-color: #64748b;
}

.chip-prioridad-baja {
    background-color: rgba(148,163,184,0.12);
    color: #475569;
}
.chip-prioridad-media {
    background-color: rgba(59,130,246,0.1);
    color: #1d4ed8;
}
.chip-prioridad-alta {
    background-color: rgba(239,68,68,0.09);
    color: #b91c1c;
}
/* ===== Finanzas ===== */
.amount-pos {
    color: #16a34a;
    font-weight: 600;
}
.amount-neg {
    color: #b91c1c;
    font-weight: 600;
}
.amount-muted {
    color: var(--color-text-muted);
}
.tag-tipo {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
}
.tag-tipo-ingreso {
    background-color: rgba(34,197,94,0.1);
    color: #15803d;
}
.tag-tipo-gasto {
    background-color: rgba(239,68,68,0.1);
    color: #b91c1c;
}
.tag-estado-cobro {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
}
.tag-estado-pendiente { background-color: rgba(234,179,8,0.15); color:#92400e; }
.tag-estado-parcial   { background-color: rgba(59,130,246,0.15); color:#1d4ed8; }
.tag-estado-pagado    { background-color: rgba(34,197,94,0.15); color:#166534; }
.tag-estado-vencido   { background-color: rgba(239,68,68,0.15); color:#b91c1c; }

@media (max-width: 600px) {
    /* Evitar scroll horizontal global en móvil */
    body, .app-layout, .app-main {
        overflow-x: hidden;
    }

    /* La tabla tiene scroll horizontal y vertical propio */
    .table-responsive {
        max-height: calc(100vh - 180px); /* un poco menos alto en móvil */
        overflow-x: auto;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch; /* scroll más suave en iOS */
    }

    /* Que la tabla no fuerce más ancho del necesario */
    .table {
        min-width: 600px; /* o el ancho mínimo que necesites para que no se aplaste demasiado */
    }
}
