:root {
    /* Core Colors - Dark Graphite/Chumbo Theme */
    --bg-base: #0a0a0c;
    --bg-panel: #131417;
    --bg-elevated: #1e1f24;
    --bg-hover: #2a2b32;
    
    /* Accents - Discrete Tech Blue */
    --accent-primary: #2563eb;
    --accent-hover: #3b82f6;
    --accent-glow: rgba(37, 99, 235, 0.3);
    
    /* Status Colors */
    --status-critical: #ef4444;
    --status-warning: #f59e0b;
    --status-success: #10b981;
    
    /* Text Colors */
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    /* Borders & Shadows */
    --border-light: rgba(255, 255, 255, 0.05);
    --border-medium: rgba(255, 255, 255, 0.1);
    --shadow-glow: 0 0 20px var(--accent-glow);
    --shadow-panel: 0 4px 20px rgba(0, 0, 0, 0.5);
    
    /* Dimensions */
    --sidebar-width: 260px;
    --topbar-height: 70px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    display: flex;
    height: 100vh;
    overflow: hidden;
    font-size: 14px;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    padding: 24px 0;
    transition: all 0.3s ease;
}

.sidebar-header {
    padding: 0 24px 24px 24px;
    border-bottom: 1px solid var(--border-light);
}

.brand-title {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}

.brand-subtitle {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.brand-glow {
    width: 8px;
    height: 8px;
    background-color: var(--accent-primary);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--accent-primary);
}

.sidebar-menu {
    flex: 1;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
}

.sidebar-menu::-webkit-scrollbar {
    width: 4px;
}

.sidebar-menu::-webkit-scrollbar-thumb {
    background-color: var(--bg-elevated);
    border-radius: 4px;
}

.menu-item {
    padding: 10px 16px;
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s ease;
    font-weight: 500;
}

.menu-item:hover, .menu-item.active {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.menu-item.active {
    background-color: rgba(37, 99, 235, 0.1);
    color: var(--accent-primary);
    border-left: 3px solid var(--accent-primary);
}

.menu-icon {
    width: 18px;
    height: 18px;
    opacity: 0.8;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-base);
    position: relative;
    overflow-x: hidden;
}

/* Topbar */
.topbar {
    height: var(--topbar-height);
    background-color: var(--bg-base);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
}

.search-container {
    position: relative;
    width: 350px;
}

.search-input {
    width: 100%;
    background-color: var(--bg-panel);
    border: 1px solid var(--border-medium);
    border-radius: 8px;
    padding: 10px 16px 10px 40px;
    color: var(--text-primary);
    font-size: 13px;
    transition: all 0.2s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.action-icon {
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s ease;
    position: relative;
}

.action-icon:hover {
    color: var(--text-primary);
}

.badge-critical {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 8px;
    height: 8px;
    background-color: var(--status-critical);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--status-critical);
}

.sync-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    background-color: var(--bg-elevated);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--border-light);
}

.sync-dot {
    width: 6px;
    height: 6px;
    background-color: var(--status-success);
    border-radius: 50%;
    box-shadow: 0 0 6px var(--status-success);
}

/* Dashboard Area */
.dashboard-area {
    flex: 1;
    padding: 24px;
    height: calc(100vh - var(--topbar-height));
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.page-header {
    margin-bottom: 32px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.page-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
}

.ai-action-btn {
    background: linear-gradient(135deg, var(--accent-primary) 0%, #1d4ed8 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow-glow);
    transition: all 0.2s ease;
}

.ai-action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(37, 99, 235, 0.5);
}

/* Grid Layout */
.grid-dashboard {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 24px;
}

/* Cards */
.card {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow-panel);
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.card:hover {
    border-color: var(--border-medium);
}

.col-span-3 { grid-column: span 3; }
.col-span-4 { grid-column: span 4; }
.col-span-6 { grid-column: span 6; }
.col-span-8 { grid-column: span 8; }
.col-span-12 { grid-column: span 12; }

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.kpi-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.kpi-trend {
    font-size: 12px;
    color: var(--status-success);
    display: flex;
    align-items: center;
    gap: 4px;
}

.kpi-trend.negative {
    color: var(--status-critical);
}

/* Timeline & Lists */
.list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
}

.list-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.item-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.item-title {
    font-weight: 500;
    color: var(--text-primary);
}

.item-desc {
    font-size: 12px;
    color: var(--text-secondary);
}

.badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge.critical { background: rgba(239, 68, 68, 0.1); color: var(--status-critical); }
.badge.warning { background: rgba(245, 158, 11, 0.1); color: var(--status-warning); }
.badge.info { background: rgba(37, 99, 235, 0.1); color: var(--accent-primary); }

