:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --bg: #f1f5f9;
    --bg-dark: #0f172a;
    --sidebar-bg: #1e293b;
    --card: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1);
    --radius: 12px;
    --radius-sm: 8px;
    --sidebar-width: 260px;
    --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* Auth Pages */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.auth-card {
    background: var(--card);
    padding: 2.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
}

.auth-logo { text-align: center; margin-bottom: 2rem; }
.auth-logo svg { color: var(--primary); margin-bottom: .5rem; }
.auth-logo h1 { font-size: 1.75rem; font-weight: 700; }
.auth-form .form-group { margin-bottom: 1.25rem; }

/* Layout */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #cbd5e1;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    z-index: 100;
    transition: transform .3s;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,.1);
    display: flex;
    align-items: center;
    gap: .75rem;
}

.sidebar-header h2 { color: #fff; font-size: 1.25rem; font-weight: 700; }
.sidebar-header svg { color: var(--primary-light); }

.sidebar-nav { padding: 1rem 0; }

.nav-section { padding: .5rem 1.5rem; font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: #64748b; margin-top: .5rem; }

.nav-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .7rem 1.5rem;
    color: #94a3b8;
    transition: all .2s;
    font-size: .9rem;
}

.nav-link:hover, .nav-link.active {
    background: rgba(99,102,241,.15);
    color: #fff;
}

.nav-link.active { border-right: 3px solid var(--primary); }
.nav-link svg { width: 20px; height: 20px; flex-shrink: 0; }

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
}

.topbar {
    background: var(--card);
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar h1 { font-size: 1.5rem; font-weight: 600; }

.topbar-actions { display: flex; align-items: center; gap: 1rem; }

.user-info {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .875rem;
    color: var(--text-muted);
}

.user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: .875rem;
}

.page-content { padding: 2rem; }

