/* ==============================================================================
   ERP INTERNO DE COMPRAS - DESIGN SYSTEM CORE (SaaS Enterprise Premium)
   Inspirado en Microsoft 365, Linear y ERP Moderno
   ============================================================================== */

:root {
    /* Paleta Corporativa Slate & Indigo */
    --bg-main: #f8fafc;
    --bg-surface: #ffffff;
    --bg-sidebar: #0f172a;
    --bg-sidebar-hover: #1e293b;
    --bg-sidebar-active: #2563eb;
    --border-color: #e2e8f0;
    --border-subtle: #f1f5f9;

    /* Tipografía y Textos */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-inverse: #ffffff;

    /* Colores de Marca y Acento */
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --primary-border: #bfdbfe;

    /* Estados del Ciclo de Compras */
    --status-draft: #64748b;
    --status-draft-bg: #f1f5f9;
    --status-pending: #f59e0b;
    --status-pending-bg: #fef3c7;
    --status-review: #3b82f6;
    --status-review-bg: #dbeafe;
    --status-approval: #d97706;
    --status-approval-bg: #fef3c7;
    --status-approved: #10b981;
    --status-approved-bg: #d1fae5;
    --status-rejected: #ef4444;
    --status-rejected-bg: #fee2e2;
    --status-po: #059669;
    --status-po-bg: #ecfdf5;
    --status-invoice: #8b5cf6;
    --status-invoice-bg: #ede9fe;
    --status-paid: #047857;
    --status-paid-bg: #d1fae5;

    /* Sombras y Elevación */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.06);

    /* Radios */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-full: 9999px;

    /* Transiciones */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset y Bases */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Layout Principal */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* SIDEBAR CORPORATIVO */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width var(--transition-normal);
    z-index: 40;
}

.sidebar-header {
    padding: 20px 22px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #2563eb 0%, #38bdf8 100%);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 800;
    font-size: 16px;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.brand-title {
    font-size: 15px;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: -0.2px;
    line-height: 1.2;
}

.brand-subtitle {
    font-size: 10.5px;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #64748b;
    font-weight: 700;
    padding: 10px 12px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    color: #94a3b8;
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: all var(--transition-fast);
    cursor: pointer;
}

.nav-item:hover {
    background-color: var(--bg-sidebar-hover);
    color: #ffffff;
}

.nav-item.active {
    background-color: var(--bg-sidebar-active);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.nav-item-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-item svg {
    width: 18px;
    height: 18px;
    opacity: 0.9;
}

.nav-badge {
    background-color: #ef4444;
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: var(--radius-full);
}

.sidebar-footer {
    padding: 16px 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.2);
}

.mode-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 9px;
    border-radius: var(--radius-full);
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.mode-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 8px #10b981;
}

/* ÁREA DE CONTENIDO Y HEADER */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: var(--bg-main);
}

.header {
    height: 64px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    z-index: 30;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.search-box {
    position: relative;
    width: 320px;
}

.search-box input {
    width: 100%;
    padding: 8px 14px 8px 36px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: #f8fafc;
    font-size: 13px;
    outline: none;
    transition: all var(--transition-fast);
}

.search-box input:focus {
    background: #ffffff;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.search-box svg {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Selector de Rol Demo Rápido */
.demo-role-switcher {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f1f5f9;
    padding: 5px 12px;
    border-radius: var(--radius-md);
    border: 1px solid #e2e8f0;
}

.demo-role-label {
    font-size: 11px;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
}

.demo-role-select {
    background: transparent;
    border: none;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
    outline: none;
}

/* Notificaciones y Perfil */
.btn-icon {
    position: relative;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-icon:hover {
    background: #f8fafc;
    color: var(--text-primary);
}

.notif-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    background: #ef4444;
    color: white;
    font-size: 10px;
    font-weight: 800;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #ffffff;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px;
    border-radius: var(--radius-md);
    cursor: pointer;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, #1e293b 0%, #475569 100%);
    color: white;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
}

.user-info-text {
    line-height: 1.2;
}

.user-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
}

.user-role-badge {
    font-size: 10.5px;
    color: var(--primary);
    font-weight: 600;
}

/* ÁREA DE CONTENIDO SCROLLABLE */
.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 28px;
}

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

.page-title {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.page-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* BOTONES GLOBALES */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: var(--radius-md);
    font-size: 13.5px;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

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

.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.35);
}

.btn-secondary {
    background-color: #ffffff;
    color: var(--text-secondary);
    border-color: var(--border-color);
}

.btn-secondary:hover {
    background-color: #f8fafc;
    color: var(--text-primary);
}

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

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

.btn-danger {
    background-color: #ef4444;
    color: white;
}

.btn-danger:hover {
    background-color: #dc2626;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
    border-radius: var(--radius-sm);
}

/* RESPONSIVE */
@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        bottom: 0;
    }
    .sidebar.open {
        left: 0;
    }
    .header {
        padding: 0 16px;
    }
    .search-box {
        display: none;
    }
    .content-area {
        padding: 16px;
    }
}

/* ==============================================================================
   PANTALLA DE LOGIN INICIAL (SUPERADMIN & ACCESO SQL)
   ============================================================================== */
.login-screen-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 10% 20%, #1e293b 0%, #0f172a 100%);
    z-index: 99999;
    padding: 20px;
    box-sizing: border-box;
}

.login-card {
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.15);
    width: 100%;
    max-width: 460px;
    overflow: hidden;
    animation: loginFadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes loginFadeIn {
    from { opacity: 0; transform: translateY(12px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.login-card-header {
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 50%, #2563eb 100%);
    padding: 32px 24px;
    color: #ffffff;
    text-align: center;
}

.login-card-brand-icon {
    width: 52px;
    height: 52px;
    background: rgba(255, 255, 255, 0.18);
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 22px;
    margin: 0 auto 14px;
    letter-spacing: -0.5px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.login-card-body {
    padding: 28px 26px 32px;
}

.quick-admin-banner {
    background: #eff6ff;
    border: 1.5px solid #bfdbfe;
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
