/* ==========================================
   MAIN.CSS — Design System & Global Styles
   Fiambres y Quesos El Chingón — ERP
   ========================================== */

/* --- CSS Custom Properties --- */
:root {
    /* Colors — El Chingón Brand: Negro, Rojo, Blanco */
    --primary: #c41e2f;
    --primary-hover: #a3182a;
    --primary-light: rgba(196, 30, 47, 0.15);
    --secondary: #8b1a2b;
    --accent: #d4a017;
    --accent-light: rgba(212, 160, 23, 0.15);
    --success: #10b981;
    --success-light: rgba(16, 185, 129, 0.15);
    --warning: #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.15);
    --danger: #ef4444;
    --danger-light: rgba(239, 68, 68, 0.15);

    /* Backgrounds — True Black */
    --bg-body: #0a0a0a;
    --bg-surface: #161616;
    --bg-surface-2: #222222;
    --bg-surface-3: #333333;
    --bg-glass: rgba(22, 22, 22, 0.8);

    /* Text */
    --text: #f5f0eb;
    --text-secondary: #c9c0b6;
    --text-muted: #8a8078;
    --text-dark: #0a0a0a;

    /* Borders */
    --border: rgba(196, 30, 47, 0.18);
    --border-light: rgba(138, 128, 120, 0.12);

    /* Spacing */
    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
    --topbar-height: 64px;

    /* Typography */
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* Radius */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
    --shadow: 0 4px 12px rgba(0,0,0,0.5);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.6);
    --shadow-glow: 0 0 20px rgba(196, 30, 47, 0.35);

    /* Transitions */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.15s ease;
}

/* --- CSS Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
    font-family: var(--font);
    background: var(--bg-body);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; }

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-surface); }
::-webkit-scrollbar-thumb { background: var(--bg-surface-3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ==========================================
   LOGIN SCREEN
   ========================================== */