/* IA Assistant Overlay Overlay */
.ai-assistant-panel {
    position: fixed;
    bottom: 32px;
    right: 32px;
    width: 380px;
    height: 500px;
    background-color: var(--bg-panel);
    border: 1px solid var(--accent-primary);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 0 20px rgba(37, 99, 235, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.ai-assistant-panel.active {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.ai-header {
    padding: 16px 20px;
    background: linear-gradient(180deg, rgba(37, 99, 235, 0.1) 0%, transparent 100%);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ai-title {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-chat-area {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ai-message {
    background-color: var(--bg-elevated);
    padding: 12px 16px;
    border-radius: 12px;
    border-top-left-radius: 4px;
    font-size: 13px;
    line-height: 1.5;
    align-self: flex-start;
    max-width: 85%;
}

.ai-message.user {
    background-color: var(--accent-primary);
    color: white;
    border-top-left-radius: 12px;
    border-top-right-radius: 4px;
    align-self: flex-end;
}

.ai-input-area {
    padding: 16px;
    border-top: 1px solid var(--border-light);
    display: flex;
    gap: 8px;
}

.ai-input {
    flex: 1;
    background-color: var(--bg-elevated);
    border: 1px solid var(--border-medium);
    border-radius: 8px;
    padding: 10px 16px;
    color: white;
    font-size: 13px;
}

.ai-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.ai-send {
    width: 40px;
    background-color: var(--accent-primary);
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* FAB */
.fab-ai {
    position: fixed;
    bottom: 32px;
    right: 32px;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--accent-primary) 0%, #1d4ed8 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(37, 99, 235, 0.4);
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
}

.fab-ai:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(37, 99, 235, 0.6);
}

/* Global Search Results Dropdown Overlay */
.search-results-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background-color: var(--bg-panel);
    border: 1px solid var(--border-medium);
    border-radius: 8px;
    margin-top: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
    z-index: 1000;
    max-height: 350px;
    overflow-y: auto;
    display: none;
    padding: 8px 0;
    border-left: 2px solid var(--accent-primary);
}

.search-results-dropdown.active {
    display: block;
}

.search-result-group-title {
    padding: 6px 16px;
    font-size: 11px;
    color: var(--accent-primary);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background-color: rgba(255, 255, 255, 0.02);
}

.search-result-item {
    padding: 10px 16px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 3px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background-color: var(--bg-hover);
}

.search-result-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 13px;
}

.search-result-subtitle {
    font-size: 11px;
    color: var(--text-secondary);
}

.search-result-empty {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

/* Modal Overlay & Card styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-container {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-medium);
    border-radius: 12px;
    width: 480px;
    max-width: 90%;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.95);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active .modal-container {
    transform: scale(1);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s ease;
    font-size: 24px;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-light);
    background-color: rgba(255, 255, 255, 0.01);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.modal-input {
    width: 100%;
    background-color: var(--bg-elevated);
    border: 1px solid var(--border-medium);
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 13px;
    transition: border-color 0.2s ease;
}

.modal-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.modal-select {
    width: 100%;
    background-color: var(--bg-elevated);
    border: 1px solid var(--border-medium);
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 13px;
    appearance: none;
}

.btn-secondary {
    background: none;
    border: 1px solid var(--border-medium);
    color: var(--text-secondary);
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    color: var(--text-primary);
    background-color: var(--bg-hover);
}

.btn-danger {
    background-color: var(--status-critical);
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    font-weight: 500;
    transition: opacity 0.2s ease;
}

.btn-danger:hover {
    opacity: 0.9;
}

/* Custom premium classes for search results loading & spinner */
.spinner-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    gap: 12px;
}

.spinner-circle {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(255,255,255,0.05);
    border-top: 3px solid var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-status-text {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    letter-spacing: 0.5px;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* Glowing AI Card */
.ai-glowing-card {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.08) 0%, rgba(16, 185, 129, 0.08) 100%);
    border: 1px solid rgba(37, 99, 235, 0.2);
    box-shadow: 0 0 15px rgba(37, 99, 235, 0.1);
    border-radius: 8px;
    padding: 16px;
    position: relative;
    overflow: hidden;
}

.ai-glowing-card::before {
    content: '';
    position: absolute;
    top: 0; left: -150%;
    width: 50%; height: 100%;
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.05), transparent);
    transform: skewX(-25deg);
    animation: shine 4s infinite linear;
}

@keyframes shine {
    to { left: 200%; }
}



/* ==========================================================================
   Premium SPA Fixed Height & Custom Scrollbar Styles
   ========================================================================== */

/* Subtle and thin custom scrollbars globally */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    transition: background 0.2s ease;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* App Views flex wrapper inside the fixed dashboard */
.app-view {
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow: hidden;
    flex: 1;
    min-height: 0;
}

.app-view > .page-header {
    flex-shrink: 0;
    margin-bottom: 8px;
}

/* Grid within app-view should span the remaining space and handle vertical overflow internally */
.app-view > .grid-dashboard {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px;
}

/* Full span cards should use flexbox to contain tables scrollably */
.app-view > .card.col-span-12 {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Container for responsive tables inside cards */
.table-responsive {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: auto;
    padding-right: 4px;
}

.juridico-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.juridico-table th {
    position: sticky;
    top: 0;
    background-color: var(--bg-panel);
    z-index: 2;
    padding: 12px 16px;
    border-bottom: 2px solid var(--border-light);
}

.juridico-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
}
