/* ============================================================
   FUNDACIÓN MUTUA — public/css/theme.css
   Variables del sistema + clases utilitarias para las vistas
   ============================================================ */
:root {
  --background:           #f8fafc;
  --foreground:           #0f172a;
  --card:                 #ffffff;
  --border:               #e2e8f0;
  --primary:              #1d4ed8;
  --primary-foreground:   #ffffff;
  --secondary:            #f1f5f9;
  --secondary-foreground: #475569;
  --muted:                #f1f5f9;
  --muted-foreground:     #64748b;
  --success:              #16a34a;
  --success-bg:           #dcfce7;
  --warning:              #d97706;
  --warning-bg:           #fef3c7;
  --danger:               #dc2626;
  --danger-bg:            #fee2e2;
  --sidebar-width:        240px;
  --radius:               0.5rem;
  --shadow-sm:            0 1px 2px 0 rgb(0 0 0 / 0.05);
}

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

body {
  background-color: var(--background);
  color: var(--foreground);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

/* ── LAYOUT ──────────────────────────────────────────────────── */
.layout       { display: flex; min-height: 100vh; }
.sidebar      { width: var(--sidebar-width); background: var(--card); border-right: 1px solid var(--border); height: 100vh; position: fixed; left: 0; top: 0; display: flex; flex-direction: column; z-index: 50; }
.main-content { margin-left: var(--sidebar-width); flex: 1; min-height: 100vh; }
.page-header  { background: var(--card); border-bottom: 1px solid var(--border); padding: 1rem 2rem; display: flex; align-items: center; justify-content: space-between; }
.page-body    { padding: 2rem; }

/* ── SIDEBAR ─────────────────────────────────────────────────── */
.sidebar-logo      { padding: 1rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 0.75rem; }
.sidebar-logo-icon { width: 2.25rem; height: 2.25rem; background: var(--primary); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sidebar-logo-icon svg { width: 1.25rem; height: 1.25rem; stroke: white; fill: none; }
.sidebar-logo-name { font-size: 0.875rem; font-weight: 600; color: var(--foreground); }
.sidebar-logo-sub  { font-size: 0.75rem; color: var(--muted-foreground); }
.sidebar-nav       { flex: 1; padding: 0.75rem; display: flex; flex-direction: column; gap: 0.25rem; }
.sidebar-footer    { padding: 0.75rem; border-top: 1px solid var(--border); }
.sidebar-user      { background: var(--muted); border-radius: var(--radius); padding: 0.625rem 0.75rem; margin-bottom: 0.5rem; }
.sidebar-user-name { font-size: 0.875rem; font-weight: 500; color: var(--foreground); }
.sidebar-user-role { font-size: 0.75rem; color: var(--muted-foreground); }

/* ── NAV ITEMS ───────────────────────────────────────────────── */
.nav-item { display: flex; align-items: center; gap: 0.625rem; padding: 0.5rem 0.75rem; border-radius: var(--radius); color: var(--muted-foreground); text-decoration: none; font-size: 0.875rem; font-weight: 500; transition: all .15s; width: 100%; border: none; cursor: pointer; background: transparent; }
.nav-item:hover  { background: var(--muted); color: var(--foreground); }
.nav-item.active { background: var(--primary); color: white; }
.nav-item svg    { width: 1rem; height: 1rem; flex-shrink: 0; }
.nav-item.danger { color: var(--danger); }
.nav-item.danger:hover { background: var(--danger-bg); }

/* ── CARDS ───────────────────────────────────────────────────── */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }

/* ── BADGES / ESTADO ─────────────────────────────────────────── */
.badge { display: inline-block; padding: 0.2rem 0.6rem; border-radius: 0.25rem; font-size: 0.75rem; font-weight: 600; }
.badge-activo   { background: var(--success-bg);  color: var(--success); }
.badge-proceso  { background: var(--warning-bg);  color: var(--warning); }
.badge-inactivo { background: var(--muted);        color: var(--muted-foreground); }
.badge-vencida  { background: var(--danger-bg);   color: var(--danger); }
.badge-admin    { background: #ede9fe; color: #7c3aed; }
.badge-coord    { background: #dcfce7; color: #15803d; }
.badge-count    { display: inline-flex; align-items: center; justify-content: center; width: 1.75rem; height: 1.75rem; border-radius: 50%; background: #dbeafe; color: #1d4ed8; font-size: 0.75rem; font-weight: 600; }

/* ── BOTONES ─────────────────────────────────────────────────── */
.btn-primary   { background: var(--primary); color: var(--primary-foreground); border-radius: var(--radius); padding: 0.5rem 1rem; font-size: 0.875rem; font-weight: 500; border: none; cursor: pointer; display: inline-flex; align-items: center; gap: 0.375rem; text-decoration: none; transition: opacity .15s; }
.btn-primary:hover { opacity: 0.9; }
.btn-secondary { background: var(--secondary); color: var(--secondary-foreground); border-radius: var(--radius); padding: 0.5rem 1rem; font-size: 0.875rem; font-weight: 500; border: none; cursor: pointer; display: inline-flex; align-items: center; gap: 0.375rem; text-decoration: none; transition: background .15s; }
.btn-secondary:hover { background: #e2e8f0; }
.btn-danger  { background: var(--danger); color: #fff; border-radius: var(--radius); padding: 0.5rem 1rem; font-size: 0.875rem; font-weight: 500; border: none; cursor: pointer; display: inline-flex; align-items: center; gap: 0.375rem; text-decoration: none; transition: opacity .15s; }
.btn-danger:hover { opacity: 0.88; }
.btn-ghost  { background: transparent; color: var(--muted-foreground); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.375rem 0.75rem; font-size: 0.875rem; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: 0.375rem; text-decoration: none; transition: all .15s; }
/* Searchable select */
.ss-wrap { position: relative; }
.ss-list { position: absolute; z-index: 600; top: calc(100% + 2px); left: 0; width: 100%; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 4px 14px rgba(0,0,0,.1); max-height: 210px; overflow-y: auto; display: none; }
.ss-item { padding: .4rem .75rem; font-size: .875rem; cursor: pointer; color: var(--foreground); }
.ss-item:hover, .ss-item.active { background: var(--muted); }
.btn-ghost:hover { background: var(--muted); color: var(--foreground); }
.btn-icon   { background: transparent; border: none; cursor: pointer; color: var(--muted-foreground); padding: 0.25rem; border-radius: 0.25rem; display: inline-flex; align-items: center; transition: color .15s; }
.btn-icon:hover         { color: var(--primary); }
.btn-icon.danger:hover  { color: var(--danger); }
.btn-icon svg           { width: 1rem; height: 1rem; }

/* ── FORMULARIOS ─────────────────────────────────────────────── */
.form-label { display: block; font-size: 0.8125rem; font-weight: 500; color: var(--foreground); margin-bottom: 0.25rem; }
.form-input { width: 100%; border: 1px solid var(--border); border-radius: var(--radius); padding: 0.5rem 0.75rem; background: #fff; color: var(--foreground); font-size: 0.875rem; transition: border-color .15s, box-shadow .15s; outline: none; }
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgb(29 78 216 / 0.1); }
.form-error { font-size: 0.75rem; color: var(--danger); margin-top: 0.25rem; }
.form-group { margin-bottom: 1rem; }

/* ── TABLA ───────────────────────────────────────────────────── */
.table-wrap  { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; white-space: nowrap; }
.data-table th { text-align: left; font-size: 0.75rem; font-weight: 600; color: var(--muted-foreground); text-transform: uppercase; letter-spacing: 0.05em; padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); }
.data-table td { padding: 0.875rem 1rem; border-bottom: 1px solid var(--border); font-size: 0.875rem; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--muted); }

/* ── ALERTAS ─────────────────────────────────────────────────── */
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #bbf7d0; border-radius: var(--radius); padding: 0.75rem 1rem; font-size: 0.875rem; margin-bottom: 1.5rem; }
.alert-error   { background: var(--danger-bg);  color: var(--danger);  border: 1px solid #fecaca; border-radius: var(--radius); padding: 0.75rem 1rem; font-size: 0.875rem; margin-bottom: 1.5rem; }

/* ── MODAL ───────────────────────────────────────────────────── */
.modal-overlay { display: none; position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,0.4); align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal-box  { background: var(--card); border-radius: calc(var(--radius) * 1.5); padding: 1.5rem; width: 100%; max-width: 32rem; margin: 1rem; box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1); }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.modal-title  { font-size: 1.0625rem; font-weight: 600; color: var(--foreground); }
.modal-close  { background: none; border: none; cursor: pointer; color: var(--muted-foreground); font-size: 1.25rem; line-height: 1; }

/* ── UTILIDADES ──────────────────────────────────────────────── */
.text-muted    { color: var(--muted-foreground); }
.text-primary  { color: var(--primary); }
.text-danger   { color: var(--danger); }
.text-success  { color: var(--success); }
.font-semibold { font-weight: 600; }
.font-medium   { font-weight: 500; }
.text-xs  { font-size: 0.75rem; }
.text-sm  { font-size: 0.875rem; }
.text-lg  { font-size: 1.125rem; }
.text-2xl { font-size: 1.5rem; }
.text-3xl { font-size: 2rem; }
.text-4xl { font-size: 2.5rem; }
.uppercase    { text-transform: uppercase; }
.tracking-wide { letter-spacing: 0.05em; }
.mt-1 { margin-top: 0.25rem; } .mt-2 { margin-top: 0.5rem; } .mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; } .mt-6 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.25rem; } .mb-2 { margin-bottom: 0.5rem; } .mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; } .mb-6 { margin-bottom: 1.5rem; }
.p-3 { padding: 0.75rem; } .p-4 { padding: 1rem; } .p-5 { padding: 1.25rem; } .p-6 { padding: 1.5rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.gap-2 { gap: 0.5rem; } .gap-3 { gap: 0.75rem; } .gap-4 { gap: 1rem; } .gap-6 { gap: 1.5rem; }
.flex { display: flex; } .flex-col { flex-direction: column; }
.items-center { align-items: center; } .items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; } .justify-end { justify-content: flex-end; } .justify-center { justify-content: center; }
.flex-1 { flex: 1; }
.w-full { width: 100%; }
.col-span-2 { grid-column: span 2; }
.col-span-3 { grid-column: span 3; }
.space-y-2 > * + * { margin-top: 0.5rem; }
.space-y-3 > * + * { margin-top: 0.75rem; }
.space-y-4 > * + * { margin-top: 1rem; }
.hidden { display: none; }
.divider { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0; }
.rounded { border-radius: var(--radius); }
.text-center { text-align: center; }
summary { cursor: pointer; }
details summary { font-size: 0.8125rem; font-weight: 500; color: var(--primary); padding: 0.375rem 0; }

/* ── GRIDS FLUIDOS (se adaptan solos sin breakpoints) ─────────── */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.form-grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }

