/* ==========================================================================
   LexDesk - Bespoke Modern Legal-Tech Design System
   Engineered with UI-UX-Pro-Max, Apple HIG & Emil Kowalski Motion Principles
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
    --bg-main: #070b14;
    --bg-body: #070b14;
    --bg-card: #0d1527;
    --bg-card-hover: #131f38;
    --bg-surface-2: #162442;
    --bg-input: #101a2f;
    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.18);
    --border-focus: #38bdf8;
    --border-glow: rgba(56, 189, 248, 0.25);
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    
    --primary: #38bdf8;
    --primary-hover: #0ea5e9;
    --primary-gradient: linear-gradient(135deg, #0284c7 0%, #38bdf8 100%);
    --primary-glow: rgba(56, 189, 248, 0.25);
    
    --gold: #f59e0b;
    --gold-bg: rgba(245, 158, 11, 0.12);
    --gold-border: rgba(245, 158, 11, 0.3);
    
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.12);
    --success-border: rgba(16, 185, 129, 0.3);
    
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.12);
    --warning-border: rgba(245, 158, 11, 0.3);
    
    --danger: #f43f5e;
    --danger-bg: rgba(244, 63, 94, 0.12);
    --danger-border: rgba(244, 63, 94, 0.3);
    
    --purple: #a855f7;
    --purple-bg: rgba(168, 85, 247, 0.12);
    --purple-border: rgba(168, 85, 247, 0.3);
    
    --cyan: #06b6d4;
    --cyan-bg: rgba(6, 182, 212, 0.12);
    --cyan-border: rgba(6, 182, 212, 0.3);
    
    --radius-xs: 6px;
    --radius-sm: 10px;
    --radius: 14px;
    --radius-lg: 20px;
    --radius-xl: 26px;
    --radius-full: 9999px;
    
    --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.5), inset 0 1px 0 0 rgba(255, 255, 255, 0.05);
    --shadow-lg: 0 20px 40px -8px rgba(0, 0, 0, 0.65), inset 0 1px 0 0 rgba(255, 255, 255, 0.08);
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 15px;
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: var(--font);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: radial-gradient(circle at 50% 0%, #101b33 0%, #070b14 60%);
    background-attachment: fixed;
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 84px);
}

@media (min-width: 900px) {
    body {
        padding-bottom: 32px;
    }
}

a {
    color: inherit;
    text-decoration: none;
    transition: color 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ==========================================================================
   SVG ICONS (Crisp Vector Standard)
   ========================================================================== */
.svg-icon {
    display: inline-block;
    vertical-align: -0.15em;
    flex-shrink: 0;
    stroke-width: 2;
    transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1), stroke 0.18s ease;
}

.svg-icon.icon-xs { width: 12px; height: 12px; }
.svg-icon.icon-sm { width: 14px; height: 14px; }
.svg-icon.icon-md { width: 18px; height: 18px; }
.svg-icon.icon-lg { width: 22px; height: 22px; }
.svg-icon.icon-xl { width: 28px; height: 28px; }

/* ==========================================================================
   TOP HEADER & DESKTOP NAV
   ========================================================================== */
.top-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(7, 11, 20, 0.82);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: var(--primary-gradient);
    color: #060a12;
    font-weight: 800;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 20px var(--primary-glow), inset 0 1px 0 rgba(255,255,255,0.4);
    letter-spacing: -0.5px;
}

.brand-title {
    font-size: 17px;
    font-weight: 800;
    letter-spacing: -0.4px;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 6px;
}

.brand-badge {
    font-size: 10px;
    padding: 2px 7px;
    border-radius: var(--radius-full);
    background: rgba(56, 189, 248, 0.15);
    color: var(--primary);
    border: 1px solid rgba(56, 189, 248, 0.3);
    font-weight: 700;
    letter-spacing: 0.5px;
}

.brand-sub {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

.desktop-nav {
    display: none;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.03);
    padding: 4px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

@media (min-width: 900px) {
    .desktop-nav {
        display: flex;
    }
}

.nav-link {
    padding: 7px 14px;
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 13.5px;
    font-weight: 500;
    transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    gap: 7px;
}

.nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.06);
}

