/* ═══════════════════════════════════════════════════════
   VentaFácil — Design System & Global Styles
   ═══════════════════════════════════════════════════════ */

:root {
    /* Background */
    --bg-primary: #07070d;
    --bg-secondary: #0e0e18;
    --bg-tertiary: #161625;
    --bg-elevated: #1e1e32;
    --bg-hover: #252540;
    --bg-input: #12121f;

    /* Accent */
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.25);
    --accent-subtle: rgba(99, 102, 241, 0.08);

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

    /* Text */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #4b5572;
    --text-inverse: #07070d;

    /* Borders */
    --border: rgba(255, 255, 255, 0.06);
    --border-accent: rgba(99, 102, 241, 0.2);
    --border-hover: rgba(255, 255, 255, 0.12);

    /* Misc */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --shadow: 0 4px 24px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 40px rgba(0,0,0,0.6);
    --transition: 200ms ease;
    --font: 'Inter', -apple-system, sans-serif;
    --glass-bg: rgba(14, 14, 24, 0.88);
    --glass-blur: blur(24px);
}

:root.theme-light {
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --bg-elevated: #ffffff;
    --bg-hover: #e2e8f0;
    --bg-input: #ffffff;

    --accent: #4f46e5;
    --accent-hover: #4338ca;
    --accent-glow: rgba(79, 70, 229, 0.15);
    --accent-subtle: rgba(79, 70, 229, 0.08);

    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --text-inverse: #ffffff;

    --border: #e2e8f0;
    --border-accent: rgba(79, 70, 229, 0.3);
    --border-hover: #cbd5e1;

    --shadow: 0 4px 12px rgba(0,0,0,0.05);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.1);
    --glass-bg: rgba(255, 255, 255, 0.88);
}

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

html { font-size: 14px; }

body {
    font-family: var(--font);
    background: var(--bg-primary);
    background-image: 
        radial-gradient(at 0% 0%, hsla(243, 75%, 58%, 0.15) 0, transparent 50%), 
        radial-gradient(at 100% 0%, hsla(267, 83%, 60%, 0.1) 0, transparent 50%),
        radial-gradient(at 100% 100%, hsla(243, 75%, 58%, 0.1) 0, transparent 50%),
        radial-gradient(at 0% 100%, hsla(267, 83%, 60%, 0.15) 0, transparent 50%);
    color: var(--text-primary);
    line-height: 1.5;
    overflow: hidden;
    height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── Typography ─────────────────────────────── */
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.4rem; font-weight: 600; }
h3 { font-size: 1.15rem; font-weight: 600; }
a { color: var(--accent); text-decoration: none; }

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

/* ─── Sidebar ─────────────────────────────────── */
.sidebar {
    width: 240px;
    min-width: 240px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: var(--transition);
}

.sidebar-header {
    padding: 20px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, var(--accent), #a855f7);
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    color: white;
    box-shadow: 0 8px 16px rgba(99, 102, 241, 0.3);
}
.sidebar-logo svg { width: 20px; height: 20px; }

.sidebar-brand {
    font-size: 1.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-hover), #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

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

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-weight: 500;
    transition: var(--transition);
    text-decoration: none;
    position: relative;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active {
    background: var(--accent-subtle);
    color: var(--accent-hover);
    box-shadow: inset 3px 0 0 var(--accent);
}
.nav-divider { height: 1px; background: var(--border); margin: 8px 14px; }

.sidebar-footer {
    padding: 14px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}
