/* ================================================================
   JurisMate Design System v1.0
   Centralized variables, components, and animations
   ================================================================ */

/* Google Fonts — Inter (all pages) */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

/* ── 1. CSS Custom Properties ── */
:root {
    /* Primary Palette */
    --jm-primary: #2563eb;
    --jm-primary-dark: #1e40af;
    --jm-primary-light: #dbeafe;
    --jm-primary-hover: #1d4ed8;

    /* Neutral Palette */
    --jm-bg: #f4f7fb;
    --jm-card: #ffffff;
    --jm-text: #1e293b;
    --jm-text-muted: #64748b;
    --jm-text-light: #94a3b8;
    --jm-border: #e2e8f0;
    --jm-border-light: #f1f5f9;

    /* Semantic */
    --jm-success: #16a34a;
    --jm-success-bg: #dcfce7;
    --jm-danger: #dc2626;
    --jm-danger-bg: #fef2f2;
    --jm-warning: #f59e0b;
    --jm-warning-bg: #fef3c7;

    /* Typography */
    --jm-font: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* Spacing */
    --jm-radius-sm: 8px;
    --jm-radius-md: 12px;
    --jm-radius-lg: 16px;
    --jm-radius-xl: 24px;
    --jm-radius-full: 999px;

    /* Shadows */
    --jm-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --jm-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --jm-shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.1);
    --jm-shadow-xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --jm-shadow-primary: 0 8px 24px rgba(37, 99, 235, 0.25);

    /* Transitions */
    --jm-ease: cubic-bezier(0.4, 0, 0.2, 1);
    --jm-duration: 0.2s;
}

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

body {
    font-family: var(--jm-font);
    background-color: var(--jm-bg);
    margin: 0;
    padding: 0;
    color: var(--jm-text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── 3. Button Components ── */
.jm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--jm-radius-full);
    font-family: var(--jm-font);
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all var(--jm-duration) var(--jm-ease);
    line-height: 1.4;
}

.jm-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.jm-btn-primary {
    background: var(--jm-primary);
    color: white;
    box-shadow: var(--jm-shadow-sm);
}

.jm-btn-primary:hover:not(:disabled) {
    background: var(--jm-primary-hover);
    box-shadow: var(--jm-shadow-primary);
    transform: translateY(-1px);
}

.jm-btn-secondary {
    background: white;
    color: var(--jm-text);
    border: 1.5px solid var(--jm-border);
}

.jm-btn-secondary:hover:not(:disabled) {
    background: var(--jm-bg);
    border-color: var(--jm-primary);
    color: var(--jm-primary);
}

.jm-btn-ghost {
    background: transparent;
    color: var(--jm-text-muted);
    padding: 8px 12px;
}

.jm-btn-ghost:hover {
    color: var(--jm-primary);
    background: var(--jm-primary-light);
}

/* ── 4. Skeleton Loading ── */
.jm-skeleton {
    background: linear-gradient(90deg,
            var(--jm-border-light) 25%,
            #e8ecf1 37%,
            var(--jm-border-light) 63%);
    background-size: 400% 100%;
    animation: jm-shimmer 1.4s ease infinite;
    border-radius: var(--jm-radius-sm);
}

.jm-skeleton-text {
    height: 14px;
    margin-bottom: 8px;
    width: 80%;
}

.jm-skeleton-text.short {
    width: 40%;
}

.jm-skeleton-text.medium {
    width: 60%;
}

.jm-skeleton-text.full {
    width: 100%;
}

.jm-skeleton-circle {
    border-radius: 50%;
}

.jm-skeleton-card {
    padding: 20px;
    border-radius: var(--jm-radius-lg);
    border: 1px solid var(--jm-border-light);
    background: var(--jm-card);
}

/* Stats skeleton */
.jm-skeleton-stat {
    height: 80px;
    border-radius: var(--jm-radius-lg);
}

/* Table row skeleton */
.jm-skeleton-row {
    display: grid;
    grid-template-columns: 1.2fr 1fr 0.8fr 1fr 0.6fr 0.8fr;
    gap: 12px;
    padding: 12px 10px;
    border-bottom: 1px solid var(--jm-border-light);
    align-items: center;
}

.jm-skeleton-row .jm-skeleton-text {
    width: 100%;
    height: 12px;
    margin: 0;
}

/* ── 5. Modal Base ── */
.jm-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(8px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
}

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

.jm-modal-card {
    background: var(--jm-card);
    width: 90%;
    max-width: 500px;
    border-radius: var(--jm-radius-xl);
    padding: 28px;
    box-shadow: var(--jm-shadow-xl);
    animation: jm-modal-in 0.25s var(--jm-ease);
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.jm-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--jm-border-light);
    border: none;
    color: var(--jm-text-muted);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--jm-duration) var(--jm-ease);
}