.nav-link.active {
    color: #fff;
    background: rgba(56, 189, 248, 0.15);
    border: 1px solid rgba(56, 189, 248, 0.3);
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* ==========================================================================
   LAYOUT & CONTAINER
   ========================================================================== */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 16px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px;
    flex-wrap: wrap;
    gap: 14px;
}

.page-title {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: #fff;
}

.page-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 3px;
    font-weight: 500;
}

/* ==========================================================================
   CARDS & PANELS (Surface Elevation)
   ========================================================================== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 18px;
    box-shadow: var(--shadow-card);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
}

.card:hover {
    border-color: var(--border-hover);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 9px;
    letter-spacing: -0.2px;
}

/* ==========================================================================
   BENTO GRID & KPI CARDS (Linear / Apple Elegance)
   ========================================================================== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    margin-bottom: 22px;
}

@media (min-width: 900px) {
    .kpi-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 16px;
    }
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: var(--shadow-card);
    position: relative;
    overflow: hidden;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: transparent;
    transition: background 0.2s ease;
}

.kpi-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-hover);
}

.kpi-card.kpi-cyan::before   { background: var(--primary); }
.kpi-card.kpi-amber::before  { background: var(--gold); }
.kpi-card.kpi-emerald::before{ background: var(--success); }
.kpi-card.kpi-purple::before { background: var(--purple); }

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

.kpi-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.kpi-icon-badge {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.kpi-value {
    font-size: 24px;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.03em;
    line-height: 1.15;
    font-feature-settings: "cv02", "cv03", "cv04", "cv11", "tnum";
    font-variant-numeric: tabular-nums;
}

.kpi-sub {
    font-size: 11.5px;
    color: var(--text-dim);
    margin-top: 6px;
    font-weight: 500;
}

/* ==========================================================================
   BUTTONS (Tactile & Accessible 44px+)
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    white-space: nowrap;
    text-align: center;
    min-height: 42px;
    font-family: inherit;
}

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

.btn-sm {
    padding: 6px 14px;
    font-size: 12.5px;
    border-radius: 8px;
    min-height: 34px;
}

.btn-primary {
    background: var(--primary-gradient);
    color: #060a12;
    box-shadow: 0 2px 10px rgba(56, 189, 248, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.btn-primary:hover {
    filter: brightness(1.1);
    box-shadow: 0 4px 18px rgba(56, 189, 248, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.4);
    color: #060a12;
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-main);
    border: 1px solid var(--border);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--border-hover);
    color: #fff;
    transform: translateY(-1px);
}

.btn-success {
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
    color: #fff;
    box-shadow: 0 2px 10px rgba(16, 185, 129, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-success:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.btn-danger {
    background: linear-gradient(135deg, #e11d48 0%, #f43f5e 100%);
    color: #fff;
    box-shadow: 0 2px 10px rgba(244, 63, 94, 0.25);
}

.btn-danger:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.btn-whatsapp {
    background: linear-gradient(135deg, #16a34a 0%, #22c55e 100%);
    color: #fff;
    font-weight: 700;
    box-shadow: 0 2px 10px rgba(34, 197, 94, 0.25);
}

.btn-whatsapp:hover {
    filter: brightness(1.1);
    color: #fff;
    transform: translateY(-1px);
}

/* ==========================================================================
   FORMS & INPUTS (iOS-Safe 16px, High Contrast)
   ========================================================================== */
.form-group {
    margin-bottom: 18px;
}

.form-label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 7px;
    letter-spacing: -0.1px;
}

.form-control {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: #fff;
    padding: 12px 14px;
    font-size: 15px;
    font-family: inherit;
    transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.25);
}

.form-control:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--primary-glow), inset 0 1px 2px rgba(0,0,0,0.2);
    background: var(--bg-card);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 16px;
    padding-right: 40px;
}

