/* ============================================================
   CRM Jurídico — Estilo Principal (Despacho)
   ============================================================ */

/* ── Variables ───────────────────────────────────────────── */
:root {
    --navy:   #0F2A4A;
    --gold:   #C9A86B;
    --cream:  #FAF7F2;
    --light:  #FAF7F2;
    --white:  #ffffff;
    --gray:   #556072;
    --ink:    #1A2330;
    --line:   #E5DED1;
    --success:#2d8a4f;
    --danger: #a03232;
    --warning:#c28214;
}

/* ── 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);
    text-align: justify;
}

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

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

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 240px;
    height: 100vh;
    background: var(--navy);
    color: white;
    overflow-y: auto;
    z-index: 900;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.sidebar-logo {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    height: calc(100% - 80px);
    overflow-y: auto;
}

.sidebar-nav li { width: 100%; }

.sidebar-nav a {
    display: block;
    padding: 12px 20px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.sidebar-nav a.active {
    background: rgba(201, 168, 107, 0.2);
    color: var(--gold);
    border-left: 3px solid var(--gold);
}

/* ── Main Content ────────────────────────────────────────── */
.main-content {
    margin-left: 240px;
    padding: 30px;
    min-height: 100vh;
}

/* ── ExpDig layout (main-wrap / topbar / content / footer) ── */
.main-wrap {
    margin-left: 240px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: var(--navy);
    color: white;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 800;
}

.topbar-title {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 1rem;
    white-space: nowrap;
}

.topbar-search {
    margin-left: auto;
}

.topbar-search-input {
    padding: 6px 14px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 6px;
    background: rgba(255,255,255,0.1);
    color: white;
    font-size: 0.85rem;
    width: 200px;
}

.topbar-search-input::placeholder { color: rgba(255,255,255,0.5); }
.topbar-search-input:focus { outline: none; border-color: var(--gold); background: rgba(255,255,255,0.15); }

.hamburger {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 4px 8px;
}

.content {
    flex: 1;
    padding: 30px;
}

.app-footer {
    padding: 16px 30px;
    text-align: center;
    font-size: 0.8rem;
    color: var(--gray);
    border-top: 1px solid var(--line);
}

/* ── Top Bar ─────────────────────────────────────────────── */
.top-bar {
    background: white;
    padding: 15px 30px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: -30px -30px 30px -30px;
}

/* ── Page Header ─────────────────────────────────────────── */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.page-header h1 {
    margin: 0;
    font-size: 1.6rem;
    color: var(--navy);
}

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

.card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--navy);
    margin: 0 0 15px 0;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
}

/* ── Stats Grid ──────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.stat-card {
    background: white;
    border-radius: 10px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(15, 42, 74, 0.08);
    text-align: center;
    border-top: 3px solid var(--gold);
    border: 1px solid var(--line);
    border-top: 3px solid var(--gold);
}

.stat-number {
    font-size: 2rem;
    font-weight: bold;
    color: var(--navy);
    line-height: 1.2;
}

.stat-label {
    color: var(--gray);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 4px;
}

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

.btn:hover { opacity: 0.88; }

.btn-primary {
    background: var(--gold);
    color: var(--navy);
}

.btn-primary:hover {
    background: #B4935A;
    color: var(--navy);
    opacity: 1;
}

.btn-gold {
    background: var(--gold);
    color: var(--navy);
}

.btn-gold:hover {
    background: #B4935A;
    color: var(--navy);
    opacity: 1;
}

.btn-navy {
    background: var(--navy);
    color: white;
}

.btn-navy:hover {
    background: #0a1e35;
    color: white;
    opacity: 1;
}

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

.btn-danger:hover {
    background: #b02a37;
    color: white;
    opacity: 1;
}

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

.btn-secondary {
    background: var(--gray);
    color: white;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.8rem;
}

.btn-outline-primary {
    background: transparent;
    color: var(--navy);
    border: 2px solid var(--navy);
}

.btn-outline-primary:hover {
    background: var(--navy);
    color: white;
    opacity: 1;
}

.btn-outline-danger {
    background: transparent;
    color: var(--danger);
    border: 2px solid var(--danger);
}

.btn-outline-danger:hover {
    background: var(--danger);
    color: white;
    opacity: 1;
}

/* ── Tables ──────────────────────────────────────────────── */
.table-responsive { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
}

table th {
    background: #F3EEE4;
    color: var(--navy);
    padding: 10px 12px;
    text-align: left;
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: .04em;
}

