/* ============================================================
   Family Court Toolbox v2 — Main Stylesheet
   ============================================================ */

:root {
    --primary: #1a56db;
    --primary-hover: #1648b8;
    --primary-light: #e8eefb;
    --success: #059669;
    --success-light: #d1fae5;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --radius: 8px;
    --radius-sm: 4px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
    font-family: var(--font);
    color: var(--gray-800);
    background: var(--gray-50);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============ TOP NAV ============ */
.top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 56px;
    background: white;
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand a {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--gray-900);
    text-decoration: none;
}

.nav-links {
    display: flex;
    gap: 4px;
}

.nav-links a {
    padding: 8px 16px;
    border-radius: var(--radius);
    color: var(--gray-600);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.15s;
}

.nav-links a:hover { background: var(--gray-100); color: var(--gray-900); }
.nav-links a.active { background: var(--primary-light); color: var(--primary); }

.nav-user { position: relative; }

.user-menu-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius);
}

.user-menu-trigger:hover { background: var(--gray-100); }

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
}

.user-name { font-size: 0.875rem; color: var(--gray-700); }

.user-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    z-index: 200;
}

.user-dropdown.open { display: block; }

.dropdown-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-200);
}

.dropdown-header strong { display: block; font-size: 0.9rem; }

.user-type-badge {
    font-size: 0.75rem;
    color: var(--primary);
    background: var(--primary-light);
    padding: 2px 8px;
    border-radius: 10px;
    display: inline-block;
    margin-top: 4px;
}

.user-dropdown a {
    display: block;
    padding: 10px 16px;
    color: var(--gray-700);
    font-size: 0.875rem;
    text-decoration: none;
}

.user-dropdown a:hover { background: var(--gray-50); }

/* ============ MAIN CONTENT ============ */
.main-content {
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px;
}

/* ============ PAGE HEADER ============ */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
}

.back-link {
    font-size: 0.875rem;
    color: var(--gray-500);
    margin-right: auto;
    width: 100%;
}

/* ============ BUTTONS ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
    font-family: var(--font);
    text-decoration: none;
    gap: 6px;
}

.btn:hover { text-decoration: none; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

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

.btn-secondary { background: white; color: var(--gray-700); border-color: var(--gray-300); }
.btn-secondary:hover { background: var(--gray-50); }

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

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

.btn-small { padding: 6px 12px; font-size: 0.8rem; }
.btn-full { width: 100%; }

/* ============ FORMS ============ */
.form-container { max-width: 720px; }

.form-section {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 16px;
}

.form-section h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--gray-900);
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 4px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: var(--font);
    transition: border-color 0.15s;
    background: white;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.1);
}

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

.form-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

.form-error {
    color: var(--danger);
    font-size: 0.85rem;
    margin-top: 8px;
    min-height: 20px;
}

.form-message {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin: 12px 0;
}

.form-message.success { background: var(--success-light); color: var(--success); }
.form-message.error { background: var(--danger-light); color: var(--danger); }

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    cursor: pointer;
}

.link-small { font-size: 0.8rem; }

