/**
 * Juris — Design System
 * CSS principal com variáveis, reset, tipografia, componentes base.
 * Paleta: Navy + Gold para escritório de advocacia premium.
 */

/* ══════════════════════════════════════════
   CSS Variables (Design Tokens)
   ══════════════════════════════════════════ */
:root {
    /* ── Colors: Navy + Gold ── */
    --bg-dark: #0f1419;
    --bg-body: #141a22;
    --bg-card: #1a2332;
    --bg-card-hover: #1f2a3c;
    --bg-elevated: #222e40;
    --bg-input: #1a2332;

    --accent: #c9a84c;
    --accent-light: #dfc06a;
    --accent-dark: #a88a3a;
    --accent-bg: rgba(201, 168, 76, 0.1);
    --accent-bg-hover: rgba(201, 168, 76, 0.15);

    --gradient-accent: linear-gradient(135deg, #c9a84c 0%, #dfc06a 100%);
    --gradient-card: linear-gradient(135deg, #1a2332 0%, #1f2a3c 100%);

    --text-primary: #e8ecf1;
    --text-secondary: #a0aec0;
    --text-muted: #6b7a8d;
    --text-inverse: #0f1419;

    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);
    --border-accent: rgba(201, 168, 76, 0.3);

    /* ── Semantic Colors ── */
    --success: #48bb78;
    --success-bg: rgba(72, 187, 120, 0.1);
    --error: #fc8181;
    --error-bg: rgba(252, 129, 129, 0.1);
    --warning: #f6ad55;
    --warning-bg: rgba(246, 173, 85, 0.1);
    --info: #63b3ed;
    --info-bg: rgba(99, 179, 237, 0.1);

    /* ── Typography ── */
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-heading: 'Outfit', 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    --text-xs: 0.75rem;
    --text-sm: 0.8125rem;
    --text-base: 0.875rem;
    --text-md: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;

    /* ── Spacing ── */
    --sp-1: 0.25rem;
    --sp-2: 0.5rem;
    --sp-3: 0.75rem;
    --sp-4: 1rem;
    --sp-5: 1.25rem;
    --sp-6: 1.5rem;
    --sp-8: 2rem;
    --sp-10: 2.5rem;
    --sp-12: 3rem;

    /* ── Radius ── */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;

    /* ── Shadows ── */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 20px rgba(201, 168, 76, 0.15);

    /* ── Transitions ── */
    --transition-fast: 0.15s ease;
    --transition-base: 0.25s ease;
    --transition-slow: 0.4s ease;

    /* ── Layout ── */
    --sidebar-width: 280px;
    --header-height: 64px;
    --max-width: 1400px;
}

/* ══════════════════════════════════════════
   Light Mode Theme
   ══════════════════════════════════════════ */
[data-theme="light"] {
    --bg-dark: #e8ecf0;
    --bg-body: #f0f2f5;
    --bg-card: #ffffff;
    --bg-card-hover: #f7f8fa;
    --bg-elevated: #f0f2f5;
    --bg-input: #ffffff;

    --accent: #b8942e;
    --accent-light: #c9a84c;
    --accent-dark: #9a7b24;
    --accent-bg: rgba(184, 148, 46, 0.08);
    --accent-bg-hover: rgba(184, 148, 46, 0.12);

    --gradient-accent: linear-gradient(135deg, #b8942e 0%, #c9a84c 100%);
    --gradient-card: linear-gradient(135deg, #ffffff 0%, #f7f8fa 100%);

    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --text-muted: #a0aec0;
    --text-inverse: #ffffff;

    --border-color: rgba(0, 0, 0, 0.08);
    --border-hover: rgba(0, 0, 0, 0.15);
    --border-accent: rgba(184, 148, 46, 0.3);

    /* ── Semantic (stronger for light bg) ── */
    --success: #38a169;
    --success-bg: rgba(56, 161, 105, 0.08);
    --error: #e53e3e;
    --error-bg: rgba(229, 62, 62, 0.06);
    --warning: #dd6b20;
    --warning-bg: rgba(221, 107, 32, 0.06);
    --info: #3182ce;
    --info-bg: rgba(49, 130, 206, 0.06);

    /* ── Shadows (subtler) ── */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 0 20px rgba(184, 148, 46, 0.1);
}


/* ══════════════════════════════════════════
   Reset & Base
   ══════════════════════════════════════════ */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-body);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--accent-light);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

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

/* ── Scrollbar ── */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-elevated);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}