textarea.form-control {
    min-height: 90px;
    resize: vertical;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

@media (min-width: 640px) {
    .form-row-2 {
        grid-template-columns: repeat(2, 1fr);
    }
    .form-row-3 {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ==========================================================================
   BADGES & PILLS
   ========================================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 9px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.02em;
}

.badge-amber   { background: var(--gold-bg); color: #fbbf24; border: 1px solid var(--gold-border); }
.badge-blue    { background: rgba(56, 189, 248, 0.12); color: var(--primary); border: 1px solid rgba(56, 189, 248, 0.28); }
.badge-purple  { background: var(--purple-bg); color: #c084fc; border: 1px solid var(--purple-border); }
.badge-emerald { background: var(--success-bg); color: #34d399; border: 1px solid var(--success-border); }
.badge-orange  { background: rgba(249, 115, 22, 0.12); color: #fb923c; border: 1px solid rgba(249, 115, 22, 0.28); }
.badge-rose    { background: var(--danger-bg); color: #fb7185; border: 1px solid var(--danger-border); }
.badge-slate   { background: rgba(148, 163, 184, 0.12); color: var(--text-muted); border: 1px solid rgba(148, 163, 184, 0.25); }
.badge-cyan    { background: var(--cyan-bg); color: #22d3ee; border: 1px solid var(--cyan-border); }

/* ==========================================================================
   LISTS & DATA TABLES
   ========================================================================== */
.list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    margin-bottom: 9px;
    transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    gap: 14px;
}

.list-item:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
    transform: translateY(-1px);
}

.data-table-container {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-card);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 13px;
}

.data-table th {
    background: rgba(13, 21, 39, 0.95);
    color: var(--text-muted);
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 13px 18px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 13px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    color: var(--text-main);
    font-feature-settings: "cv02", "cv03", "cv04", "cv11", "tnum";
    font-variant-numeric: tabular-nums;
}

.data-table tr:hover td {
    background: rgba(255, 255, 255, 0.03);
}

/* ==========================================================================
   ALERTS
   ========================================================================== */
.alert {
    padding: 13px 18px;
    border-radius: var(--radius);
    font-size: 13.5px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
    font-weight: 500;
    box-shadow: var(--shadow-card);
}

.alert-danger {
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
    color: #fca5a5;
}

.alert-success {
    background: var(--success-bg);
    border: 1px solid var(--success-border);
    color: #6ee7b7;
}

.alert-warning {
    background: var(--warning-bg);
    border: 1px solid var(--warning-border);
    color: #fde68a;
}

/* ==========================================================================
   MOBILE FLOATING DOCK & FAB
   ========================================================================== */
.bottom-nav {
    position: fixed;
    bottom: 12px;
    left: 14px;
    right: 14px;
    max-width: 480px;
    margin: 0 auto;
    z-index: 60;
    background: rgba(13, 21, 39, 0.88);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 22px;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 6px 10px;
    height: 62px;
}

@media (min-width: 900px) {
    .bottom-nav {
        display: none;
    }
}

.bottom-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--text-muted);
    font-size: 10.5px;
    font-weight: 600;
    flex: 1;
    min-height: 48px;
    transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    border-radius: 14px;
}

.bottom-tab:hover, .bottom-tab.active {
    color: var(--primary);
}

.bottom-tab.active {
    background: rgba(56, 189, 248, 0.1);
}

.bottom-tab-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.fab-btn {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    background: var(--primary-gradient);
    color: #060a12;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.3);
    cursor: pointer;
    box-shadow: 0 4px 20px var(--primary-glow);
    margin-top: -20px;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.fab-btn:active {
    transform: scale(0.92);
}

/* ==========================================================================
   BOTTOM SHEET / MODAL
   ========================================================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    align-items: flex-end;
    justify-content: center;
}

@media (min-width: 640px) {
    .modal-overlay {
        align-items: center;
    }
}

.modal-overlay.active {
    display: flex;
}

.bottom-sheet {
    background: var(--bg-card);
    width: 100%;
    max-width: 520px;
    border-radius: 28px 28px 0 0;
    border: 1px solid var(--border);
    padding: 22px 22px calc(env(safe-area-inset-bottom, 0px) + 26px);
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

@media (min-width: 640px) {
    .bottom-sheet {
        border-radius: var(--radius-xl);
        padding: 26px;
        animation: popIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    }
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

@keyframes popIn {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

.sheet-handle {
    width: 40px;
    height: 4px;
    background: rgba(255, 255, 255, 0.22);
    border-radius: var(--radius-full);
    margin: 0 auto 18px;
}

@media (min-width: 640px) {
    .sheet-handle {
        display: none;
    }
}

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

.sheet-title {
    font-size: 17px;
    font-weight: 800;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sheet-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.sheet-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 18px 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.sheet-item:hover {
    background: rgba(56, 189, 248, 0.1);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(56, 189, 248, 0.15);
}

.sheet-icon-wrapper {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    border: 1px solid var(--border);
}