/* Cards */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 { font-size: 1.1rem; font-weight: 600; }
.card-body { padding: 1.5rem; }

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    width: 48px; height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon.purple { background: #ede9fe; color: #7c3aed; }
.stat-icon.green { background: #d1fae5; color: #059669; }
.stat-icon.blue { background: #dbeafe; color: #2563eb; }
.stat-icon.orange { background: #fef3c7; color: #d97706; }
.stat-icon.red { background: #fee2e2; color: #dc2626; }

.stat-info h4 { font-size: .8rem; color: var(--text-muted); font-weight: 500; }
.stat-info .stat-value { font-size: 1.5rem; font-weight: 700; }

/* Forms */
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; margin-bottom: .4rem; font-weight: 500; font-size: .875rem; color: var(--text); }
.form-group .text-muted { font-size: .8rem; color: var(--text-muted); }

input, select, textarea {
    width: 100%;
    padding: .6rem .85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .9rem;
    font-family: var(--font);
    transition: border-color .2s, box-shadow .2s;
    background: #fff;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .6rem 1.25rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all .2s;
    font-family: var(--font);
    text-decoration: none;
    line-height: 1.4;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-lg { padding: .85rem 2rem; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-icon { padding: .5rem; }

/* Tables */
.table-responsive { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }
table th, table td { padding: .75rem 1rem; text-align: left; border-bottom: 1px solid var(--border); font-size: .875rem; }
table th { font-weight: 600; color: var(--text-muted); background: #f8fafc; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
table tr:hover { background: #f8fafc; }

.product-thumb {
    width: 40px; height: 40px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    background: var(--bg);
}

/* Badges */
.badge {
    display: inline-block;
    padding: .2rem .6rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 500;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-purple { background: #ede9fe; color: #5b21b6; }

/* Alerts */
.alert { padding: .85rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-size: .875rem; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-center { text-align: center; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-2 { margin-bottom: 1rem; }
.gap-1 { gap: .5rem; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all .3s;
}

.modal-overlay.active { opacity: 1; visibility: visible; }

.modal {
    background: var(--card);
    border-radius: var(--radius);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px);
    transition: transform .3s;
}

.modal-overlay.active .modal { transform: translateY(0); }

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 { font-size: 1.1rem; }
.modal-body { padding: 1.5rem; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: .5rem; }

.modal-close {
    background: none; border: none; font-size: 1.5rem;
    cursor: pointer; color: var(--text-muted); line-height: 1;
}

/* POS Specific */
.pos-layout { display: grid; grid-template-columns: 1fr 400px; gap: 0; height: calc(100vh - 64px); }

.pos-products {
    padding: 1.5rem;
    overflow-y: auto;
    background: var(--bg);
}

.pos-cart {
    background: var(--card);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.pos-cart-header { padding: 1.25rem; border-bottom: 1px solid var(--border); }
.pos-cart-items { flex: 1; overflow-y: auto; padding: .5rem; }
.pos-cart-footer { padding: 1.25rem; border-top: 1px solid var(--border); }

.category-tabs {
    display: flex;
    gap: .5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.category-tab {
    padding: .5rem 1rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--card);
    cursor: pointer;
    font-size: .85rem;
    transition: all .2s;
    white-space: nowrap;
}

.category-tab:hover, .category-tab.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
}

.product-card {
    background: var(--card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    cursor: pointer;
    transition: all .2s;
}

.product-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-light);
}

.product-card img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    background: var(--bg);
}

.product-card-info { padding: .75rem; }
.product-card-info h4 { font-size: .85rem; font-weight: 600; margin-bottom: .25rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.product-card-info .price { color: var(--primary); font-weight: 700; font-size: .95rem; }
.product-card-info .stock { font-size: .75rem; color: var(--text-muted); }

.cart-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem;
    border-bottom: 1px solid var(--border);
}

.cart-item-info { flex: 1; }
.cart-item-info h5 { font-size: .85rem; font-weight: 600; }
.cart-item-info .price { font-size: .8rem; color: var(--text-muted); }

.qty-control {
    display: flex;
    align-items: center;
    gap: .25rem;
}

.qty-control button {
    width: 28px; height: 28px;
    border: 1px solid var(--border);
    background: var(--bg);
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qty-control span { min-width: 24px; text-align: center; font-weight: 600; font-size: .875rem; }

.cart-totals { margin-bottom: 1rem; }
.cart-total-row { display: flex; justify-content: space-between; padding: .35rem 0; font-size: .9rem; }
.cart-total-row.grand { font-size: 1.25rem; font-weight: 700; border-top: 2px solid var(--border); padding-top: .75rem; margin-top: .5rem; }

.pos-search {
    margin-bottom: 1rem;
    position: relative;
}

.pos-search input {
    padding-left: 2.5rem;
    font-size: 1rem;
}

.pos-search svg {
    position: absolute;
    left: .85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.payment-methods { display: flex; gap: .5rem; margin-bottom: 1rem; }

.payment-method {
    flex: 1;
    padding: .75rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    text-align: center;
    cursor: pointer;
    transition: all .2s;
    font-size: .85rem;
    font-weight: 500;
}

.payment-method:hover, .payment-method.active {
    border-color: var(--primary);
    background: rgba(99,102,241,.05);
}

.payment-method.active { border-color: var(--primary); background: rgba(99,102,241,.1); }

/* Receipt */
.receipt {
    max-width: 320px;
    margin: 0 auto;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    padding: 1rem;
}

.receipt-header { text-align: center; margin-bottom: 1rem; }
.receipt-header h2 { font-size: 16px; margin-bottom: .25rem; }
.receipt-line { border-top: 1px dashed #000; margin: .5rem 0; }
.receipt-item { display: flex; justify-content: space-between; margin: .25rem 0; }
.receipt-total { font-weight: bold; font-size: 14px; }
.receipt-footer { text-align: center; margin-top: 1rem; font-size: 11px; }

/* Barcode */
.barcode-label {
    border: 1px solid var(--border);
    padding: 1rem;
    text-align: center;
    display: inline-block;
    margin: .5rem;
    background: #fff;
}

.barcode-label .product-name { font-size: .8rem; font-weight: 600; margin-bottom: .25rem; }
.barcode-label .barcode-text { font-family: 'Libre Barcode 128', monospace; font-size: 2rem; letter-spacing: 2px; }
.barcode-label .sku { font-size: .7rem; color: var(--text-muted); }
.barcode-label .price { font-size: .9rem; font-weight: 700; margin-top: .25rem; }

/* Image preview */
.image-preview {
    width: 120px; height: 120px;
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin-top: .5rem;
    background: var(--bg);
}

.image-preview img { width: 100%; height: 100%; object-fit: cover; }

/* Grid layouts */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }

/* Search bar */
.search-bar {
    position: relative;
    max-width: 300px;
}

.search-bar input { padding-left: 2.25rem; }
.search-bar svg { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); }

/* Pagination */
.pagination { display: flex; gap: .25rem; justify-content: center; margin-top: 1.5rem; }
.pagination a, .pagination span {
    padding: .4rem .75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .85rem;
}
.pagination a:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Tabs */
.tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 1.5rem; }
.tab {
    padding: .75rem 1.5rem;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all .2s;
}
.tab:hover, .tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Print */
@media print {
    body * { visibility: hidden; }
    .receipt, .receipt *, .barcode-print-area, .barcode-print-area * { visibility: visible; }
    .receipt { position: absolute; left: 0; top: 0; }
    .barcode-print-area { position: absolute; left: 0; top: 0; }
    .no-print { display: none !important; }
}

/* Responsive */
@media (max-width: 1024px) {
    .pos-layout { grid-template-columns: 1fr 350px; }
    .form-row, .form-row-3, .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .pos-layout { grid-template-columns: 1fr; height: auto; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}
