/* 
    SISDEL Professional Design System
    Supports Light/Dark Mode via .light-mode class on body
*/

:root {
    /* Transitions */
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-glow: 0 0 15px rgba(37, 99, 235, 0.4);

    /* Sizes */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Theme: Dark (Default) */
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #60a5fa;
    --accent: #8b5cf6;
    --bg-app: #0f172a;
    --bg-surface: rgba(30, 41, 59, 0.8);
    --bg-surface-solid: #1e293b;
    --bg-item: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border-subtle: rgba(255, 255, 255, 0.05);
    --border-strong: rgba(255, 255, 255, 0.1);
    --glass-blur: blur(12px);
    --input-bg: rgba(15, 23, 42, 0.6);

    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.1);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --info: #3b82f6;
    --info-bg: rgba(59, 130, 246, 0.1);
}

/* Theme: Light Mode */
body.light-mode {
    --bg-app: #f1f5f9;
    --bg-surface: rgba(255, 255, 255, 0.85);
    --bg-surface-solid: #ffffff;
    --bg-item: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --border-subtle: rgba(0, 0, 0, 0.05);
    --border-strong: rgba(0, 0, 0, 0.1);
    --input-bg: #f8fafc;
    --shadow-glow: 0 0 10px rgba(37, 99, 235, 0.15);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--bg-app);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    transition: background-color var(--transition-base), color var(--transition-base);
}

/* Background Effects */
.bg-decor {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.bg-decor div {
    position: absolute;
    width: 800px;
    height: 800px;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.15;
}

.light-mode .bg-decor div {
    opacity: 0.1;
}

/* Auth Page Theme */
.auth-page {
    background: url('bg-login.png') no-repeat center center fixed;
    background-size: cover;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    color: white;
}

.auth-page::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, rgba(15, 23, 42, 0.7) 0%, rgba(15, 23, 42, 0.95) 100%);
    z-index: 1;
}

.auth-page .page-container {
    position: relative;
    z-index: 2;
    background: transparent;
}

.auth-page .top-bar {
    border-bottom: none;
}

.decor-1 {
    background: var(--primary);
    top: -200px;
    right: -150px;
    animation: float 20s infinite alternate;
}

.decor-2 {
    background: var(--accent);
    bottom: -200px;
    left: -150px;
    animation: float 25s infinite alternate-reverse;
}

@keyframes float {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(50px, 40px) scale(1.1);
    }
}

/* Layout */
.page-container {
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    padding: 0 1rem;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.page-content {
    flex: 1;
    padding: 2rem 0;
    display: flex;
    flex-direction: column;
}

/* Top Bar */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--border-subtle);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: var(--shadow-glow);
}

.brand-text h1 {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.brand-text p {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Welcome Landing Page */
.welcome-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 4rem 1rem;
    animation: fadeIn var(--transition-slow);
}

.welcome-hero {
    margin-bottom: 3.5rem;
}

.welcome-logo {
    width: 140px;
    height: 140px;
    margin: 0 auto 2.5rem;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 30%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: var(--shadow-xl), 0 0 50px rgba(37, 99, 235, 0.25);
}

.welcome-hero h1 {
    font-size: 4rem;
    font-weight: 900;
    letter-spacing: -0.05em;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.welcome-hero p {
    font-size: 1.25rem;
    color: var(--text-secondary);
    max-width: 650px;
    margin: 0 auto;
    line-height: 1.6;
}

/* Login Card Section (hidden by default if on Welcome) */
.login-section {
    display: none;
    /* Controlled by JS */
    animation: fadeIn var(--transition-slow);
}

.card {
    background: var(--bg-surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    transition: transform var(--transition-base), box-shadow var(--transition-base), background-color var(--transition-base);
}

.login-card {
    max-width: 440px;
    width: 100%;
    padding: 3rem;
    margin: 2rem auto;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.security-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

@keyframes floatGlow {
    0% {
        transform: translateY(15px) scale(0.9);
        box-shadow: 0 0 0 rgba(37, 99, 235, 0);
        opacity: 0;
    }

    50% {
        transform: translateY(-5px) scale(1.05);
        box-shadow: 0 10px 30px rgba(37, 99, 235, 0.7);
        opacity: 1;
    }

    100% {
        transform: translateY(0) scale(1);
        box-shadow: 0 0 15px rgba(37, 99, 235, 0.2);
        opacity: 1;
    }
}

@keyframes orbit {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.security-badge {
    position: relative;
    width: 64px;
    height: 64px;
    background: rgba(37, 99, 235, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    color: var(--primary);
    border: 1px solid rgba(37, 99, 235, 0.1);
    animation: floatGlow 1s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.security-badge::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    padding: 2px;
    border: 2px solid transparent;
    border-top: 2px solid var(--primary);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    animation: orbit 4s linear infinite;
    opacity: 0.7;
    filter: drop-shadow(0 0 5px var(--primary));
}

.form-title {
    font-size: 1.75rem;
    font-weight: 800;
    text-align: center;
    margin-bottom: 0.5rem;
    color: white;
}

.form-subtitle {
    text-align: center;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9rem;
    margin-bottom: 2.5rem;
}

.form-group {
    margin-bottom: 1.75rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.6rem;
    color: var(--text-secondary);
}

.input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 1rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
}

.form-input {
    width: 100%;
    padding: 0.875rem 1rem 0.875rem 3rem;
    background: var(--input-bg);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1rem;
    transition: all var(--transition-base);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
    background: var(--bg-surface-solid);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--transition-base);
    text-decoration: none;
    white-space: nowrap;
}

.btn-lg {
    padding: 1.25rem 3rem;
    font-size: 1.125rem;
    border-radius: var(--radius-lg);
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--bg-item);
    color: var(--text-primary);
}

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

.theme-toggle {
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    color: var(--text-primary);
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    padding: 1.75rem;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-strong);
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 2.25rem;
    font-weight: 800;
    margin-bottom: 0.25rem;
}

.stats-grid.compact {
    gap: 1rem;
    margin-bottom: 1rem;
}

.stats-grid.compact .stat-card {
    padding: 0.85rem 1.25rem;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
}

.stats-grid.compact .stat-value {
    font-size: 1.5rem;
    margin-bottom: 0;
}

.stats-grid.compact .stat-label {
    font-size: 0.85rem;
    font-weight: 600;
}

/* List Items (simplified generic version) */
.list-item {
    display: flex;
    align-items: center;
    padding: 1.25rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    margin-bottom: 0.75rem;
    transition: all var(--transition-base);
}

.list-item:hover {
    background: var(--bg-surface-solid);
    border-color: var(--primary);
}

.avatar {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.25rem;
    color: white;
    flex-shrink: 0;
    margin-right: 1.25rem;
    box-shadow: var(--shadow-sm);
}

.item-info {
    flex: 1;
    min-width: 0;
}

.item-name {
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    font-size: 1.05rem;
}

.item-detail {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease-out;
}

.modal {
    background: var(--bg-surface-solid);
    width: 100%;
    max-width: 500px;
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    position: relative;
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-xl);
}

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

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

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

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

/* Animation Utils */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(15px);
    }

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

