:root {
    /* Colores Patrios Base */
    --color-red: #D52B1E;
    --color-white: #FFFFFF;
    --color-blue: #0038A8;

    /* Light Theme (Por defecto) */
    --bg-main: #f0f4f8;
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.4);
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --sidebar-bg: rgba(255, 255, 255, 0.95);
    --input-bg: #f8fafc;
    --input-border: #cbd5e1;
    --btn-primary: var(--color-red);
    --btn-primary-hover: #b92015;
    --btn-secondary: var(--color-blue);
    --card-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
}

[data-theme="dark"] {
    /* Dark Theme */
    --bg-main: #0f172a;
    --glass-bg: rgba(30, 41, 59, 0.85);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --sidebar-bg: rgba(15, 23, 42, 0.95);
    --input-bg: #1e293b;
    --input-border: #334155;
    --card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
    min-height: 100vh;
    display: flex;
}

/* Background Blobs for Glassmorphism */
.background-blobs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.5;
    z-index: -1;
    animation: float 10s infinite ease-in-out alternate;
}

.blob-1 {
    top: -10%; left: -10%;
    width: 500px; height: 500px;
    background: var(--color-red);
    opacity: 0.2;
}

.blob-2 {
    bottom: -10%; right: -10%;
    width: 400px; height: 400px;
    background: var(--color-blue);
    opacity: 0.15;
}

@keyframes float {
    0% { transform: translateY(0px) scale(1); }
    100% { transform: translateY(30px) scale(1.05); }
}

/* Auth / Login Container */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    width: 100vw;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: var(--card-shadow);
    padding: 2rem;
}

.login-box {
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-box h2 {
    color: var(--color-red);
    margin-bottom: 0.5rem;
}

.login-box p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 0.9rem;
}

/* Layout Dashboard */
.sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    height: 100vh;
    position: fixed;
    backdrop-filter: blur(10px);
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 2rem;
}

.sidebar-header h2 {
    font-size: 1.2rem;
    color: var(--color-red);
}

.sidebar-menu {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 15px;
    text-decoration: none;
    color: var(--text-secondary);
    border-radius: 8px;
    transition: all 0.2s;
    font-weight: 500;
}

.nav-item:hover, .nav-item.active {
    background: rgba(213, 43, 30, 0.1); /* Red low opacity */
    color: var(--color-red);
}

.user-profile {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.user-info h4 { font-size: 0.95rem; }
.user-info p { font-size: 0.8rem; color: var(--text-secondary); }

.logout-btn {
    background: none;
    border: 1px solid var(--input-border);
    color: var(--text-primary);
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    width: 100%;
}
.logout-btn:hover {
    background: rgba(213, 43, 30, 0.1);
    color: var(--color-red);
    border-color: var(--color-red);
}

/* Main Content */
.main-content {
    margin-left: 280px;
    padding: 2rem;
    flex: 1;
    max-width: calc(100vw - 280px);
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.top-bar h1 {
    font-size: 1.8rem;
    font-weight: 600;
}

.theme-toggle {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    border-radius: 50%;
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    box-shadow: var(--card-shadow);
}

/* Formularios y Botones */
.form-group {
    margin-bottom: 1.2rem;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--input-border);
    background: var(--input-bg);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s;
}

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

.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

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

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

.btn-secondary {
    background: var(--glass-bg);
    border: 1px solid var(--input-border);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--input-bg);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(5px);
}

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

.modal-content {
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

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

.close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
}

/* Tablas */
.table-container {
    width: 100%;
    overflow-x: auto;
}

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

th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--glass-border);
}

th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
}

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

.badge.pendiente   { background: rgba(245, 158, 11, 0.1); color: #f59e0b; }
.badge.recibido    { background: rgba(16, 185, 129, 0.1); color: #10b981; }
.badge.derivado    { background: rgba(0, 56, 168, 0.1);   color: var(--color-blue); }
.badge.finalizado  { background: rgba(239, 68, 68, 0.12); color: #ef4444; }

.historial-firma {
    background: rgba(0,0,0,0.03);
    padding: 10px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.8rem;
    white-space: pre-wrap;
    border-left: 3px solid var(--color-blue);
    margin-top: 10px;
}

[data-theme="dark"] .historial-firma {
    background: rgba(255,255,255,0.05);
}
