/* =====================================================
   POS Multisucursal - Sistema de Estilos Principal
   Moneda: Quetzal Guatemalteco (Q)
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* === VARIABLES CSS === */
:root {
    --primary: #1e40af;
    --primary-dark: #1e3a8a;
    --primary-light: #3b82f6;
    --secondary: #0f766e;
    --accent: #f59e0b;
    --danger: #dc2626;
    --success: #16a34a;
    --warning: #d97706;
    --info: #0891b2;

    --bg-dark: #0f172a;
    --bg-sidebar: #1e293b;
    --bg-card: #ffffff;
    --bg-page: #f1f5f9;

    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-white: #ffffff;
    --text-sidebar: #cbd5e1;

    --border: #e2e8f0;
    --border-dark: #334155;

    --sidebar-width: 260px;
    --header-height: 64px;

    --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.04);
    --shadow-lg: 0 10px 25px rgba(0,0,0,.10), 0 6px 10px rgba(0,0,0,.04);
    --shadow-xl: 0 20px 40px rgba(0,0,0,.12);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --transition: 0.2s ease;
}

/* === RESET & BASE === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; scroll-behavior: smooth; }

body {
    font-family: 'Inter', system-ui, sans-serif;
    background-color: var(--bg-page);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a { text-decoration: none; color: var(--primary); }
a:hover { color: var(--primary-dark); }

img { max-width: 100%; }

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

/* === SIDEBAR === */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform var(--transition);
    scrollbar-width: thin;
    scrollbar-color: var(--border-dark) transparent;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-dark); border-radius: 4px; }

.sidebar-brand {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border-dark);
    flex-shrink: 0;
}

.sidebar-brand .brand-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-brand .brand-icon {
    width: 40px; height: 40px;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(59,130,246,.4);
}

.sidebar-brand .brand-text {
    display: flex;
    flex-direction: column;
}

.sidebar-brand .brand-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-white);
    line-height: 1.2;
}

.sidebar-brand .brand-sub {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
}

/* User info */
.sidebar-user {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-dark);
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, var(--secondary), #14b8a6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

.user-info .user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-white);
    line-height: 1.2;
}

.user-info .user-role {
    font-size: 11px;
    color: var(--text-muted);
}

/* Nav menu */
.sidebar-nav {
    padding: 12px 0;
    flex: 1;
}

.nav-section-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-muted);
    padding: 12px 20px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    color: var(--text-sidebar);
    font-size: 13px;
    font-weight: 500;
    border-radius: 0;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    white-space: nowrap;
}

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

.nav-item.active {
    background: linear-gradient(90deg, rgba(59,130,246,.2), rgba(59,130,246,.05));
    color: #93c5fd;
    border-left: 3px solid var(--primary-light);
    padding-left: 17px;
}

.nav-item .nav-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.nav-item .nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-dark);
}

.sidebar-footer a {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-muted);
    font-size: 13px;
    padding: 8px 0;
    transition: color var(--transition);
}

.sidebar-footer a:hover { color: var(--danger); }

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

/* Topbar */
.topbar {
    height: var(--header-height);
    background: white;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 28px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.topbar-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    flex: 1;
}

.topbar-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 400;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-sucursal {
    background: var(--bg-page);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

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

/* === CARDS === */
.card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    overflow: hidden;
}

.card-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-body { padding: 24px; }

/* === STAT CARDS === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

.stat-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 22px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    transition: transform var(--transition), box-shadow var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-card .sc-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: 8px;
}

.stat-card .sc-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.stat-card .sc-icon {
    width: 48px; height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.sc-icon.blue   { background: #dbeafe; color: var(--primary); }
.sc-icon.green  { background: #dcfce7; color: var(--success); }
.sc-icon.amber  { background: #fef3c7; color: var(--warning); }
.sc-icon.red    { background: #fee2e2; color: var(--danger); }
.sc-icon.teal   { background: #ccfbf1; color: var(--secondary); }
.sc-icon.purple { background: #ede9fe; color: #7c3aed; }

/* === TABLES === */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-lg);
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    background: var(--bg-page);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-secondary);
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table td {
    padding: 13px 16px;
    border-bottom: 1px solid #f8fafc;
    font-size: 13.5px;
    color: var(--text-primary);
    vertical-align: middle;
}