.user-info { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.user-avatar {
    width: 34px; height: 34px;
    background: linear-gradient(135deg, var(--accent), #a855f7);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.85rem; color: white; flex-shrink: 0;
}
.user-details { display: flex; flex-direction: column; min-width: 0; }
.user-name { font-weight: 600; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.7rem; color: var(--text-muted); text-transform: capitalize; }

/* ─── Main Content ────────────────────────────── */
.main-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px;
    background: var(--bg-primary);
}

/* ─── Login ───────────────────────────────────── */
.login-screen {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(99,102,241,0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(168,85,247,0.06) 0%, transparent 50%);
}

.login-card {
    width: 380px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 40px 32px;
    box-shadow: var(--shadow-lg);
    animation: fadeUp 0.5s ease;
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}
.login-logo .logo-icon {
    width: 56px; height: 56px;
    background: linear-gradient(135deg, var(--accent), #a855f7);
    border-radius: var(--radius-lg);
    display: inline-flex; align-items: center; justify-content: center;
    margin-bottom: 16px;
    box-shadow: 0 0 30px var(--accent-glow);
}
.login-logo .logo-icon svg { width: 28px; height: 28px; color: white; }
.login-logo h1 {
    font-size: 1.6rem;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-hover));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.login-logo p { color: var(--text-muted); font-size: 0.9rem; margin-top: 4px; }
.login-footer { text-align: center; color: var(--text-muted); font-size: 0.75rem; margin-top: 24px; }

/* ─── Forms ───────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; font-size: 0.85rem; }

.input-icon {
    position: relative;
}
.input-icon svg {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    width: 16px; height: 16px; color: var(--text-muted); pointer-events: none;
}
.input-icon input { padding-left: 38px; }

input, select, textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.9rem;
    transition: var(--transition);
    outline: none;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
input::placeholder { color: var(--text-muted); }

/* ─── Buttons ─────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 20px;
    border: none; border-radius: var(--radius);
    font-family: var(--font); font-weight: 600; font-size: 0.85rem;
    cursor: pointer; transition: var(--transition);
    white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn:active { transform: scale(0.97); }

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 0 20px var(--accent-glow); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { opacity: 0.9; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { opacity: 0.9; }

.btn-outline {
    background: transparent; border: 1px solid var(--border);
    color: var(--text-secondary);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

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

.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }

.btn-icon {
    width: 36px; height: 36px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: var(--transition);
}
.btn-icon svg { width: 16px; height: 16px; }
.btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-hover); }

/* ─── Cards ───────────────────────────────────── */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: var(--transition);
}
.card:hover { border-color: var(--border-hover); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-weight: 600; font-size: 1rem; display: flex; align-items: center; gap: 8px; }
.card-title svg { width: 18px; height: 18px; color: var(--accent); }

/* ─── Badges ──────────────────────────────────── */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-neutral { background: var(--bg-hover); color: var(--text-secondary); }

/* ─── Tables ──────────────────────────────────── */
.table-wrapper { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
th {
    text-align: left; padding: 12px 16px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-weight: 600; font-size: 0.78rem;
    text-transform: uppercase; letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 0.88rem;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--accent-subtle); }