/* ============ AUTH PAGES ============ */
.auth-page {
    background: linear-gradient(135deg, #1a56db 0%, #1648b8 50%, #0f3a8f 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-container {
    width: 100%;
    max-width: 420px;
    padding: 24px;
}

.auth-brand {
    text-align: center;
    color: white;
    margin-bottom: 32px;
}

.auth-brand h1 { font-size: 1.5rem; margin-top: 12px; }
.auth-brand p { opacity: 0.8; font-size: 0.9rem; }

.auth-card {
    background: white;
    border-radius: 12px;
    padding: 32px;
    box-shadow: var(--shadow-lg);
}

.auth-card h2 {
    font-size: 1.25rem;
    margin-bottom: 24px;
    color: var(--gray-900);
}

.auth-subtitle {
    color: var(--gray-500);
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.auth-switch {
    text-align: center;
    margin-top: 20px;
    font-size: 0.875rem;
    color: var(--gray-500);
}

.auth-switch a { color: var(--primary); font-weight: 500; }

.auth-footer {
    text-align: center;
    margin-top: 24px;
    color: rgba(255,255,255,0.6);
    font-size: 0.8rem;
}

/* ============ STATS GRID ============ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--gray-900);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-top: 4px;
}

/* ============ DASHBOARD ============ */
.dashboard-section {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

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

.section-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.dashboard-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ============ CASE CARDS ============ */
.case-list { display: flex; flex-direction: column; gap: 8px; }

.case-card {
    display: block;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 16px 20px;
    text-decoration: none;
    color: inherit;
    transition: all 0.15s;
}

.case-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
    text-decoration: none;
}

.case-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.case-label { font-weight: 600; color: var(--gray-900); }

.case-status {
    font-size: 0.75rem;
    padding: 3px 10px;
    border-radius: 10px;
    font-weight: 500;
    text-transform: capitalize;
}

.status-intake { background: var(--primary-light); color: var(--primary); }
.status-active { background: var(--success-light); color: var(--success); }
.status-pending_court { background: var(--warning-light); color: var(--warning); }
.status-settled { background: var(--gray-100); color: var(--gray-600); }
.status-closed { background: var(--gray-100); color: var(--gray-400); }
.status-scheduled { background: var(--primary-light); color: var(--primary); }
.status-completed { background: var(--success-light); color: var(--success); }
.status-archived { background: var(--gray-100); color: var(--gray-400); }

.case-card-parties {
    font-size: 0.9rem;
    color: var(--gray-600);
    margin-bottom: 8px;
}

.case-card-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--gray-400);
}

/* ============ DATA TABLE ============ */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table th {
    text-align: left;
    padding: 10px 12px;
    font-weight: 600;
    color: var(--gray-600);
    border-bottom: 2px solid var(--gray-200);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
}

.data-table .clickable-row { cursor: pointer; }
.data-table .clickable-row:hover { background: var(--gray-50); }

.text-center { text-align: center; }
.text-muted { color: var(--gray-400); font-size: 0.875rem; }

/* ============ TABS ============ */
.tab-nav {
    display: flex;
    gap: 2px;
    border-bottom: 2px solid var(--gray-200);
    margin-bottom: 24px;
    overflow-x: auto;
}

.tab-btn {
    padding: 10px 18px;
    background: none;
    border: none;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-500);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    font-family: var(--font);
}

.tab-btn:hover { color: var(--gray-700); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

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

/* ============ DETAIL GRID ============ */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 16px;
}

.detail-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 20px;
}

.detail-card h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--gray-800);
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--gray-50);
    font-size: 0.875rem;
}

.detail-row span:first-child { color: var(--gray-500); }
.detail-row span:last-child { color: var(--gray-800); font-weight: 500; }

/* ============ PARTY CARDS ============ */
.party-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 12px;
}

.party-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.party-type-badge {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    padding: 3px 10px;
    border-radius: 10px;
    background: var(--primary-light);
    color: var(--primary);
}

.party-actions {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--gray-100);
}

/* ============ FORMS GRID ============ */
.forms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

.form-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 16px;
    cursor: pointer;
    transition: all 0.15s;
}

.form-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
}

.form-number {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
}

.form-name {
    font-weight: 500;
    margin: 4px 0 8px;
    color: var(--gray-800);
    font-size: 0.9rem;
}

.form-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--gray-400);
}

.form-category {
    text-transform: capitalize;
    background: var(--gray-100);
    padding: 2px 8px;
    border-radius: 4px;
}

.form-category-filters {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

/* ============ FORM FILL ============ */
.form-fill-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 24px;
}

.form-fill-sidebar {
    position: sticky;
    top: 80px;
    align-self: start;
}

.fill-progress {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
}

.progress-bar {
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.3s;
    width: 0%;
}

.fill-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.fill-sections {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    overflow: hidden;
}

