/* ============================================================
   CRM Jurídico — Estilo Portal del Cliente
   Mobile-first
   ============================================================ */

/* ── Variables ───────────────────────────────────────────── */
:root {
    --light: var(--cream);
    --gray: var(--muted);
}

/* ── Reset / Base ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
    margin: 0;
    background: var(--cream);
    color: var(--ink);
    font-size: 16px;
    /* Antes era justify; separaba palabras en labels y textos cortos. */
    text-align: left;
}

h1, h2, h3 {
    font-family: 'Libre Baskerville', Georgia, serif;
}

a { color: var(--navy); }

/* ── Portal Header ───────────────────────────────────────── */
.portal-header {
    background: var(--navy);
    color: white;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.portal-header-title {
    font-size: 1.125rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
}

.portal-header a {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.2s;
}

.portal-header a:hover { color: white; }

/* ── Portal Container ────────────────────────────────────── */
.portal-container {
    max-width: 700px;
    margin: 0 auto;
    padding: 15px;
}

/* ── Portal Card ─────────────────────────────────────────── */
.portal-card {
    background: white;
    border-radius: 10px;
    padding: 24px;
    margin-bottom: 15px;
    box-shadow: 0 2px 8px rgba(15, 42, 74, 0.08);
    border: 1px solid var(--line);
}

/* ── Caso Card ───────────────────────────────────────────── */
.caso-card {
    background: white;
    border-radius: 10px;
    padding: 24px;
    margin-bottom: 15px;
    box-shadow: 0 2px 8px rgba(15, 42, 74, 0.08);
    border-left: 4px solid var(--gold);
    border: 1px solid var(--line);
    border-left: 4px solid var(--gold);
}

.caso-card a {
    text-decoration: none;
    display: block;
}

.caso-card-title {
    color: var(--navy);
    font-size: 1.125rem;
    font-weight: bold;
    margin-bottom: 5px;
}

.caso-card-meta {
    color: var(--gray);
    font-size: 0.875rem;
    margin-bottom: 8px;
}

.caso-card-preview {
    font-size: 0.875rem;
    color: var(--gray);
    margin-top: 8px;
    line-height: 1.5;
}

.caso-card-link {
    display: inline-block;
    color: var(--navy);
    font-size: 0.875rem;
    font-weight: 600;
    margin-top: 8px;
    text-decoration: none;
}

.caso-card-link:hover { text-decoration: underline; }

/* ── Actualización Box ───────────────────────────────────── */
.actualizacion-box {
    background: rgba(15, 42, 74, 0.04);
    border-left: 4px solid var(--gold);
    padding: 15px;
    border-radius: 0 8px 8px 0;
    margin: 15px 0;
}

.actualizacion-title {
    font-weight: bold;
    color: var(--navy);
    margin-bottom: 8px;
    font-size: 1rem;
}

.actualizacion-text {
    font-size: 1rem;
    color: var(--ink);
    line-height: 1.6;
    white-space: pre-wrap;
}

.actualizacion-date {
    font-size: 0.8125rem;
    color: var(--gray);
    margin-top: 8px;
}

/* ── Badges ──────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 600;
    white-space: nowrap;
    line-height: 1.4;
}

/* badge-normal envuelve un texto libre (la etapa procesal actual, p.ej.
   "DEMANDA EJECUTIVA — Elaboración de demanda con título ejecutivo"), a
   diferencia de los demás badges (estado corto de una o dos palabras). El
   .badge base trae white-space:nowrap, pensado para esas etiquetas cortas;
   aquí lo revertimos para que el texto largo se acomode DENTRO de la
   tarjeta en vez de desbordarla. Reportado por Pablo 2026-07-27, reproducido
   2026-08-13: a 390px de ancho se salía 126px (lista) / 236px (detalle) del
   recuadro; a 768/1280 no ocurría porque la tarjeta ya tenía espacio de sobra. */
.badge-normal {
    white-space: normal;
    overflow-wrap: break-word;
    word-break: break-word;
}

.badge-activo     { background: rgba(15, 42, 74, 0.15); color: #0F2A4A; }
.badge-en_preparacion { background: rgba(201, 168, 96, 0.25); color: #7A5A0E; }
.badge-suspendido { background: rgba(108, 117, 125, 0.2);  color: var(--gray); }
.badge-concluido  { background: rgba(20, 108, 67,  0.15);  color: #146c43; }
.badge-perdido    { background: rgba(132, 32,  41,  0.15);  color: #842029; }

.badge-aldia     { background: rgba(25, 135, 84, 0.15); color: #146c43; }
.badge-pendiente { background: rgba(255, 193, 7, 0.25);  color: #7A5A0E; }
.badge-atrasado  { background: rgba(220, 53, 69, 0.15);  color: #842029; }

.badge-llamada      { background: rgba(13,  110, 253, 0.15); color: #1B4D8A; }
.badge-whatsapp     { background: rgba(25,  135, 84,  0.15); color: #146c43; }
.badge-email        { background: rgba(102, 16,  242, 0.12); color: #5b3fa0; }
.badge-reunion      { background: rgba(111, 66,  193, 0.15); color: #5B3FA0; }
.badge-nota_interna { background: rgba(108, 117, 125, 0.2);  color: var(--gray); }

.badge-lg {
    padding: 8px 18px;
    font-size: 1rem;
}

/* ── Portal Login ────────────────────────────────────────── */
.portal-login-page {
    min-height: 100vh;
    background: var(--navy);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(15, 42, 74, 0.15);
    width: 100%;
    max-width: 400px;
}

.login-logo {
    text-align: center;
    margin-bottom: 30px;
    font-size: 2.5rem;
}

.login-title {
    text-align: center;
    color: var(--navy);
    margin: 0 0 5px 0;
    font-size: 1.375rem;
}

.login-subtitle {
    text-align: center;
    color: var(--gray);
    margin-bottom: 25px;
    font-size: 0.875rem;
    line-height: 1.4;
}

.code-input {
    text-align: center;
    font-size: 1.375rem !important;
    letter-spacing: 4px;
    text-transform: uppercase;
    font-family: 'Courier New', monospace !important;
    font-weight: bold;
}

/* ── Form elements portal ────────────────────────────────── */
.form-group { margin-bottom: 15px; }

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.form-group input,
.form-group select,
.form-group textarea,
input[type="text"],
input[type="email"],
input[type="password"] {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(201, 168, 107, 0.2);
}

/* ── Buttons portal ──────────────────────────────────────── */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    transition: opacity 0.2s, background 0.2s;
    line-height: 1.4;
    vertical-align: middle;
    font-family: inherit;
}

.btn-primary {
    background: var(--gold);
    color: var(--navy);
    width: 100%;
    text-align: center;
    padding: 12px;
}

.btn-primary:hover { opacity: 0.88; }

.btn-sm {
    padding: 5px 12px;
    font-size: 0.875rem;
}

/* ── Alerts portal ───────────────────────────────────────── */
.alert {
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 1rem;
}

.alert-danger  { background: #fce7e7; color: #842029; border-left: 4px solid #842029; }
.alert-success { background: #e7f3ea; color: #146c43; border-left: 4px solid #146C43; }
.alert-info    { background: #e3ecfb; color: #1B4D8A; border-left: 4px solid #1b4d8a; }

/* ── Collapsed sections ──────────────────────────────────── */
.collapsed-toggle {
    width: 100%;
    text-align: left;
    background: #FAF7F2;
    border: 1px solid var(--line);
    padding: 12px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    color: var(--navy);
    font-size: 1rem;
    font-family: inherit;
    transition: background 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.collapsed-toggle:hover { background: #faf7f2; }

.collapsed-toggle::after {
    content: '▼';
    font-size: 0.75rem;
    transition: transform 0.2s;
}

.collapsed-toggle.open::after { transform: rotate(180deg); }

.collapsed-content { display: none; margin-top: 10px; }
.collapsed-content.open { display: block; }

/* ── Communication entry portal ──────────────────────────── */
.comm-entry {
    padding: 12px 0;
    border-bottom: 1px solid #faf7f2;
}

.comm-entry:last-child { border-bottom: none; }

.comm-meta {
    font-size: 0.8125rem;
    color: var(--gray);
    margin-bottom: 4px;
}

.comm-body { font-size: 1rem; color: var(--ink); line-height: 1.5; white-space: pre-wrap; }

/* ── Section headings ────────────────────────────────────── */
.portal-section-title {
    color: var(--navy);
    font-size: 1.125rem;
    font-weight: bold;
    margin: 0 0 15px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--line);
}

/* ── Welcome card ────────────────────────────────────────── */
.welcome-card {
    background: var(--navy);
    color: white;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.welcome-card h2 {
    margin: 0 0 4px 0;
    font-size: 1.375rem;
}

.welcome-card p {
    margin: 0;
    font-size: 0.875rem;
    opacity: 0.8;
}

/* ── Empty state ─────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 30px 20px;
    color: var(--gray);
    font-size: 1rem;
}

/* ── Detail meta grid ────────────────────────────────────── */
.meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 20px;
    margin-bottom: 15px;
}

.meta-item label {
    display: block;
    font-size: 0.75rem;
    color: var(--gray);
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 2px;
}

.meta-item span {
    font-size: 1rem;
    color: var(--ink);
}

/* ── Back link ───────────────────────────────────────────── */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--navy);
    text-decoration: none;
    font-size: 0.875rem;
    margin-bottom: 15px;
    font-weight: 600;
}

.back-link:hover { text-decoration: underline; }

/* ── Portal Footer ───────────────────────────────────────── */
.portal-footer {
    text-align: center;
    padding: 20px;
    color: var(--gray);
    font-size: 0.75rem;
    border-top: 1px solid var(--line);
    margin-top: 20px;
    line-height: 1.5;
}

/* ── Login footer ────────────────────────────────────────── */
.login-footer {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.75rem;
    text-align: center;
    margin-top: 20px;
    max-width: 400px;
    line-height: 1.5;
}

/* ── Resumen de sus casos (RV-DIR-5 f1, 2026-10-21) ──────── */
.table-responsive { overflow-x: auto; }

.resumen-cifras {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.resumen-cifra {
    background: var(--cream);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.resumen-num {
    font-size: 2rem;
    font-weight: 700;
    color: var(--navy);
    line-height: 1.1;
}

.resumen-etq {
    font-size: 0.8125rem;
    color: var(--gray);
}

.resumen-tabla {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.resumen-tabla th {
    text-align: left;
    font-size: 0.75rem;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: .03em;
    padding: 8px 8px;
    border-bottom: 2px solid var(--line);
}

.resumen-tabla td {
    padding: 10px 8px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
    overflow-wrap: break-word;
}

.resumen-tabla td a { color: var(--navy); font-weight: 600; }
.resumen-tabla tr.resumen-cerrado td { color: var(--gray); }
.resumen-exp { font-family: 'Courier New', monospace; }
.resumen-tenue { color: var(--gray); }

.resumen-nuevo {
    display: inline-block;
    background: rgba(201, 168, 96, 0.25);
    color: #7A5A0E;
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 0.75rem;
    font-weight: 600;
}

.resumen-nota {
    font-size: 0.8125rem;
    color: var(--gray);
    margin: 12px 0 0;
}

/* En el teléfono cada caso es una tarjetita: una tabla de cinco columnas no
   cabe en 390 px y deslizarla de lado esconde justo la fecha que importa. */
@media (max-width: 600px) {
    .resumen-tabla thead { display: none; }
    .resumen-tabla, .resumen-tabla tbody, .resumen-tabla tr, .resumen-tabla td { display: block; width: 100%; }
    .resumen-tabla tr {
        border: 1px solid var(--line);
        border-radius: 8px;
        padding: 6px 10px;
        margin-bottom: 10px;
    }
    .resumen-tabla td {
        border-bottom: none;
        padding: 4px 0;
        display: grid;
        grid-template-columns: 112px minmax(0, 1fr);
        gap: 8px;
    }
    .resumen-tabla td::before {
        content: attr(data-label);
        font-size: 0.75rem;
        color: var(--gray);
        text-transform: uppercase;
        font-weight: 600;
    }
}

/* ── Responsive ──────────────────────────────────────────── */
@media (min-width: 768px) {
    .resumen-cifras { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .portal-container { padding: 30px; }
    .meta-grid { grid-template-columns: repeat(3, 1fr); }
}
