:root {
    /* Eventia Brand — Celebration Palette */
    --primary-color: #6366f1;       
    --primary-hover: #4f46e5;       
    --secondary-color: #a855f7;     
    --accent-color: #fbbf24;        
    
    /* Variables Base */
    --bg-color: #F5F3FF;            /* Lavender Mist */
    --surface-color: #FFFFFF;
    --text-color: #1e1b4b;          /* Dark Indigo */
    --text-muted: #6b7280;
    --border-color: #e0e7ff;        /* Light Indigo Border */
    
    /* Semantics */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;

    /* Metrics */
    --sidebar-width: 280px;
    --topbar-height: 64px;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --font-sans: 'Inter', system-ui, sans-serif;
}

[data-theme="dark"] {
    --bg-app: #0f172a;
    --bg-surface: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: #334155;
}

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

body {
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(circle at 2px 2px, rgba(99, 102, 241, 0.05) 1px, transparent 0);
    background-size: 24px 24px;
    color: var(--text-color);
    font-family: var(--font-sans);
    -webkit-font-smoothing: antialiased;
}

/* Componentes Globales */
.form-group { margin-bottom: 1.5rem; }
.form-group label { display: block; font-weight: 500; margin-bottom: 0.5rem; color: var(--text-color); }
.form-input, .form-select { 
    width: 100%; padding: 0.75rem; border: 1px solid var(--border-color); border-radius: 8px; font-family: inherit;
    transition: border-color 0.2s;
}
.form-input:focus, .form-select:focus { border-color: var(--primary-color); outline: none; }

.mt-md { margin-top: 1.5rem; }
.mt-lg { margin-top: 2.5rem; }

/* Modal System */
.modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); display: none; align-items: center; justify-content: center; z-index: 1000;
    backdrop-filter: blur(4px);
}
.modal.active { display: flex; }
.modal-content { 
    background: var(--surface-color); padding: 2.5rem; border-radius: 16px; width: 500px; max-width: 90%;
    max-height: 90vh; overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1); position: relative;
}
.close-modal { position: absolute; top: 1.5rem; right: 1.5rem; cursor: pointer; font-size: 1.5rem; color: var(--text-muted); }