.section-link {
    display: block;
    padding: 8px 16px;
    font-size: 0.8rem;
    color: var(--gray-600);
    border-bottom: 1px solid var(--gray-100);
    text-transform: capitalize;
    text-decoration: none;
}

.section-link:hover { background: var(--gray-50); text-decoration: none; }

.form-fill-content .form-section {
    margin-bottom: 24px;
}

.section-title {
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--gray-500);
    padding-bottom: 8px;
    border-bottom: 1px solid var(--gray-200);
    margin-bottom: 16px;
}

.form-field {
    margin-bottom: 12px;
}

.form-field label {
    display: block;
    font-size: 0.8rem;
    color: var(--gray-600);
    margin-bottom: 3px;
}

.form-field input,
.form-field select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-family: var(--font);
}

.form-field input:focus,
.form-field select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(26,86,219,0.1);
}

.checkbox-field { padding: 4px 0; }

/* ============ MESSAGES ============ */
.message-thread {
    max-height: 500px;
    overflow-y: auto;
    padding: 16px;
    background: var(--gray-50);
    border-radius: var(--radius);
    margin-bottom: 12px;
}

.message {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 12px;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.message-sent {
    background: var(--primary);
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.message-received {
    background: white;
    border: 1px solid var(--gray-200);
    border-bottom-left-radius: 4px;
}

.message-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    margin-bottom: 4px;
    opacity: 0.8;
}

.message-compose {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.message-compose textarea {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.9rem;
    resize: none;
}

/* ============ FILTERS ============ */
.filters-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.search-box input {
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.9rem;
    width: 280px;
    font-family: var(--font);
}

.filter-group select {
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: var(--font);
    background: white;
}

/* ============ PAGINATION ============ */
.pagination {
    display: flex;
    gap: 4px;
    justify-content: center;
    margin-top: 16px;
}

.page-btn {
    padding: 6px 12px;
    border: 1px solid var(--gray-300);
    background: white;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
}

.page-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ============ MODAL ============ */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: white;
    border-radius: 12px;
    padding: 32px;
    max-width: 560px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal h3 { font-size: 1.1rem; margin-bottom: 20px; }

/* ============ NOTIFICATIONS ============ */
.notification-container {
    position: fixed;
    top: 72px;
    right: 24px;
    z-index: 500;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.notification {
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    box-shadow: var(--shadow-md);
    transform: translateX(120%);
    transition: transform 0.3s;
    max-width: 400px;
}

.notification.show { transform: translateX(0); }
.notification-info { background: white; border-left: 4px solid var(--primary); }
.notification-success { background: var(--success-light); border-left: 4px solid var(--success); color: var(--success); }
.notification-error { background: var(--danger-light); border-left: 4px solid var(--danger); color: var(--danger); }
.notification-warning { background: var(--warning-light); border-left: 4px solid var(--warning); color: var(--warning); }

/* ============ EMPTY STATE ============ */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--gray-400);
}

.loading {
    text-align: center;
    padding: 40px;
    color: var(--gray-400);
}

.error {
    text-align: center;
    padding: 20px;
    color: var(--danger);
}

/* ============ BILLING ============ */
.billing-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

/* ============ FINANCIAL NAV ============ */
.financial-nav {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

/* ============ PRIORITY BADGES ============ */
.task-priority { font-size: 0.7rem; padding: 2px 8px; border-radius: 4px; text-transform: uppercase; }
.priority-low { background: var(--gray-100); color: var(--gray-500); }
.priority-normal { background: var(--primary-light); color: var(--primary); }
.priority-high { background: var(--warning-light); color: var(--warning); }
.priority-urgent { background: var(--danger-light); color: var(--danger); }

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
    .form-row-2col { grid-template-columns: 1fr; }
    .dashboard-columns { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: 1fr; }
    .form-fill-layout { grid-template-columns: 1fr; }
    .form-fill-sidebar { position: static; }
    .billing-summary { grid-template-columns: 1fr; }
    .nav-links { display: none; }
    .filters-bar { flex-direction: column; }
    .search-box input { width: 100%; }
}