/* ══════════════════════════════════════════
   Typography
   ══════════════════════════════════════════ */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
}

h1 {
    font-size: var(--text-3xl);
}

h2 {
    font-size: var(--text-2xl);
}

h3 {
    font-size: var(--text-xl);
}

h4 {
    font-size: var(--text-lg);
}

h5 {
    font-size: var(--text-md);
}

h6 {
    font-size: var(--text-base);
}

.page-title {
    font-family: var(--font-heading);
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--sp-6);
    display: flex;
    align-items: center;
    gap: var(--sp-3);
}

.page-title .badge {
    font-size: var(--text-xs);
    vertical-align: middle;
}

.section-title {
    font-family: var(--font-heading);
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--sp-4);
    padding-bottom: var(--sp-3);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}


/* ══════════════════════════════════════════
   Buttons
   ══════════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    padding: 0.625rem 1.25rem;
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: 500;
    line-height: 1;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.btn-primary {
    background: var(--gradient-accent);
    color: var(--text-inverse);
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(201, 168, 76, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 4px 16px rgba(201, 168, 76, 0.4);
    color: var(--text-inverse);
}

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.btn-danger {
    background: var(--error-bg);
    color: var(--error);
    border-color: rgba(252, 129, 129, 0.2);
}

.btn-danger:hover {
    background: rgba(252, 129, 129, 0.2);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: var(--text-xs);
    border-radius: var(--radius-sm);
}

.btn-block {
    width: 100%;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: var(--radius-sm);
}

.btn-group {
    display: flex;
    gap: var(--sp-2);
    flex-wrap: wrap;
}


/* ══════════════════════════════════════════
   Forms
   ══════════════════════════════════════════ */
.form-group {
    margin-bottom: var(--sp-5);
}

.form-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--sp-2);
}

.form-control {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-family: var(--font-body);
    font-size: var(--text-base);
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    outline: none;
}

.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-bg);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-control:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.form-control-error {
    border-color: var(--error);
}

.form-error {
    font-size: var(--text-xs);
    color: var(--error);
    margin-top: var(--sp-1);
}

.form-hint {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: var(--sp-1);
}

.input-icon-wrapper {
    position: relative;
}

.input-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
}

.input-icon-wrapper .form-control {
    padding-left: 2.5rem;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7a8d' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
}

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

.form-check {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--text-sm);
    cursor: pointer;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--sp-4);
}


/* ══════════════════════════════════════════
   Tables
   ══════════════════════════════════════════ */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
}

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

.data-table thead {
    background: var(--bg-elevated);
}

.data-table th {
    padding: 0.75rem 1rem;
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid var(--border-color);
}

.data-table td {
    padding: 0.75rem 1rem;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
    background: var(--bg-card-hover);
}

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

/* Sortable columns */
.sortable {
    cursor: pointer;
    user-select: none;
    transition: color var(--transition-fast);
}

.sortable:hover {
    color: var(--accent);
}

.sortable::after {
    content: ' ↕';
    font-size: 0.7em;
    opacity: 0.4;
}

.sortable.asc::after {
    content: ' ↑';
    opacity: 1;
    color: var(--accent);
}

.sortable.desc::after {
    content: ' ↓';
    opacity: 1;
    color: var(--accent);
}

/* Status in tables */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    padding: 0.25rem 0.625rem;
    font-size: var(--text-xs);
    font-weight: 500;
    border-radius: var(--radius-full);
    white-space: nowrap;
}

.status-active {
    background: var(--success-bg);
    color: var(--success);
}

.status-pending {
    background: var(--warning-bg);
    color: var(--warning);
}

.status-closed {
    background: var(--bg-elevated);
    color: var(--text-muted);
}

.status-overdue {
    background: var(--error-bg);
    color: var(--error);
}

/* Actions column */
.table-actions {
    display: flex;
    gap: var(--sp-1);
    justify-content: flex-end;
}


/* ══════════════════════════════════════════
   Cards
   ══════════════════════════════════════════ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--sp-6);
    transition: all var(--transition-base);
}

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

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

.card-title {
    font-family: var(--font-heading);
    font-size: var(--text-md);
    font-weight: 600;
    color: var(--text-primary);
}


/* ══════════════════════════════════════════
   Alerts
   ══════════════════════════════════════════ */