.jm-modal-close:hover {
    background: var(--jm-danger-bg);
    color: var(--jm-danger);
}

/* Quick-create modal form fields */
.jm-form-group {
    margin-bottom: 16px;
}

.jm-form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
}

.jm-form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--jm-border);
    border-radius: var(--jm-radius-sm);
    font-family: var(--jm-font);
    font-size: 14px;
    outline: none;
    transition: border-color var(--jm-duration) var(--jm-ease), box-shadow var(--jm-duration) var(--jm-ease);
    box-sizing: border-box;
}

.jm-form-input:focus {
    border-color: var(--jm-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.jm-form-select {
    appearance: none;
    width: 100%;
    padding: 10px 32px 10px 12px;
    border: 1.5px solid var(--jm-border);
    border-radius: var(--jm-radius-sm);
    font-family: var(--jm-font);
    font-size: 14px;
    background-color: white;
    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='%2364748b' stroke-width='2'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 16px;
    outline: none;
    transition: border-color var(--jm-duration) var(--jm-ease);
    cursor: pointer;
}

.jm-form-select:focus {
    border-color: var(--jm-primary);
}

/* ── 6. Toast Notifications ── */
.jm-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--jm-text);
    color: white;
    padding: 12px 24px;
    border-radius: var(--jm-radius-full);
    font-family: var(--jm-font);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--jm-shadow-lg);
    z-index: 9999;
    transition: transform 0.3s var(--jm-ease);
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}

.jm-toast.active {
    transform: translateX(-50%) translateY(0);
}

.jm-toast.success {
    background: var(--jm-success);
}

.jm-toast.error {
    background: var(--jm-danger);
}

/* ── 7. Animations ── */
@keyframes jm-shimmer {
    0% {
        background-position: -400% 0;
    }

    100% {
        background-position: 400% 0;
    }
}

@keyframes jm-spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes status-pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(var(--status-rgb), 0.7);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(var(--status-rgb), 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(var(--status-rgb), 0);
    }
}

@keyframes jm-fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes jm-slide-up {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes jm-modal-in {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(8px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes jm-stagger-in {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── 8. Utility Classes ── */
.uppercase-input {
    text-transform: uppercase;
}

/* Autocomplete Highlighting */
.ac-highlight {
    font-weight: 800;
    color: var(--jm-primary);
    text-decoration: underline;
}

.jm-fade-in {
    animation: jm-fade-in 0.3s var(--jm-ease);
}

.jm-slide-up {
    animation: jm-slide-up 0.4s var(--jm-ease);
}

/* Staggered entrance for lists/grids */
.jm-stagger>* {
    animation: jm-stagger-in 0.4s var(--jm-ease) both;
}

.jm-stagger>*:nth-child(1) {
    animation-delay: 0s;
}

.jm-stagger>*:nth-child(2) {
    animation-delay: 0.06s;
}

.jm-stagger>*:nth-child(3) {
    animation-delay: 0.12s;
}

.jm-stagger>*:nth-child(4) {
    animation-delay: 0.18s;
}

.jm-stagger>*:nth-child(5) {
    animation-delay: 0.24s;
}

/* Premium table row hover */
.jm-table-hover tr {
    transition: all var(--jm-duration) var(--jm-ease);
}

.jm-table-hover tbody tr:hover {
    background: linear-gradient(90deg, var(--jm-primary-light) 0%, rgba(219, 234, 254, 0.3) 100%);
    transform: scale(1.002);
}

.jm-table-hover tbody tr:hover td:first-child {
    border-left: 3px solid var(--jm-primary);
    padding-left: 7px;
}

/* Spinner */
.jm-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2.5px solid var(--jm-border);
    border-top-color: var(--jm-primary);
    border-radius: 50%;
    animation: jm-spin 0.7s linear infinite;
    vertical-align: middle;
}

.jm-spinner.lg {
    width: 40px;
    height: 40px;
    border-width: 3.5px;
}

/* [FRENTE 3] UI Locking for Archived Cases */
.case-archived #mainCaseContent {
    pointer-events: none;
    opacity: 0.7;
    filter: grayscale(0.5);
    transition: all 0.3s ease;
}

/* Ensure Status Picker remains interactive in archived mode */
.case-archived #contextRailPanel {
    pointer-events: auto !important;
}

.case-archived .context-rail > *:not(#btn-status-picker-wrapper) {
    /* Optional: dim other rail items too if desired */
}