table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    font-size: 0.9rem;
    vertical-align: middle;
}

table tr:last-child td { border-bottom: none; }

table tr:hover td { background: rgba(15, 42, 74, 0.03); }

.row-concluido { background: rgba(25, 135, 84, 0.05); }
.row-perdido   { background: rgba(220, 53, 69, 0.05); }

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

/* Estado de caso */
.badge-activo     { background: rgba(26,  58,  92,  0.15); color: var(--navy); }
.badge-suspendido { background: rgba(108, 117, 125, 0.2);  color: #495057; }
.badge-concluido  { background: rgba(20, 108, 67,  0.15);  color: #146c43; }
.badge-perdido    { background: rgba(132, 32,  41,  0.15);  color: #842029; }

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

/* Prioridad */
.badge-alta   { background: rgba(220, 53,  69,  0.15); color: #842029; }
.badge-normal { background: rgba(13,  110, 253, 0.15); color: #084298; }
.badge-baja   { background: rgba(108, 117, 125, 0.2);  color: #495057; }

/* Tipo de comunicación */
.badge-llamada        { background: rgba(13,  110, 253, 0.15); color: #084298; }
.badge-whatsapp       { background: rgba(25,  135, 84,  0.15); color: #146c43; }
.badge-email          { background: rgba(102, 16,  242, 0.12); color: #4a0ca4; }
.badge-reunion        { background: rgba(111, 66,  193, 0.15); color: #432874; }
.badge-nota_interna   { background: rgba(108, 117, 125, 0.2);  color: #495057; }

/* Portal */
.badge-portal-activo   { background: rgba(25, 135, 84, 0.15); color: #146c43; }
.badge-portal-inactivo { background: rgba(108, 117, 125, 0.2); color: #495057; }

/* ── Tabs ────────────────────────────────────────────────── */
.tabs-nav {
    display: flex;
    border-bottom: 2px solid var(--line);
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.tab-link {
    padding: 10px 20px;
    cursor: pointer;
    text-decoration: none;
    color: var(--gray);
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    font-size: 0.9rem;
    transition: color 0.2s, border-color 0.2s;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: inherit;
}

.tab-link:hover { color: var(--navy); }

.tab-link.active {
    color: var(--navy);
    border-bottom-color: var(--gold);
    font-weight: bold;
}

.tab-panel        { display: none; }
.tab-panel.active { display: block; }

/* ── Forms ───────────────────────────────────────────────── */
.form-group { margin-bottom: 15px; }

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    font-size: 0.78rem;
    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"],
input[type="date"],
input[type="datetime-local"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: white;
}

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

textarea { resize: vertical; min-height: 80px; }

.form-note {
    font-size: 0.8rem;
    color: var(--gray);
    margin-top: 4px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.form-check input[type="checkbox"] {
    width: auto;
    margin: 0;
}

/* ── Search Bar ──────────────────────────────────────────── */
.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.search-bar input,
.search-bar select {
    flex: 1;
    min-width: 150px;
}

/* ── Progress Bar ────────────────────────────────────────── */
.progress {
    height: 10px;
    background: var(--line);
    border-radius: 5px;
    overflow: hidden;
    margin: 8px 0;
}

.progress-bar {
    height: 100%;
    background: var(--navy);
    border-radius: 5px;
    transition: width 0.3s ease;
    min-width: 2px;
}

.progress-bar.bg-success { background: var(--success); }
.progress-bar.bg-warning { background: var(--warning); }
.progress-bar.bg-danger  { background: var(--danger); }

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

.alert-success { background: #d1e7dd; color: #0a3622; border-left: 4px solid var(--success); }
.alert-danger  { background: #f8d7da; color: #58151c; border-left: 4px solid var(--danger); }
.alert-warning { background: #fff3cd; color: #664d03; border-left: 4px solid var(--warning); }
.alert-info    { background: #cff4fc; color: #055160; border-left: 4px solid #0dcaf0; }

/* ── Quick Actions ───────────────────────────────────────── */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.quick-btn {
    padding: 20px;
    text-align: center;
    border-radius: 10px;
    background: white;
    border: 1px solid var(--line);
    color: var(--navy);
    text-decoration: none;
    font-weight: bold;
    font-size: 0.9rem;
    transition: background 0.2s, color 0.2s;
    cursor: pointer;
    display: block;
}

.quick-btn:hover {
    background: var(--gold);
    color: var(--navy);
    border-color: var(--gold);
}

.quick-btn .quick-icon {
    font-size: 1.6rem;
    display: block;
    margin-bottom: 8px;
}

/* ── Two-column layout ───────────────────────────────────── */
.two-col {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

.two-col-equal {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* ── Breadcrumb ──────────────────────────────────────────── */
.breadcrumb {
    font-size: 0.85rem;
    color: var(--gray);
    margin-bottom: 15px;
}

.breadcrumb a { color: var(--navy); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .sep { margin: 0 6px; color: var(--line); }

/* ── Info Box ────────────────────────────────────────────── */
.info-box {
    background: rgba(15, 42, 74, 0.06);
    border-left: 4px solid var(--navy);
    padding: 12px 15px;
    border-radius: 0 8px 8px 0;
    font-size: 0.9rem;
    color: var(--navy);
    margin: 15px 0;
}

/* ── Client Portal Code Box ──────────────────────────────── */
.codigo-box {
    background: var(--light);
    border: 2px dashed var(--navy);
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    margin: 12px 0;
}

.codigo-box .codigo-value {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--navy);
    letter-spacing: 4px;
    font-family: 'Courier New', monospace;
}

/* ── Section Headers ─────────────────────────────────────── */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.section-header h2,
.section-header h3 {
    margin: 0;
    color: var(--navy);
}

/* ── Task item ───────────────────────────────────────────── */
.task-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}

.task-item:last-child { border-bottom: none; }

.task-item.completada {
    opacity: 0.55;
}

.task-item.completada .task-desc {
    text-decoration: line-through;
}

.task-desc { flex: 1; font-size: 0.9rem; }

/* ── Vencida section ─────────────────────────────────────── */
.section-vencidas {
    background: #fff5f5;
    border-radius: 10px;
    padding: 15px;
    border: 1px solid #f8d7da;
    margin-bottom: 20px;
}

.section-vencidas .section-label {
    color: var(--danger);
    font-weight: bold;
    margin-bottom: 10px;
}

/* ── Honorarios progress ─────────────────────────────────── */
.honorarios-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin: 15px 0;
}

.honorarios-stat {
    text-align: center;
    padding: 12px;
    background: var(--light);
    border-radius: 10px;
}

.honorarios-stat .h-number {
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--navy);
}

.honorarios-stat .h-label {
    font-size: 0.75rem;
    color: var(--gray);
    text-transform: uppercase;
}

/* ── Empty state ─────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--gray);
}

.empty-state .empty-icon { font-size: 3rem; margin-bottom: 10px; }

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

/* ── Sidebar overlay (mobile) ────────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 898;
}

/* ── Hamburger ───────────────────────────────────────────── */
.hamburger {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1000;
    background: var(--navy);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
}

/* ── Dropdown ────────────────────────────────────────────── */
.dropdown { position: relative; display: inline-block; }

.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    background: white;
    border: 1px solid var(--line);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(15, 42, 74, 0.08);
    min-width: 160px;
    z-index: 500;
}

.dropdown-menu.show { display: block; }

.dropdown-item {
    display: block;
    padding: 8px 16px;
    color: var(--ink);
    text-decoration: none;
    font-size: 0.9rem;
    cursor: pointer;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
}

.dropdown-item:hover { background: var(--light); }

/* ── Inline form bar ─────────────────────────────────────── */
.inline-form {
    background: var(--light);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

.inline-form-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.inline-form-row .form-group { margin-bottom: 0; flex: 1; min-width: 130px; }

/* ── Communication entry ─────────────────────────────────── */
.comm-entry {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
}

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

.comm-meta {
    font-size: 0.8rem;
    color: var(--gray);
    white-space: nowrap;
}

.comm-body { flex: 1; font-size: 0.9rem; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
    .hamburger { display: block; }

    .sidebar {
        transform: translateX(-100%);
    }

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

    body.sidebar-open .sidebar-overlay {
        display: block;
    }

    .main-wrap {
        margin-left: 0;
    }

    .main-content {
        margin-left: 0;
        padding: 20px 15px;
        padding-top: 60px;
    }

    .two-col,
    .two-col-equal {
        grid-template-columns: 1fr;
    }

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

    .honorarios-stats {
        grid-template-columns: 1fr;
    }

    .search-bar { flex-direction: column; }
    .search-bar input,
    .search-bar select { min-width: 100%; }

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

    table th, table td { padding: 8px; font-size: 0.82rem; }

    .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .quick-actions { grid-template-columns: 1fr; }
}