.alert {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    margin-bottom: var(--sp-4);
    animation: slideDown 0.3s ease;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(72, 187, 120, 0.2);
}

.alert-error {
    background: var(--error-bg);
    color: var(--error);
    border: 1px solid rgba(252, 129, 129, 0.2);
}

.alert-warning {
    background: var(--warning-bg);
    color: var(--warning);
    border: 1px solid rgba(246, 173, 85, 0.2);
}

.alert-info {
    background: var(--info-bg);
    color: var(--info);
    border: 1px solid rgba(99, 179, 237, 0.2);
}

.alert-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.25rem;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity var(--transition-fast);
    line-height: 1;
}

.alert-close:hover {
    opacity: 1;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

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


/* ══════════════════════════════════════════
   Badges
   ══════════════════════════════════════════ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.5rem;
    font-size: var(--text-xs);
    font-weight: 600;
    border-radius: var(--radius-full);
    line-height: 1;
}

.badge-accent {
    background: var(--accent-bg);
    color: var(--accent);
}

.badge-count {
    background: var(--accent);
    color: var(--text-inverse);
    min-width: 20px;
    height: 20px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
}


/* ══════════════════════════════════════════
   Pagination
   ══════════════════════════════════════════ */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    padding: var(--sp-4) 0;
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 0.5rem;
    font-size: var(--text-sm);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.pagination a {
    color: var(--text-secondary);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
}

.pagination a:hover {
    background: var(--bg-elevated);
    border-color: var(--accent);
    color: var(--accent);
}

.pagination .current {
    background: var(--accent);
    color: var(--text-inverse);
    font-weight: 600;
    border: 1px solid var(--accent);
}

.pagination .disabled {
    color: var(--text-muted);
    opacity: 0.4;
    pointer-events: none;
}

.pagination-info {
    color: var(--text-muted);
    font-size: var(--text-sm);
}


/* ══════════════════════════════════════════
   Search Box
   ══════════════════════════════════════════ */
.search-box {
    position: relative;
    margin-bottom: var(--sp-4);
}

.search-box .search-icon {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-box input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.75rem;
    font-size: var(--text-base);
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    outline: none;
    transition: all var(--transition-fast);
}

.search-box input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-bg);
}


/* ══════════════════════════════════════════
   Empty State
   ══════════════════════════════════════════ */
.empty-state {
    text-align: center;
    padding: var(--sp-12) var(--sp-4);
    color: var(--text-muted);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    margin: 0 auto var(--sp-4);
    opacity: 0.3;
}

.empty-state p {
    font-size: var(--text-sm);
}


/* ══════════════════════════════════════════
   Modal / Confirm Dialog
   ══════════════════════════════════════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-base);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: var(--sp-8);
    max-width: 480px;
    width: 90%;
    box-shadow: var(--shadow-lg);
    transform: scale(0.95);
    transition: transform var(--transition-base);
}

.modal-overlay.active .modal {
    transform: scale(1);
}


/* ══════════════════════════════════════════
   Utilities
   ══════════════════════════════════════════ */
.text-accent {
    color: var(--accent);
}

.text-success {
    color: var(--success);
}

.text-error {
    color: var(--error);
}

.text-warning {
    color: var(--warning);
}

.text-muted {
    color: var(--text-muted);
}

.text-secondary {
    color: var(--text-secondary);
}

.text-right {
    text-align: right;
}

.text-center {
    text-align: center;
}

.mt-1 {
    margin-top: var(--sp-1);
}

.mt-2 {
    margin-top: var(--sp-2);
}

.mt-4 {
    margin-top: var(--sp-4);
}

.mt-6 {
    margin-top: var(--sp-6);
}

.mt-8 {
    margin-top: var(--sp-8);
}

.mb-2 {
    margin-bottom: var(--sp-2);
}

.mb-4 {
    margin-bottom: var(--sp-4);
}

.mb-6 {
    margin-bottom: var(--sp-6);
}

.flex {
    display: flex;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.gap-2 {
    gap: var(--sp-2);
}

.gap-4 {
    gap: var(--sp-4);
}

.gap-6 {
    gap: var(--sp-6);
}

.gap-8 {
    gap: var(--sp-8);
}


.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    clip: rect(0, 0, 0, 0);
    overflow: hidden;
}

/* Responsive visibility */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
}

@media (min-width: 769px) {
    .hide-desktop {
        display: none !important;
    }
}