.shake {
    animation: shake 0.5s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes shake {

    10%,
    90% {
        transform: translate3d(-1px, 0, 0);
    }

    20%,
    80% {
        transform: translate3d(2px, 0, 0);
    }

    30%,
    50%,
    70% {
        transform: translate3d(-3px, 0, 0);
    }

    40%,
    60% {
        transform: translate3d(3px, 0, 0);
    }
}

/* Utility Badges */
.badge {
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

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

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

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

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

/* Text Utilities */
.text-xs {
    font-size: 0.75rem;
}

.text-sm {
    font-size: 0.875rem;
}

.text-lg {
    font-size: 1.125rem;
}

.text-xl {
    font-size: 1.25rem;
}

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

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

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

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

.font-bold {
    font-weight: 700;
}

.auth-footer-inner {
    display: flex;
    justify-content: space-between;
    margin-top: 1.5rem;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
}

.auth-footer-inner a {
    color: var(--primary-light);
    text-decoration: none;
    transition: color 0.2s;
}

.auth-footer-inner a:hover {
    color: white;
}

.page-footer-nav {
    display: flex;
    justify-content: space-between;
    padding: 2rem 0;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.4);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.page-footer-nav a {
    color: inherit;
    text-decoration: none;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    background: var(--bg-surface);
    padding: 0.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-strong);
}

.tab {
    flex: 1;
    padding: 0.875rem;
    border: none;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
}

.tab.active {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-md);
}

/* Custom Tooltip */
.custom-tooltip {
    position: relative;
    display: inline-flex;
    cursor: pointer;
}

.custom-tooltip-text {
    visibility: hidden;
    width: max-content;
    background-color: rgba(15, 23, 42, 0.98);
    /* Oscuro sólido */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #ffffff;
    /* Texto claro siempre */
    text-align: left;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    position: absolute;
    z-index: 9999;
    bottom: 125%;
    right: 50%;
    transform: translateX(50%);
    opacity: 0;
    transition: opacity 0.1s ease-in-out, visibility 0.1s;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.85rem;
    line-height: 1.4;
}

.custom-tooltip-text::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -6px;
    border-width: 6px;
    border-style: solid;
    border-color: rgba(15, 23, 42, 0.98) transparent transparent transparent;
}

.custom-tooltip:hover .custom-tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* Footer */
.app-footer {
    padding: 2.5rem 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
    border-top: 1px solid var(--border-subtle);
    margin-top: auto;
}

@media (max-width: 768px) {
    .welcome-hero h1 {
        font-size: 2.75rem;
    }

    .welcome-hero p {
        font-size: 1.1rem;
    }

    .login-card {
        padding: 2rem 1.5rem;
    }
}