:root {
    --bg-dark: #07090E;
    --bg-card: #0F121D;
    --sidebar-bg: #0A0D16;
    --primary: #2563EB;
    --primary-light: #3B82F6;
    --accent: #06B6D4;
    --accent-glow: rgba(6, 182, 212, 0.4);
    --text-main: #F8FAFC;
    --text-sec: #94A3B8;
    --border: rgba(255, 255, 255, 0.08);
    --success: #10B981;
    --danger: #EF4444;
    --pending: #F59E0B;
    --font-main: 'Inter', sans-serif;
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-dark);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* SIDEBAR */
.sidebar {
    width: 280px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 24px 0;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 0 24px 32px;
}

.sidebar-header .logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-main);
}

.logo-icon {
    color: var(--accent);
}

.sidebar-nav {
    flex: 1;
}

.sidebar-nav ul {
    list-style: none;
}

.sidebar-nav li {
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-sec);
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.sidebar-nav li:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.03);
}

.sidebar-nav li.active {
    color: var(--accent);
    background: rgba(6, 182, 212, 0.05);
    border-left-color: var(--accent);
}

.sidebar-nav li i {
    width: 20px;
    height: 20px;
}

.sidebar-footer {
    padding: 24px;
    border-top: 1px solid var(--border);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: white;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-sec);
}

.logout-btn {
    width: 100%;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-sec);
    padding: 10px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border-color: var(--danger);
}

/* MAIN CONTENT */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
    position: relative;
}

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 40px;
}

.header-title h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 4px;
}

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

/* BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    font-family: inherit;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover {
    background-color: var(--primary-light);
    transform: translateY(-2px);
}

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

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.05);
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.85rem;
}

/* KPI GRID */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 48px;
}

.kpi-card {
    background: linear-gradient(145deg, var(--bg-card), rgba(255, 255, 255, 0.05));
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 24px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.kpi-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100px;
    background: radial-gradient(circle, rgba(6, 182, 212, 0.05) 0%, transparent 70%);
    pointer-events: none;
}

.kpi-card:hover {
    transform: translateY(-8px);
    border-color: rgba(6, 182, 212, 0.4);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.4), 0 0 20px rgba(6, 182, 212, 0.1);
}

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

.kpi-label {
    color: var(--text-sec);
    font-size: 0.9rem;
    font-weight: 500;
}

.kpi-value {
    font-size: 2rem;
    font-weight: 700;
}

.kpi-trend {
    font-size: 0.8rem;
    margin-top: 4px;
    display: block;
}

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

/* PROGRESS CIRCLE */
.progress-circle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: conic-gradient(var(--accent) var(--progress), var(--border) 0);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.progress-circle::before {
    content: '';
    position: absolute;
    width: 48px;
    height: 48px;
    background: var(--bg-card);
    border-radius: 50%;
}

.progress-text {
    position: relative;
    font-size: 0.8rem;
    font-weight: 700;
}

/* TABLE SECTION */
.table-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 32px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

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

.search-input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 16px;
    color: white;
    width: 250px;
}

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

.modern-table th {
    text-align: left;
    padding: 16px;
    color: var(--text-sec);
    font-weight: 500;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border);
}