/* ── RESPONSIVE ──────────────────────────────────────────────── */
.hamburger {
    display: none;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--foreground);
    padding: 0.375rem;
    border-radius: var(--radius);
    margin-right: 0.5rem;
    flex-shrink: 0;
}
.hamburger:hover { background: var(--muted); }
.hamburger svg   { width: 1.25rem; height: 1.25rem; }

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

@media (max-width: 1024px) {
    .sidebar {
        left: calc(-1 * var(--sidebar-width));
        transition: left .25s ease;
    }
    .sidebar.sidebar-open { left: 0; }
    .main-content { margin-left: 0; }
    .hamburger    { display: flex; }
    .page-header  { padding: 0.75rem 1.25rem; }
    .page-body    { padding: 1.25rem; }
}

/* ── TABLA → TARJETAS (móvil) ──────────────────────────────── */
@media (max-width: 768px) {
    .table-wrap { overflow-x: unset; }
    .data-table { white-space: normal; }
    .data-table thead { display: none; }
    .data-table,
    .data-table tbody { display: block; }

    .data-table tr {
        display: block;
        padding: .875rem 1rem;
        border-bottom: 1px solid var(--border);
    }
    .data-table tbody tr:last-child { border-bottom: none; }
    .data-table tbody tr:hover      { background: transparent; }

    /* Celda genérica: etiqueta izquierda, valor derecha */
    .data-table td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: .75rem;
        padding: .3rem 0;
        border: none;
        font-size: .875rem;
    }
    .data-table td[data-label]::before {
        content: attr(data-label);
        font-size: .7rem;
        font-weight: 600;
        color: var(--muted-foreground);
        text-transform: uppercase;
        letter-spacing: .05em;
        flex-shrink: 0;
        min-width: 5rem;
    }

    /* Título de la fila: grande, sin etiqueta */
    .data-table td.row-title {
        display: block;
        font-size: 1rem;
        font-weight: 600;
        padding-bottom: .625rem;
        border-bottom: 1px solid var(--border);
        margin-bottom: .125rem;
    }
    .data-table td.row-title::before { display: none; }

    /* Fila de acciones: botones alineados, sin etiqueta */
    .data-table td.row-actions {
        display: block;
        padding-top: .5rem;
        border-top: 1px solid var(--border);
        margin-top: .125rem;
    }
    .data-table td.row-actions::before { display: none; }

    /* Columnas secundarias ocultas en móvil */
    .data-table td.hide-mobile { display: none !important; }
}

@media (max-width: 640px) {
    .page-header  { padding: 0.625rem 0.875rem; flex-wrap: wrap; }
    .page-body    { padding: 0.875rem; }
    .modal-box    { margin: 0.5rem; max-height: 90vh; overflow-y: auto; }
    /* Grids inline con style attr también se apilan */
    div[style*="grid-template-columns:1fr 1fr"]       { display: flex !important; flex-direction: column; }
    div[style*="grid-template-columns: 1fr 1fr"]      { display: flex !important; flex-direction: column; }
    div[style*="grid-template-columns:1fr 1fr 1fr"]   { display: flex !important; flex-direction: column; }
}
