/* ============= CSS Variables ============= */
:root {
    --sidebar-width: 250px;
    --sidebar-bg: #1a1f36;
    --sidebar-hover: #272d45;
    --sidebar-active: #3b4568;
    --sidebar-text: #a4b0cc;
    --sidebar-section: #5a6688;
    --navbar-bg: #fff;
    --navbar-border: #e2e6ef;
    --content-bg: #f4f6fa;
    --card-bg: #fff;
    --card-border: #e2e6ef;
    --primary: #1a73e8;
    --primary-hover: #1557b0;
    --success: #34a853;
    --warning: #fbbc04;
    --danger: #ea4335;
    --danger-hover: #d33426;
    --info: #4285f4;
    --text: #202124;
    --text-secondary: #5f6368;
    --text-muted: #80868b;
    --radius: 8px;
    --radius-sm: 4px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
}

/* ============= Reset ============= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body { font-family: var(--font); background: var(--content-bg); color: var(--text); line-height: 1.6; }

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

/* ============= Sidebar ============= */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    z-index: 1000;
    transition: transform 0.25s ease;
    display: flex; flex-direction: column;
}
.sidebar-brand { padding: 20px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.sidebar-brand a { color: #fff; text-decoration: none; font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.brand-icon { font-size: 24px; color: var(--primary); }
.sidebar-nav { list-style: none; padding: 12px 0; flex: 1; }
.sidebar-nav li { margin: 2px 0; }
.sidebar-nav li a {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 20px; color: var(--sidebar-text);
    text-decoration: none; font-size: 13px; font-weight: 500;
    transition: all 0.15s;
}
.sidebar-nav li a:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-nav li a.active { background: var(--sidebar-active); color: #fff; border-left: 3px solid var(--primary); }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }
.nav-section { padding: 16px 20px 6px; font-size: 10px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--sidebar-section); font-weight: 600; }
.nav-section:first-of-type { padding-top: 8px; }

/* ============= Main Content ============= */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: 56px;
    padding: 24px;
    flex: 1;
    min-height: calc(100vh - 56px);
}

/* ============= Navbar ============= */
.navbar {
    position: fixed; top: 0; left: var(--sidebar-width); right: 0;
    height: 56px; background: var(--navbar-bg);
    border-bottom: 1px solid var(--navbar-border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 24px; z-index: 900;
    box-shadow: var(--shadow-sm);
}
.navbar-info { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.navbar-divider { color: var(--text-muted); }
.empresa-name { color: var(--text-secondary); font-weight: 500; }
.sede-label { font-weight: 600; color: var(--text); }
.sede-selector { display: inline-flex; }
.sede-select { padding: 4px 8px; border: 1px solid var(--navbar-border); border-radius: var(--radius-sm); font-size: 13px; background: #f8f9fa; cursor: pointer; }
.navbar-user { display: flex; align-items: center; gap: 12px; }
.user-rol { font-size: 11px; background: #e8f0fe; color: var(--primary); padding: 2px 10px; border-radius: 12px; font-weight: 600; }
.user-dropdown { position: relative; }
.user-btn { background: none; border: 1px solid var(--navbar-border); padding: 6px 12px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px; color: var(--text); display: flex; align-items: center; gap: 6px; }
.user-btn:hover { background: #f1f3f4; }
.user-menu { display: none; position: absolute; right: 0; top: 100%; margin-top: 4px; background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 160px; z-index: 1100; }
.user-dropdown:hover .user-menu { display: block; }
.user-menu a { display: block; padding: 10px 16px; color: var(--text); text-decoration: none; font-size: 13px; }
.user-menu a:hover { background: #f1f3f4; }
.sidebar-toggle { display: none; background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text); padding: 4px 8px; }

/* ============= Cards ============= */
.card { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; box-shadow: var(--shadow-sm); }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--card-border); }
.card-header h2, .card-header h3 { font-size: 16px; font-weight: 600; color: var(--text); }
.card-body { }
.card-footer { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--card-border); }

/* ============= Page Title ============= */
.page-title { font-size: 22px; font-weight: 700; margin-bottom: 20px; color: var(--text); }
.page-actions { display: flex; gap: 8px; margin-bottom: 16px; }

/* ============= Buttons ============= */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border: 1px solid transparent; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; cursor: pointer; text-decoration: none; transition: all 0.15s; line-height: 1.4; white-space: nowrap; font-family: var(--font); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #2d9249; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-hover); }
.btn-warning { background: var(--warning); color: #202124; border-color: var(--warning); }
.btn-outline { background: #fff; color: var(--text); border-color: var(--card-border); }
.btn-outline:hover { background: #f1f3f4; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-icon { padding: 6px 8px; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ============= Forms ============= */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 4px; font-weight: 600; font-size: 12px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.3px; }
.form-control { width: 100%; padding: 9px 12px; border: 1px solid var(--card-border); border-radius: var(--radius-sm); font-size: 13px; font-family: var(--font); color: var(--text); background: #fff; transition: border-color 0.15s; }
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(26,115,232,0.15); }
.form-control-sm { padding: 6px 10px; font-size: 12px; }
select.form-control { cursor: pointer; -webkit-appearance: none; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235f6368' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }
textarea.form-control { min-height: 80px; resize: vertical; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.form-check { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.form-check input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; }
.form-inline { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.form-text { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ============= Tables ============= */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
table th { background: #f8f9fa; padding: 10px 12px; text-align: left; font-weight: 600; color: var(--text-secondary); border-bottom: 2px solid var(--card-border); font-size: 12px; text-transform: uppercase; letter-spacing: 0.3px; white-space: nowrap; }
table td { padding: 10px 12px; border-bottom: 1px solid var(--card-border); color: var(--text); }
table tbody tr:hover { background: #f8fafd; }
table tbody tr:nth-child(even) { background: #fafbfc; }
table tbody tr:nth-child(even):hover { background: #f0f4f8; }
.table-actions { display: flex; gap: 4px; }
.table-badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.badge-success { background: #e6f4ea; color: #137333; }
.badge-warning { background: #fef7e0; color: #a46b00; }
.badge-danger { background: #fce8e6; color: #c5221f; }
.badge-info { background: #e8f0fe; color: #1967d2; }
.badge-default { background: #f1f3f4; color: #5f6368; }

/* ============= Alerts ============= */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 13px; border: 1px solid; }
.alert-success { background: #e6f4ea; color: #137333; border-color: #ceead6; }
.alert-danger { background: #fce8e6; color: #c5221f; border-color: #f5c6cb; }
.alert-warning { background: #fef7e0; color: #a46b00; border-color: #feefc3; }
.alert-info { background: #e8f0fe; color: #1967d2; border-color: #d2e3fc; }
.alert-dismiss { float: right; cursor: pointer; background: none; border: none; font-size: 16px; color: inherit; opacity: 0.7; }

/* ============= Pagination ============= */
.pagination { margin-top: 16px; }
.pagination ul { display: flex; list-style: none; gap: 4px; }
.pagination li a, .pagination li span { display: block; padding: 6px 12px; border: 1px solid var(--card-border); border-radius: var(--radius-sm); font-size: 13px; color: var(--text); text-decoration: none; background: #fff; }
.pagination li.active a { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination li.disabled span { color: var(--text-muted); cursor: not-allowed; }
.pagination li a:hover:not(.active) { background: #f1f3f4; }

/* ============= Breadcrumb ============= */
.breadcrumb { margin-bottom: 16px; }
.breadcrumb ul { display: flex; list-style: none; gap: 4px; font-size: 12px; }
.breadcrumb li::after { content: '/'; margin: 0 4px; color: var(--text-muted); }
.breadcrumb li:last-child::after { content: ''; }
.breadcrumb li a { color: var(--primary); text-decoration: none; }
.breadcrumb li.current { color: var(--text-secondary); }

/* ============= Modal ============= */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 2000; align-items: center; justify-content: center; }
.modal-overlay.active { display: flex; }
.modal { background: var(--card-bg); border-radius: var(--radius); box-shadow: 0 8px 30px rgba(0,0,0,0.15); width: 90%; max-width: 600px; max-height: 85vh; overflow-y: auto; }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--card-border); display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { font-size: 16px; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); }
.modal-body { padding: 20px; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--card-border); display: flex; justify-content: flex-end; gap: 8px; }

/* ============= Dashboard KPIs ============= */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi-card { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
.kpi-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.kpi-value { font-size: 28px; font-weight: 700; color: var(--text); }
.kpi-sub { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.kpi-icon { float: right; font-size: 28px; opacity: 0.2; }

/* ============= Login Page ============= */
.login-page { display: flex; justify-content: center; align-items: center; min-height: 100vh; background: linear-gradient(135deg, #1a1f36 0%, #2d3154 100%); }
.login-card { background: #fff; border-radius: 12px; padding: 48px; width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.login-logo { text-align: center; margin-bottom: 32px; font-size: 28px; font-weight: 700; color: var(--text); }
.login-logo span { color: var(--primary); }

/* ============= POS Venta ============= */
.pos-layout { display: grid; grid-template-columns: 1fr 380px; gap: 20px; }
.pos-products { }
.pos-cart { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; max-height: calc(100vh - 140px); }
.pos-cart-header { border-bottom: 1px solid var(--card-border); padding-bottom: 12px; margin-bottom: 12px; }
.pos-cart-items { flex: 1; overflow-y: auto; margin-bottom: 12px; }
.pos-cart-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid #f1f3f4; font-size: 13px; }
.pos-cart-item img { width: 40px; height: 40px; object-fit: cover; border-radius: 4px; }
.pos-cart-footer { border-top: 1px solid var(--card-border); padding-top: 12px; }
.pos-search { margin-bottom: 16px; }
.pos-search input { width: 100%; padding: 10px 16px; border: 2px solid var(--card-border); border-radius: var(--radius); font-size: 14px; }
.pos-search input:focus { border-color: var(--primary); }
.pos-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.pos-product-card { border: 1px solid var(--card-border); border-radius: var(--radius); padding: 10px; cursor: pointer; text-align: center; transition: box-shadow 0.15s; }
.pos-product-card:hover { box-shadow: var(--shadow); border-color: var(--primary); }
.pos-product-card img { width: 80px; height: 80px; object-fit: cover; border-radius: 4px; margin-bottom: 6px; }
.pos-product-card .name { font-size: 12px; font-weight: 600; }
.pos-product-card .price { font-size: 13px; color: var(--success); font-weight: 600; }

/* ============= Factura Print ============= */
.factura-print { max-width: 800px; margin: 0 auto; background: #fff; padding: 40px; }
.factura-header { display: flex; justify-content: space-between; margin-bottom: 30px; }
.factura-empresa { }
.factura-info { text-align: right; }
.factura-table { width: 100%; margin: 20px 0; }
.factura-table th { background: #f1f3f4; }
.factura-totals { text-align: right; margin-top: 20px; }
.factura-totals div { margin: 4px 0; }
.factura-total { font-size: 18px; font-weight: 700; }

/* ============= Tasa Dashboard ============= */
.tasa-card { text-align: center; padding: 24px; }
.tasa-card .tasa-value { font-size: 36px; font-weight: 700; color: var(--primary); }
.tasa-card .tasa-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ============= Product Image Preview ============= */
.img-preview { width: 120px; height: 120px; object-fit: cover; border-radius: var(--radius); border: 2px dashed var(--card-border); }
.img-thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 4px; }

/* ============= Error Page ============= */
.error-page { text-align: center; padding: 80px 20px; }
.error-page h1 { font-size: 72px; color: var(--danger); }
.error-page p { font-size: 16px; color: var(--text-muted); margin: 16px 0; }

/* ============= Custom Scrollbar ============= */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c4c7cc; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a0a4aa; }