.modern-table td {
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.badge {
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-processing {
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary-light);
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.badge-pending {
    background: rgba(245, 158, 11, 0.1);
    color: var(--pending);
}

.badge-accent {
    background: rgba(6, 182, 212, 0.1);
    color: var(--accent);
}

.action-btn {
    background: transparent;
    border: none;
    color: var(--text-sec);
    cursor: pointer;
    padding: 4px;
    transition: color 0.2s ease;
}

.action-btn:hover {
    color: var(--text-main);
}

.text-danger:hover {
    color: var(--danger);
}

.disabled { opacity: 0.3; cursor: not-allowed; }

/* MODAL */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

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

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    width: 100%;
    max-width: 500px;
    border-radius: 20px;
    padding: 32px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

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

.close-modal {
    background: transparent;
    border: none;
    color: var(--text-sec);
    cursor: pointer;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--text-sec);
}

.form-group input, .form-group select {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    color: white;
    font-family: inherit;
}

.form-group select option {
    background-color: var(--bg-card);
    color: var(--text-main);
}

.drag-drop-area {
    border: 2px dashed var(--border);
    border-radius: 16px;
    padding: 40px;
    text-align: center;
    margin-bottom: 24px;
    background: rgba(255, 255, 255, 0.02);
    transition: all 0.3s ease;
}

.drag-drop-area:hover {
    background: rgba(6, 182, 212, 0.03);
}

.drag-drop-area.highlight {
    border-color: var(--accent);
    background: rgba(6, 182, 212, 0.1);
    transform: scale(1.02);
}

.drag-icon {
    width: 48px;
    height: 48px;
    color: var(--accent);
    margin-bottom: 12px;
}

/* VIEW SYSTEM */
.view {
    display: none;
}

.view.active {
    display: block;
}

/* RESULT VIEW (SPLIT SCREEN) */
.overlay-view {
    position: fixed;
    inset: 0;
    background: var(--bg-dark);
    z-index: 1500;
    display: none;
    flex-direction: column;
}

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

.result-header {
    padding: 16px 40px;
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 24px;
}

.split-container {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.editor-pane {
    flex: 1;
    padding: 40px;
    overflow-y: auto;
    background: #111420;
}

.editor-paper {
    background: white;
    color: #1a1a1a;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    min-height: 1000px;
    padding: 80px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    font-family: 'Times New Roman', serif;
    line-height: 1.5;
}

.editor-header {
    text-align: center;
    margin-bottom: 40px;
}

.editor-paragraph {
    margin-bottom: 20px;
    text-align: justify;
}

.assistant-pane {
    width: 400px;
    background: var(--sidebar-bg);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 24px;
    overflow-y: auto;
}

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

.juris-cards {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.juris-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    transition: border-color 0.2s ease;
}

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

.juris-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.juris-court {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--accent);
    font-weight: 700;
}

.juris-card h4 {
    font-size: 1rem;
    margin-bottom: 8px;
    color: var(--text-main);
}

.juris-summary {
    font-size: 0.85rem;
    color: var(--text-sec);
    margin-bottom: 12px;
}

.btn-text {
    background: transparent;
    border: none;
    color: var(--accent);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
}

.btn-text:hover {
    text-decoration: underline;
}

/* --- CONFIGURACIÓN UI --- */
.section-title-small {
    margin-bottom: 24px;
    font-size: 1.5rem;
}

.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
}

.config-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    padding: 24px;
    border-radius: 16px;
}

/* TOGGLES / SWITCH */
.toggle-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    font-size: 0.9rem;
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input { opacity: 0; width: 0; height: 0; }

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--border);
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px; width: 18px;
    left: 3px; bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider { background-color: var(--accent); }
input:checked + .slider:before { transform: translateX(20px); }

/* --- RESPONSIVE SIDEBAR MOBILE --- */
.menu-toggle {
    display: none; /* Default hidden */
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 2100;
    background: var(--primary);
    border: none;
    color: white;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* --- NOTIFICATIONS (TOASTS) --- */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    background: #1e293b;
    color: white;
    padding: 16px 24px;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: 0 10px 25px rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--danger); }
.toast-info { border-left: 4px solid var(--accent); }

@keyframes slideIn {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}

@media (max-width: 768px) {
    .menu-toggle { display: block; }
    
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        bottom: 0;
        z-index: 2050;
        width: 80%;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 20px 0 50px rgba(0,0,0,0.5);
    }
    
    .sidebar.active-mobile {
        left: 0;
    }
    
    .main-content {
        padding: 80px 16px 24px;
    }
    
    .split-container {
        flex-direction: column;
    }
    
    .assistant-pane {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--border);
    }
    
    .editor-paper {
        padding: 40px 24px;
    }
}

/* ANIMATIONS */
.animate-scale-up {
    animation: scaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.animate-spin {
    animation: spin 1s linear infinite;
}

@keyframes scaleUp {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.loader-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-sec);
    gap: 16px;
}

.loader-container i {
    width: 48px;
    height: 48px;
    color: var(--accent);
}

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

/* Estilo para Jurisprudencia de SAIJ */
.juris-highlight {
    background: #f0f9ff;
    border-left: 4px solid var(--accent);
    padding: 15px;
    margin: 15px 0;
    border-radius: 0 8px 8px 0;
    font-size: 0.95rem;
    color: #1e293b;
}

.juris-highlight strong {
    color: var(--primary);
    display: block;
    margin-bottom: 5px;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