/* Buttons Enhancement */
.btn-secondary { background: #f3f4f6; color: var(--text-color); }
.btn-secondary:hover { background: #e5e7eb; }

.btn-success { background: #10b981; color: white; }
.btn-success:hover { background: #059669; }

.btn-icon { background: none; border: none; cursor: pointer; font-size: 1.1rem; padding: 4px; border-radius: 4px; transition: background 0.2s; }
.btn-icon:hover { background: #f3f4f6; }

/* Badges */
.badge { padding: 4px 12px; border-radius: 99px; font-size: 0.75rem; font-weight: 600; }
.badge-info { background: #e0f2fe; color: #0369a1; }
.badge-success { background: #dcfce7; color: #15803d; }
.badge-danger { background: #fee2e2; color: #b91c1c; }
.badge-warning { background: #fef9c3; color: #854d0e; }

/* Toolbar Filter */
.filter-bar { display: flex; gap: 1rem; align-items: center; background: white; padding: 1rem; border-radius: 12px; border: 1px solid var(--border-color); }
.filter-bar .form-input { max-width: 300px; }
.filter-bar .form-select { max-width: 200px; }

/* Dashboard Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.5rem; margin-bottom: 2rem; }
.stat-card { background: var(--surface-color); padding: 1.5rem; border-radius: 12px; display: flex; align-items: center; gap: 1rem; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); border: 1px solid rgba(0,0,0,0.05); transition: transform 0.2s; }
.stat-card:hover { transform: translateY(-3px); }
.stat-icon { font-size: 2rem; background: var(--bg-color); width: 50px; height: 50px; display: flex; align-items: center; justify-content: center; border-radius: 10px; }
.stat-info h3 { font-size: 1.5rem; font-weight: 700; color: var(--primary-color); }
.stat-info p { font-size: 0.85rem; color: var(--text-muted); }
/* Dashboard & Panels */
.surface-panel { background: white; padding: 1.5rem; border-radius: 12px; border: 1px solid var(--border-color); }
.text-center { text-align: center; }
.text-lg { font-size: 1.25rem; }
.font-bold { font-weight: 700; }
.btn-full { width: 100%; display: block; text-align: center; }
.text-muted { color: var(--text-muted); }

/* App Shell Layout */
.app-shell {
    display: none; /* Oculto por defecto hasta que auth lo autorice */
    height: 100vh;
    overflow: hidden;
}

.app-shell.authenticated {
    display: flex;
}

/* Sidebar - Cosmic Celebration Gradient */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(165deg, #1e1b4b 0%, #312e81 30%, #4c1d95 70%, #831843 100%);
    border-right: none;
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
    z-index: 10;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.2);
    position: relative;
    overflow: hidden;
}

.sidebar::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.05) 0%, transparent 70%);
    pointer-events: none;
}

.sidebar-header {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--border-color);
    gap: 0.75rem;
}

.tenant-logo {
    width: 32px;
    height: 32px;
    background: rgba(255,255,255,0.2);
    border-radius: var(--radius-sm);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.15);
}

.tenant-name {
    font-size: 1rem;
    font-weight: 600;
    color: white;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 1rem;
}

.nav-group-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    font-weight: 600;
    color: rgba(255,255,255,0.45);
    margin: 1.5rem 0 0.5rem 0.75rem;
    letter-spacing: 0.08em;
}

.nav-group-title:first-child {
    margin-top: 0;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 0.6rem 0.75rem;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    border-radius: var(--radius-md);
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-item:hover {
    background-color: rgba(255,255,255,0.1);
    color: white;
}

.nav-item.active {
    background: linear-gradient(135deg, #f59e0b, #f97316);
    color: white;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
    font-weight: 600;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}

/* Main Workspace */
.workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Topbar */
.topbar {
    height: var(--topbar-height);
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    z-index: 5;
}

.search-bar input {
    background-color: var(--bg-app);
    border: 1px solid transparent;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-lg);
    width: 300px;
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text-primary);
    transition: border-color 0.2s;
}

.search-bar input:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: var(--bg-surface);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.icon-button {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--text-secondary);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-button::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 8px;
    height: 8px;
    background-color: var(--danger);
    border-radius: 50%;
    border: 2px solid var(--bg-surface);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
}

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

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

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

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

/* Content Area */
.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    background-color: var(--bg-app);
}

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

h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

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

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

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
}

.metric-card {
    background: rgba(255, 255, 255, 0.9);
    padding: 1.8rem;
    border-radius: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 6px;
    height: 100%;
    background: linear-gradient(180deg, var(--primary-color), var(--vibrant-pink));
}

.metric-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 40px rgba(99, 102, 241, 0.12);
    background: white;
}

.metric-value {
    font-size: 2.2rem !important;
    background: linear-gradient(135deg, #1e1b4b 0%, #6366f1 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800 !important;
}

.metric-title {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
}

.metric-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
}

.metric-trend {
    font-size: 0.8rem;
    font-weight: 500;
}

.metric-trend.positive { color: var(--success); }
.metric-trend.negative { color: var(--danger); }

/* Utilities */
.mt-lg { margin-top: 2.5rem; }

/* Tables */
.table-container {
    background-color: var(--bg-surface);
    border-radius: var(--radius-md);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border: 1px solid var(--border-color);
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table th {
    background-color: var(--bg-app);
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 600;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.data-table td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr:hover {
    background-color: var(--bg-app);
}

/* Badges */
.badge {
    padding: 0.25rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

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

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

/* Custom Progress Bar for Table */
.progress-bar-container {
    height: 6px;
    background-color: var(--bg-app);
    border-radius: 999px;
    margin-bottom: 4px;
    width: 100px;
}
.progress-bar {
    height: 100%;
    background-color: var(--success);
    border-radius: 999px;
}
.progress-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
}