/* ─── Modal ───────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: var(--glass-blur);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}
.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 28px;
    width: 90%;
    max-width: 520px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 24px 80px rgba(0,0,0,0.8);
    animation: fadeUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-title { font-size: 1.15rem; font-weight: 700; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; }

/* ─── Toast ───────────────────────────────────── */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
    padding: 12px 20px;
    border-radius: var(--radius);
    font-weight: 500;
    font-size: 0.85rem;
    display: flex; align-items: center; gap: 10px;
    animation: slideInRight 0.3s ease;
    box-shadow: var(--shadow);
    min-width: 280px;
}
.toast svg { width: 18px; height: 18px; flex-shrink: 0; }
.toast-success { background: #065f46; color: #a7f3d0; border: 1px solid #10b981; }
.toast-error { background: #7f1d1d; color: #fecaca; border: 1px solid #ef4444; }
.toast-info { background: #1e3a5f; color: #bfdbfe; border: 1px solid #3b82f6; }

/* ─── Alerts ──────────────────────────────────── */
.alert { padding: 10px 14px; border-radius: var(--radius); font-size: 0.85rem; margin-bottom: 12px; }
.alert-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(239,68,68,0.2); }

/* ─── Page Header ─────────────────────────────── */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap; gap: 12px;
}
.page-title { font-size: 1.5rem; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.page-title svg { color: var(--accent); }

/* ─── Search & Filters ────────────────────────── */
.search-bar {
    display: flex; gap: 10px; align-items: center;
    margin-bottom: 16px; flex-wrap: wrap;
}
.search-input {
    position: relative; flex: 1; min-width: 200px;
}
.search-input svg {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    width: 16px; height: 16px; color: var(--text-muted);
}
.search-input input { padding-left: 38px; }

/* ─── POS Specific ────────────────────────────── */
.pos-container { display: flex; height: calc(100vh - 48px); gap: 20px; overflow: hidden; }
.pos-products { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.pos-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); 
    gap: 12px; 
    overflow-y: auto; 
    padding-bottom: 20px;
    padding-right: 5px;
}
.pos-product-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    text-align: left;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    height: 110px;
}
.pos-product-card:hover { border-color: var(--accent); transform: translateY(-2px); background: var(--bg-elevated); }
.pos-product-card .cat-dot { position: absolute; top: 12px; right: 12px; width: 6px; height: 6px; border-radius: 50%; }
.product-name { font-weight: 600; font-size: 0.9rem; line-height: 1.2; height: 2.4em; overflow: hidden; color: var(--text-primary); margin-bottom: 4px; }
.product-meta { display: flex; justify-content: space-between; align-items: flex-end; margin-top: auto; }
.product-price { font-size: 1rem; font-weight: 700; color: var(--accent-hover); }
.product-stock { font-size: 0.7rem; color: var(--text-muted); text-align: right; }
.product-stock.low-stock { color: var(--danger); }
.product-emoji { display: none; } /* User didn't like emojis */

.pos-cart { width: 360px; display: flex; flex-direction: column; background: var(--bg-secondary); border-left: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }

.btn-quotation { background: var(--bg-tertiary); color: var(--text-secondary); border: 1px solid var(--border); margin-top: 8px; }
.btn-quotation:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-hover); }
@media (max-width: 600px) {
    .pos-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
    .main-content { padding: 12px; }
}

/* ─── KPI Cards ───────────────────────────────── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.kpi-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
}
.kpi-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}
.kpi-icon {
    width: 46px;
    height: 46px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.kpi-icon svg {
    width: 22px;
    height: 22px;
}
.kpi-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.1;
}
.kpi-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-top: 2px;
}

/* ─── Pagination ──────────────────────────────── */
.pagination { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 16px; }
.pagination button {
    padding: 6px 12px; border: 1px solid var(--border); background: var(--bg-secondary);
    color: var(--text-secondary); border-radius: var(--radius-sm); cursor: pointer;
    font-family: var(--font); transition: var(--transition);
}
.pagination button:hover { border-color: var(--accent); color: var(--accent); }
.pagination button.active { background: var(--accent); color: white; border-color: var(--accent); }
.pagination button:disabled { opacity: 0.4; cursor: default; }

/* ─── Empty State ─────────────────────────────── */
.empty-state {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 60px 20px; color: var(--text-muted); text-align: center;
}
.empty-state svg { width: 48px; height: 48px; margin-bottom: 16px; opacity: 0.3; }
.empty-state p { font-size: 0.95rem; }

/* ─── Form Grid ───────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full-width { grid-column: 1 / -1; }
@media (max-width: 576px) {
    .form-grid { grid-template-columns: 1fr; }
}

/* ─── Animations ──────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.animate-in { animation: fadeUp 0.3s ease; }

/* ─── Utilities ───────────────────────────────── */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.gap-1 { gap: 8px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; }
.flex-gap { display: flex; gap: 10px; align-items: center; }
.font-mono { font-family: 'JetBrains Mono', monospace; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.loading { animation: pulse 1.5s ease infinite; }