.login-screen {
    position: fixed; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-body);
    z-index: 9999;
}
.login-bg-effects { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.login-orb {
    position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.35;
    animation: orb-float 8s ease-in-out infinite;
}
.login-orb-1 { width: 400px; height: 400px; background: #c41e2f; top: -10%; left: -5%; }
.login-orb-2 { width: 300px; height: 300px; background: #8b1a2b; bottom: -10%; right: -5%; animation-delay: 3s; }
.login-orb-3 { width: 200px; height: 200px; background: #d4a017; top: 50%; left: 50%; animation-delay: 5s; }
@keyframes orb-float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -20px) scale(1.05); }
    66% { transform: translate(-20px, 20px) scale(0.95); }
}

.login-card {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 40px;
    box-shadow: var(--shadow-lg);
}
.login-header { text-align: center; margin-bottom: 32px; }
.login-logo {
    margin-bottom: 16px;
}
.login-logo img {
    max-width: 280px;
    margin: 0 auto;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.5));
    animation: logo-breathe 3s ease-in-out infinite;
}
@keyframes logo-breathe {
    0%, 100% { transform: scale(1); filter: drop-shadow(0 4px 12px rgba(0,0,0,0.5)); }
    50% { transform: scale(1.02); filter: drop-shadow(0 6px 20px rgba(196, 30, 47, 0.3)); }
}
.login-header h1 {
    font-size: 1.3rem; font-weight: 700;
    background: linear-gradient(135deg, #c41e2f, #d4a017);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.login-header p { color: var(--text-muted); font-size: 0.875rem; margin-top: 4px; }
/* Checkered accent line */
.login-accent-line {
    height: 4px; margin: 12px auto 0;
    width: 120px;
    background: repeating-linear-gradient(90deg, #c41e2f 0, #c41e2f 8px, #f5f0eb 8px, #f5f0eb 16px);
    border-radius: 2px;
}

/* --- 3D Floating Logos Background --- */
.login-3d-scene {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    perspective: 1200px;
    perspective-origin: 50% 50%;
    z-index: 0;
}
.floating-logo {
    position: absolute;
    opacity: 0.06;
    filter: grayscale(0.3) drop-shadow(0 0 30px rgba(196, 30, 47, 0.2));
    transform-style: preserve-3d;
    will-change: transform;
    animation: float-3d 18s ease-in-out infinite;
}

/* Instance positions, sizes and delays — scattered around */
.fl-1 {
    width: 320px; top: -5%; left: -8%;
    animation-delay: 0s;
    animation-duration: 20s;
    opacity: 0.07;
}
.fl-2 {
    width: 220px; bottom: 5%; right: -6%;
    animation-delay: -4s;
    animation-duration: 24s;
    opacity: 0.05;
}
.fl-3 {
    width: 180px; top: 15%; right: 8%;
    animation-delay: -8s;
    animation-duration: 22s;
    opacity: 0.04;
}
.fl-4 {
    width: 260px; bottom: -8%; left: 10%;
    animation-delay: -12s;
    animation-duration: 26s;
    opacity: 0.06;
}
.fl-5 {
    width: 140px; top: 55%; left: -4%;
    animation-delay: -3s;
    animation-duration: 19s;
    opacity: 0.035;
}
.fl-6 {
    width: 200px; top: -10%; right: 30%;
    animation-delay: -7s;
    animation-duration: 28s;
    opacity: 0.04;
}
.fl-7 {
    width: 150px; bottom: 15%; right: 25%;
    animation-delay: -15s;
    animation-duration: 21s;
    opacity: 0.05;
}

/* 3D Float Animation — rotates on X, Y, Z and drifts */
@keyframes float-3d {
    0%   { transform: translate3d(0, 0, 0)      rotateX(0deg)  rotateY(0deg)  rotateZ(0deg)  scale(1);    }
    15%  { transform: translate3d(20px, -30px, 50px)  rotateX(8deg)  rotateY(-12deg) rotateZ(3deg)  scale(1.04); }
    30%  { transform: translate3d(-15px, 15px, -30px) rotateX(-5deg) rotateY(15deg)  rotateZ(-5deg) scale(0.97); }
    50%  { transform: translate3d(30px, 20px, 80px)   rotateX(12deg) rotateY(-8deg)  rotateZ(6deg)  scale(1.06); }
    70%  { transform: translate3d(-25px, -10px, -60px) rotateX(-10deg) rotateY(18deg) rotateZ(-4deg) scale(0.95); }
    85%  { transform: translate3d(10px, -25px, 40px)  rotateX(6deg)  rotateY(-5deg)  rotateZ(2deg)  scale(1.02); }
    100% { transform: translate3d(0, 0, 0)      rotateX(0deg)  rotateY(0deg)  rotateZ(0deg)  scale(1);    }
}

/* Raise the login-container above the 3D scene */
.login-container { position: relative; z-index: 2; width: 100%; max-width: 460px; padding: 20px; }

.login-form .form-group { margin-bottom: 20px; }
.login-form label { display: block; font-size: 0.875rem; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.input-icon-wrapper { position: relative; }
.input-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-size: 1rem; pointer-events: none; }
.input-icon-wrapper input {
    width: 100%; padding: 12px 16px 12px 44px;
    background: var(--bg-surface-2); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text); font-size: 0.95rem;
    transition: var(--transition);
}
.input-icon-wrapper input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.input-icon-wrapper input::placeholder { color: var(--text-muted); }
.login-error { background: var(--danger-light); color: var(--danger); padding: 10px 14px; border-radius: var(--radius-sm); font-size: 0.85rem; margin-bottom: 16px; border: 1px solid rgba(239,68,68,0.3); }
.login-footer { text-align: center; margin-top: 24px; }
.login-footer p { font-size: 0.75rem; color: var(--text-muted); }

/* ==========================================
   APP LAYOUT
   ========================================== */
.app-layout { display: flex; min-height: 100vh; }

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed; left: 0; top: 0;
    background: linear-gradient(180deg, #1a0a0e 0%, #0a0a0a 100%);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    z-index: 1000;
    transition: var(--transition);
    overflow-y: auto;
}
.sidebar-header {
    padding: 14px 16px; display: flex; align-items: center; gap: 10px;
    border-bottom: 1px solid var(--border);
    min-height: 65px;
}
.sidebar-logo {
    width: 40px; height: 40px; flex-shrink: 0;
}
.sidebar-logo img {
    width: 100%; height: 100%;
    object-fit: contain;
    border-radius: 6px;
}
.sidebar-title {
    font-size: 1rem; font-weight: 700;
    background: linear-gradient(135deg, #c41e2f, #d4a017);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
    line-height: 1.2;
}
.sidebar-title small {
    display: block; font-size: 0.65rem; font-weight: 500;
    -webkit-text-fill-color: var(--text-muted);
}
.sidebar-close-btn { display: none; background: none; border: none; color: var(--text-muted); font-size: 1.2rem; margin-left: auto; }
.sidebar-user {
    padding: 16px 20px; display: flex; align-items: center; gap: 12px;
    border-bottom: 1px solid var(--border-light);
}
.sidebar-user-avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: linear-gradient(135deg, #c41e2f, #8b1a2b);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.9rem; flex-shrink: 0;
    color: white;
}
.sidebar-user-name { font-weight: 600; font-size: 0.9rem; display: block; }
.sidebar-user-role { font-size: 0.75rem; color: var(--text-muted); display: block; }

/* --- Nav Items --- */
.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px; border-radius: var(--radius);
    color: var(--text-secondary); font-size: 0.9rem; font-weight: 500;
    transition: var(--transition); position: relative;
    margin-bottom: 2px; border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--primary-light); color: var(--text); }
.nav-item.active { background: var(--primary); color: white; box-shadow: var(--shadow-glow); }
.nav-icon { font-size: 1.15rem; width: 24px; text-align: center; flex-shrink: 0; }
.nav-label { white-space: nowrap; }
.nav-badge {
    margin-left: auto; background: var(--danger); color: white;
    font-size: 0.7rem; font-weight: 700; padding: 2px 7px; border-radius: 50px;
    animation: pulse-badge 2s ease-in-out infinite;
}
@keyframes pulse-badge {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}
.nav-divider { height: 1px; background: var(--border-light); margin: 12px 14px; }
.nav-section-title { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 1.2px; color: var(--text-muted); padding: 4px 14px; display: block; }

/* Sidebar Footer */
.sidebar-footer { padding: 10px; border-top: 1px solid var(--border-light); }
.nav-item-logout:hover { background: var(--danger-light); color: var(--danger); }

/* --- Sidebar Overlay --- */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 999; }