.table tr:hover td { background: #f8fafc; }
.table tr:last-child td { border-bottom: none; }

/* === BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 18px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
    white-space: nowrap;
    line-height: 1.4;
    text-decoration: none;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary   { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 12px rgba(30,64,175,.3); color: white;}
.btn-success   { background: var(--success); color: white; }
.btn-success:hover { background: #15803d; color: white; }
.btn-danger    { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; color: white; }
.btn-warning   { background: var(--warning); color: white; }
.btn-warning:hover { background: #b45309; color: white; }
.btn-secondary { background: var(--bg-page); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); color: var(--text-primary); }
.btn-outline   { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary); color: white; }
.btn-sm  { padding: 5px 12px; font-size: 12px; }
.btn-lg  { padding: 11px 24px; font-size: 15px; }
.btn-icon { padding: 7px; border-radius: var(--radius-sm); }
.btn-block { width: 100%; justify-content: center; }

/* === FORMS === */
.form-group { margin-bottom: 18px; }

.form-label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-control, .form-select {
    width: 100%;
    padding: 9px 13px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-primary);
    background: white;
    transition: border-color var(--transition), box-shadow var(--transition);
    font-family: inherit;
    outline: none;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}

.form-control.barcode-input {
    font-size: 15px;
    letter-spacing: .05em;
    background: #f8faff;
    border-color: var(--primary-light);
}

/* Barcode icon indicator */
.barcode-wrap {
    position: relative;
}
.barcode-wrap .barcode-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--primary-light);
    font-size: 18px;
    pointer-events: none;
}

.form-text { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }
.invalid-feedback { font-size: 12px; color: var(--danger); margin-top: 4px; display: block; }

/* Grid forms */
.form-row { display: grid; gap: 16px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row.cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

/* === BADGES === */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.badge-success { background: #dcfce7; color: #15803d; }
.badge-danger  { background: #fee2e2; color: #b91c1c; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info    { background: #e0f2fe; color: #0369a1; }
.badge-secondary { background: #f1f5f9; color: #475569; }
.badge-primary { background: #dbeafe; color: #1e40af; }

/* === ALERTS === */
.alert {
    padding: 13px 18px;
    border-radius: var(--radius-md);
    font-size: 13.5px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 20px;
    border: 1px solid transparent;
}

.alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #15803d; }
.alert-danger  { background: #fef2f2; border-color: #fecaca; color: #dc2626; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert-info    { background: #f0f9ff; border-color: #bae6fd; color: #0369a1; }
.alert .btn-close {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
    opacity: .5;
    font-size: 16px;
    padding: 0;
}
.alert .btn-close:hover { opacity: 1; }

/* === MODAL === */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.6);
    backdrop-filter: blur(3px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}
.modal-overlay.show {
    opacity: 1;
    pointer-events: all;
}
.modal {
    background: white;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(.96) translateY(10px);
    transition: transform var(--transition);
}
.modal-overlay.show .modal { transform: scale(1) translateY(0); }
.modal-header {
    padding: 22px 24px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-title { font-size: 17px; font-weight: 700; }
.modal-body  { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }
.btn-modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); }
.btn-modal-close:hover { color: var(--danger); }

/* === BREADCRUMB === */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    color: var(--text-muted);
    margin-bottom: 20px;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb span.sep { color: var(--border); }
.breadcrumb span.current { color: var(--text-primary); font-weight: 600; }

/* === EMPTY STATE === */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-icon { font-size: 52px; margin-bottom: 16px; opacity: .4; }
.empty-title { font-size: 17px; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; }
.empty-text  { font-size: 14px; }

/* === PAGINATION === */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 20px;
}
.page-link {
    width: 34px; height: 34px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: white;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
}
.page-link:hover { background: var(--primary); color: white; border-color: var(--primary); }
.page-link.active { background: var(--primary); color: white; border-color: var(--primary); }

/* === OVERLAY LOADING === */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    gap: 10px;
    color: var(--text-muted);
    font-size: 14px;
}
.spinner {
    width: 22px; height: 22px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === UTILITIES === */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-primary { color: var(--primary); }
.text-sm { font-size: 12px; }
.text-lg { font-size: 16px; }
.fw-bold { font-weight: 700; }
.fw-medium { font-weight: 500; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.p-0 { padding: 0; }
.w-100 { width: 100%; }

/* Moneda */
.moneda { font-variant-numeric: tabular-nums; font-weight: 600; }
.moneda-positive { color: var(--success); }
.moneda-negative { color: var(--danger); }

/* === SIDEBAR TOGGLE MOBILE === */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    color: var(--text-primary);
    cursor: pointer;
    padding: 4px;
}

/* === RESPONSIVE === */
@media (max-width: 1024px) {
    .form-row.cols-4 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .sidebar-toggle { display: block; }
    .page-content { padding: 16px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .form-row.cols-2,
    .form-row.cols-3,
    .form-row.cols-4 { grid-template-columns: 1fr; }
    .topbar { padding: 0 16px; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
}

/* === PRINT === */
@media print {
    .sidebar, .topbar, .btn, .breadcrumb, .no-print { display: none !important; }
    .main-content { margin-left: 0; }
    .page-content { padding: 0; }
    body { background: white; }
}
