/* OrderKro — Main Stylesheet */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --secondary: #64748b;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --info: #0891b2;
  --dark: #1e293b;
  --light: #f8fafc;
  --border: #e2e8f0;
  --sidebar-w: 250px;
  --topbar-h: 60px;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -2px rgba(0,0,0,.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1);
  --font: 'Inter', sans-serif;
  --font-ur: 'Noto Nastaliq Urdu', serif;
  --transition: all .2s ease;
}

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

html, body {
  font-family: var(--font);
  font-size: 14px;
  background: var(--light);
  color: var(--dark);
  height: 100%;
}

body.rtl { font-family: var(--font-ur); direction: rtl; text-align: right; }

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--dark);
  color: #cbd5e1;
  display: flex; flex-direction: column;
  overflow-y: auto; overflow-x: hidden;
  z-index: 1000;
  transition: transform .3s ease;
}
.rtl .sidebar { left: auto; right: 0; }

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.logo-img { width: 32px; height: 32px; border-radius: 6px; object-fit: cover; }
.brand-text { font-size: 18px; color: #fff; letter-spacing: .5px; }
.brand-text strong { color: var(--primary); }

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; flex-shrink: 0;
}
.user-name { font-size: 13px; color: #e2e8f0; font-weight: 500; }
.user-role { font-size: 10px; margin-top: 2px; }

.sidebar-nav { flex: 1; padding: 10px 0; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 18px;
  color: #94a3b8; text-decoration: none;
  transition: var(--transition);
  border-radius: 0;
}
.nav-item i { width: 18px; text-align: center; font-size: 15px; }
.nav-item:hover, .nav-item.active {
  background: rgba(37,99,235,.15);
  color: #fff;
  border-right: 3px solid var(--primary);
}
.rtl .nav-item:hover, .rtl .nav-item.active {
  border-right: none; border-left: 3px solid var(--primary);
}
.nav-item.logout { color: #f87171; }
.nav-item.logout:hover { background: rgba(220,38,38,.15); color: #ff4444; }

/* ── Main Wrapper ─────────────────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex; flex-direction: column;
}
.rtl .main-wrapper { margin-left: 0; margin-right: var(--sidebar-w); }

/* ── Topbar ───────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow);
}
.sidebar-toggle {
  background: none; border: none; cursor: pointer;
  font-size: 18px; color: var(--secondary);
  display: none;
  padding: 6px;
}
.topbar-title { font-weight: 600; font-size: 16px; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.lang-toggle { font-size: 13px !important; padding: 4px 10px !important; }

/* ── Main Content ─────────────────────────────────────────── */
.main-content { flex: 1; padding: 24px; }

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 600; font-size: 15px;
}
.card-body { padding: 20px; }

/* ── Stats Cards ──────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 16px;
}
.stat-icon {
  width: 50px; height: 50px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.stat-icon.blue { background: #eff6ff; color: var(--primary); }
.stat-icon.green { background: #f0fdf4; color: var(--success); }
.stat-icon.red { background: #fef2f2; color: var(--danger); }
.stat-icon.orange { background: #fffbeb; color: var(--warning); }
.stat-icon.purple { background: #faf5ff; color: #7c3aed; }
.stat-label { font-size: 12px; color: var(--secondary); margin-bottom: 4px; }
.stat-value { font-size: 22px; font-weight: 700; color: var(--dark); }
.stat-change { font-size: 11px; margin-top: 2px; }
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 6px;
  border: 1px solid transparent;
  font-size: 14px; font-weight: 500;
  cursor: pointer; text-decoration: none;
  transition: var(--transition); white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-dark { background: var(--dark); color: #fff; }
.btn-outline { background: transparent; border-color: var(--border); color: var(--dark); }
.btn-outline:hover { background: var(--light); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 16px; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* ── Forms ────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; margin-bottom: 6px; font-weight: 500; font-size: 13px; }
.form-control {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 14px; font-family: var(--font);
  background: #fff; color: var(--dark);
  transition: border-color .2s;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.form-control.is-invalid { border-color: var(--danger); }
.invalid-feedback { color: var(--danger); font-size: 12px; margin-top: 4px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%2364748b' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; }

/* ── Tables ───────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th { background: var(--light); color: var(--secondary); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.rtl thead th { text-align: right; }
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.badge-owner { background: #ede9fe; color: #6d28d9; }
.badge-manager { background: #fef3c7; color: #92400e; }
.badge-cashier { background: #e0f2fe; color: #0369a1; }
.badge-success, .badge-paid { background: #dcfce7; color: #166534; }
.badge-danger, .badge-pending { background: #fee2e2; color: #991b1b; }
.badge-warning, .badge-partial { background: #fef9c3; color: #713f12; }
.badge-info, .badge-preparing { background: #e0f2fe; color: #075985; }
.badge-ready { background: #d1fae5; color: #065f46; }
.badge-delivered { background: #f0fdf4; color: #166534; }
.badge-cancelled { background: #f1f5f9; color: #64748b; }
.deal-badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; color: #fff; }

/* ── Alerts ───────────────────────────────────────────────── */
.alert {
  padding: 12px 16px; border-radius: 8px;
  margin-bottom: 16px; display: flex; align-items: center;
  justify-content: space-between; gap: 10px;
}
.alert-success { background: #dcfce7; color: #166534; border-left: 4px solid var(--success); }
.alert-error { background: #fee2e2; color: #991b1b; border-left: 4px solid var(--danger); }
.alert-info { background: #e0f2fe; color: #075985; border-left: 4px solid var(--info); }
.alert-warning { background: #fef9c3; color: #713f12; border-left: 4px solid var(--warning); }
.alert-dismissible button { background: none; border: none; cursor: pointer; font-size: 18px; opacity: .6; }

/* ── Modals ───────────────────────────────────────────────── */
.modal-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 2000;
  align-items: center; justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: #fff; border-radius: 12px; width: 90%; max-width: 540px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg); animation: modalIn .25s ease;
}
@keyframes modalIn { from { transform: translateY(-20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; cursor: pointer; font-size: 20px; color: var(--secondary); }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* ── POS Layout ───────────────────────────────────────────── */
.pos-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 16px;
  height: calc(100vh - var(--topbar-h) - 48px);
}
.pos-products { display: flex; flex-direction: column; gap: 12px; }
.pos-categories {
  display: flex; gap: 8px; flex-wrap: nowrap;
  overflow-x: auto; padding-bottom: 4px;
}
.pos-categories::-webkit-scrollbar { height: 3px; }
.cat-btn {
  flex-shrink: 0; padding: 6px 14px; border-radius: 20px;
  border: 1px solid var(--border); background: #fff; cursor: pointer;
  font-size: 13px; font-weight: 500; white-space: nowrap;
  transition: var(--transition);
}
.cat-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px; overflow-y: auto; flex: 1;
}
.product-card {
  background: #fff; border-radius: 8px; box-shadow: var(--shadow);
  cursor: pointer; overflow: hidden; transition: var(--transition);
  position: relative;
}
.product-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.product-card img { width: 100%; height: 90px; object-fit: cover; }
.product-card-placeholder { width: 100%; height: 90px; background: var(--light); display: flex; align-items: center; justify-content: center; font-size: 28px; }
.product-card-body { padding: 8px; }
.product-card-name { font-size: 13px; font-weight: 500; margin-bottom: 4px; line-height: 1.3; }
.product-card-price { font-size: 14px; font-weight: 700; color: var(--primary); }
.product-card-badge { position: absolute; top: 6px; right: 6px; font-size: 10px; }
.product-card.out-of-stock { opacity: .5; pointer-events: none; }

/* ── Cart Panel ───────────────────────────────────────────── */
.cart-panel {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
}
.cart-header { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.cart-items { flex: 1; overflow-y: auto; padding: 8px; }
.cart-item { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 6px; margin-bottom: 6px; background: var(--light); }
.cart-item-name { flex: 1; font-size: 13px; font-weight: 500; }
.cart-item-qty { display: flex; align-items: center; gap: 4px; }
.qty-btn { width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--border); background: #fff; cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center; }
.qty-val { width: 28px; text-align: center; font-weight: 600; }
.cart-item-price { font-size: 13px; font-weight: 600; width: 70px; text-align: right; }
.cart-item-remove { background: none; border: none; cursor: pointer; color: var(--danger); font-size: 14px; padding: 2px; }
.cart-empty { text-align: center; padding: 40px 20px; color: var(--secondary); }
.cart-empty i { font-size: 40px; display: block; margin-bottom: 12px; opacity: .3; }
.cart-footer { padding: 14px; border-top: 1px solid var(--border); }
.cart-totals { margin-bottom: 12px; }
.cart-row { display: flex; justify-content: space-between; font-size: 13px; padding: 3px 0; }
.cart-row.total { font-weight: 700; font-size: 16px; border-top: 1px solid var(--border); padding-top: 8px; margin-top: 4px; }
.cart-row.discount { color: var(--success); }

/* ── Order Type Selector ──────────────────────────────────── */
.order-type-group { display: flex; gap: 6px; margin-bottom: 12px; }
.order-type-btn { flex: 1; padding: 6px; border: 1px solid var(--border); border-radius: 6px; background: #fff; cursor: pointer; font-size: 12px; font-weight: 500; text-align: center; transition: var(--transition); }
.order-type-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Receipt ──────────────────────────────────────────────── */
.receipt {
  max-width: 320px; margin: 0 auto; background: #fff;
  font-family: 'Courier New', monospace; font-size: 12px;
  padding: 20px; border-radius: 8px; box-shadow: var(--shadow-md);
}
.receipt-header { text-align: center; border-bottom: 1px dashed #000; padding-bottom: 10px; margin-bottom: 10px; }
.receipt-title { font-size: 18px; font-weight: 700; }
.receipt-divider { border-top: 1px dashed #000; margin: 10px 0; }
.receipt-row { display: flex; justify-content: space-between; padding: 2px 0; }
.receipt-total { font-weight: 700; font-size: 14px; }
.receipt-footer { text-align: center; margin-top: 10px; color: #555; }

/* ── Dashboard Charts ─────────────────────────────────────── */
.chart-container { position: relative; height: 260px; }

/* ── Grids ────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mt-4 { margin-top: 16px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-sm { font-size: 12px; }
.text-muted { color: var(--secondary); }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }

/* ── Landing Page ─────────────────────────────────────────── */
.landing-body { background: #fff; font-family: var(--font); }
.landing-nav { background: #fff; padding: 16px 40px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; box-shadow: var(--shadow); }
.landing-nav .logo { font-size: 24px; font-weight: 800; color: var(--dark); text-decoration: none; }
.landing-nav .logo span { color: var(--primary); }
.landing-nav-links { display: flex; gap: 30px; list-style: none; }
.landing-nav-links a { text-decoration: none; color: var(--secondary); font-weight: 500; }
.hero { padding: 80px 40px; text-align: center; background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 100%); }
.hero h1 { font-size: 52px; font-weight: 800; line-height: 1.2; margin-bottom: 20px; }
.hero h1 span { color: var(--primary); }
.hero p { font-size: 18px; color: var(--secondary); max-width: 600px; margin: 0 auto 32px; }
.hero-btns { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.features-section { padding: 80px 40px; max-width: 1200px; margin: 0 auto; }
.features-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 24px; }
.feature-card { border: 1px solid var(--border); border-radius: 12px; padding: 24px; transition: var(--transition); }
.feature-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); }
.feature-icon { width: 48px; height: 48px; border-radius: 10px; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 22px; margin-bottom: 16px; }
.feature-card h3 { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.feature-card p { color: var(--secondary); font-size: 14px; line-height: 1.6; }
.pricing-section { background: var(--light); padding: 80px 40px; }
.pricing-section h2 { text-align: center; font-size: 36px; font-weight: 700; margin-bottom: 12px; }
.pricing-section p { text-align: center; color: var(--secondary); margin-bottom: 48px; }
.pricing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px; max-width: 900px; margin: 0 auto; }
.pricing-card { background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 32px; text-align: center; transition: var(--transition); }
.pricing-card.featured { border-color: var(--primary); position: relative; transform: scale(1.04); box-shadow: var(--shadow-lg); }
.pricing-card.featured::before { content: 'Most Popular'; position: absolute; top: -12px; left: 50%; transform: translateX(-50%); background: var(--primary); color: #fff; font-size: 11px; font-weight: 700; padding: 4px 16px; border-radius: 20px; }
.pricing-plan { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--secondary); margin-bottom: 8px; }
.pricing-price { font-size: 40px; font-weight: 800; color: var(--dark); }
.pricing-price sub { font-size: 16px; font-weight: 400; color: var(--secondary); }
.pricing-features { list-style: none; margin: 24px 0; text-align: left; }
.pricing-features li { padding: 6px 0; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.pricing-features li::before { content: '✓'; color: var(--success); font-weight: 700; }
.cta-section { background: var(--primary); color: #fff; padding: 80px 40px; text-align: center; }
.cta-section h2 { font-size: 36px; font-weight: 800; margin-bottom: 16px; }
.cta-section p { font-size: 18px; opacity: .85; margin-bottom: 32px; }
.footer { background: var(--dark); color: #94a3b8; padding: 40px; text-align: center; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .rtl .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-toggle { display: block; }
  .main-wrapper { margin-left: 0 !important; margin-right: 0 !important; }
  .pos-layout { grid-template-columns: 1fr; height: auto; }
  .cart-panel { min-height: 400px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .hero h1 { font-size: 32px; }
  .landing-nav { padding: 12px 20px; }
  .features-section, .pricing-section, .cta-section, .hero { padding: 48px 20px; }
}

@media print {
  .sidebar, .topbar, .btn:not(.print-btn), .no-print { display: none !important; }
  .main-wrapper { margin: 0; }
  .main-content { padding: 0; }
}

/* ── Animations ───────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { animation: spin 1s linear infinite; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn .3s ease; }