/* --- Main Content --- */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
}

/* --- Topbar --- */
.topbar {
    height: var(--topbar-height); padding: 0 24px;
    display: flex; align-items: center; justify-content: space-between;
    background: var(--bg-glass); backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 100;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.menu-toggle-btn { display: none; background: none; border: none; color: var(--text); font-size: 1.5rem; }
.page-title { font-size: 1.15rem; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 16px; }

/* Dollar Widget */
.dollar-widget {
    display: flex; align-items: center; gap: 12px;
    background: var(--bg-surface-2); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 6px 14px;
}
.dollar-item { text-align: center; }
.dollar-label { display: block; font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.dollar-value { display: block; font-size: 0.85rem; font-weight: 700; color: var(--success); }
.dollar-blue { color: var(--accent) !important; }
.dollar-divider { width: 1px; height: 28px; background: var(--border); }

/* Scanner indicator */
.scanner-indicator { font-size: 1.1rem; opacity: 0.4; transition: var(--transition); }
.scanner-indicator.active { opacity: 1; animation: pulse-badge 1.5s infinite; }

/* Topbar buttons */
.topbar-btn { background: none; border: none; font-size: 1.3rem; color: var(--text-secondary); position: relative; transition: var(--transition); padding: 4px; }
.topbar-btn:hover { color: var(--text); transform: scale(1.1); }
.topbar-badge {
    position: absolute; top: -4px; right: -6px;
    background: var(--primary); color: white;
    font-size: 0.6rem; font-weight: 700;
    min-width: 18px; height: 18px; line-height: 18px;
    text-align: center; border-radius: 50px;
    animation: pulse-badge 2s infinite;
}
.topbar-user { display: flex; align-items: center; gap: 8px; }
.topbar-user-name { font-size: 0.85rem; font-weight: 500; color: var(--text-secondary); }
.topbar-user-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: linear-gradient(135deg, #c41e2f, #8b1a2b);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.8rem; color: white;
}

/* --- Page Content --- */
.page-content { flex: 1; padding: 24px; }

/* --- Loading Skeleton --- */
.loading-skeleton { display: grid; gap: 16px; }
.skeleton-card {
    height: 120px; border-radius: var(--radius);
    background: linear-gradient(90deg, var(--bg-surface) 25%, var(--bg-surface-2) 50%, var(--bg-surface) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
}
@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* --- Glass Card --- */
.glass-card {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
    transition: var(--transition);
}
.glass-card:hover { border-color: rgba(196, 30, 47, 0.3); box-shadow: var(--shadow-lg); }

/* --- Section Headers --- */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.section-header h3 { font-size: 1.1rem; font-weight: 600; }

/* --- Empty State --- */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; opacity: 0.5; }
.empty-state p { font-size: 0.95rem; }
