/* YS Tech Pharmacy POS - Light Theme */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700&family=Space+Mono:wght@400;700&display=swap');

:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface2: #f4f5f7;
  --surface3: #e8eaed;
  --border: #d8dbe0;
  --text: #111111;
  --text-muted: #5f6368;
  --text-dim: #9aa0a6;
  --primary: #00856a;
  --primary-dark: #006b55;
  --primary-glow: rgba(0, 133, 106, 0.1);
  --accent: #1a73e8;
  --danger: #d93025;
  --warning: #c47a1a;
  --success: #1e8e3e;
  --info: #4285f4;
  --sidebar-w: 240px;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --font: 'DM Sans', sans-serif;
  --mono: 'Space Mono', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface2); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Layout */
.app-wrapper { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: #f8f9fa;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform 0.3s;
  box-shadow: 1px 0 4px rgba(0,0,0,0.04);
}

.sidebar-logo {
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo .logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.sidebar-logo .logo-text { font-weight: 700; font-size: 13px; line-height: 1.3; color: var(--text); }
.sidebar-logo .logo-text span { color: var(--primary); display: block; font-size: 11px; font-weight: 500; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 10px; }

.nav-section-label {
  font-size: 10px; font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 1px;
  padding: 8px 8px 4px;
  margin-top: 8px;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13.5px; font-weight: 500;
  transition: all 0.2s;
  cursor: pointer;
  margin-bottom: 2px;
  border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--primary-glow); color: var(--primary); }
.nav-item .nav-icon { width: 18px; text-align: center; font-size: 15px; flex-shrink: 0; }
.nav-item .badge { margin-left: auto; background: var(--danger); color: #fff; border-radius: 10px; font-size: 10px; padding: 1px 6px; font-weight: 600; }

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--border);
}
.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface2);
}
.user-avatar {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #fff; flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-info strong { display: block; font-size: 12.5px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info span { font-size: 11px; color: var(--text-muted); }

/* Main Content */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex; align-items: center; gap: 16px;
  position: sticky; top: 0; z-index: 50;
}
.topbar h1 { font-size: 16px; font-weight: 600; color: var(--text); flex: 1; }
.topbar .breadcrumb { font-size: 12px; color: var(--text-muted); }

.page-content { padding: 24px; flex: 1; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.card-header h2 { font-size: 14px; font-weight: 600; flex: 1; }
.card-body { padding: 20px; }

/* Stats Grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.stat-card::before {
  content: ''; position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
}
.stat-card.green::before { background: var(--success); }
.stat-card.blue::before { background: var(--accent); }
.stat-card.orange::before { background: var(--warning); }
.stat-card.red::before { background: var(--danger); }
.stat-card.teal::before { background: var(--primary); }

.stat-label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.stat-value { font-size: 26px; font-weight: 700; font-family: var(--mono); color: var(--text); }
.stat-sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.stat-icon { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); font-size: 36px; opacity: 0.06; color: var(--text); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 13.5px; font-weight: 500;
  cursor: pointer; border: 1px solid transparent;
  text-decoration: none; transition: all 0.15s;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-secondary { background: var(--surface2); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface3); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { opacity: 0.85; }
.btn-outline { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover { background: var(--primary-glow); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-icon { padding: 7px; }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.4px; }
.form-control {
  width: 100%; padding: 9px 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-family: var(--font); font-size: 13.5px;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.form-control::placeholder { color: var(--text-dim); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead tr { border-bottom: 2px solid var(--border); }
thead th { padding: 10px 14px; font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; text-align: left; white-space: nowrap; }
tbody tr { border-bottom: 1px solid var(--border); transition: background 0.1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }
tbody td { padding: 12px 14px; font-size: 13.5px; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-green { background: rgba(30,142,62,0.1); color: var(--success); }
.badge-red { background: rgba(217,48,37,0.1); color: var(--danger); }
.badge-orange { background: rgba(196,122,26,0.1); color: var(--warning); }
.badge-blue { background: rgba(26,115,232,0.1); color: var(--accent); }
.badge-teal { background: rgba(0,133,106,0.1); color: var(--primary); }
.badge-gray { background: var(--surface3); color: var(--text-muted); }

/* POS Layout */
.pos-layout { display: grid; grid-template-columns: 1fr 360px; gap: 20px; height: calc(100vh - 80px); }
.pos-left { overflow-y: auto; }
.pos-right { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,0.04); }

/* Product Grid */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.product-card:hover { border-color: var(--primary); background: var(--surface2); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(0,133,106,0.12); }
.product-card.out-of-stock { opacity: 0.5; cursor: not-allowed; }
.product-img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; margin: 0 auto 8px; display: block; background: var(--surface2); }
.product-img-placeholder { width: 64px; height: 64px; background: var(--surface2); border-radius: 8px; display: flex; align-items: center; justify-content: center; margin: 0 auto 8px; font-size: 24px; }
.product-name { font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 4px; line-height: 1.3; }
.product-price { font-size: 13px; font-weight: 700; color: var(--primary); font-family: var(--mono); }
.product-stock { font-size: 10px; color: var(--text-muted); }
.product-card .category-dot { width: 6px; height: 6px; border-radius: 50%; position: absolute; top: 8px; right: 8px; }

/* Cart */
.cart-header { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.cart-header h3 { font-size: 14px; font-weight: 600; }
.cart-items { flex: 1; overflow-y: auto; padding: 8px; }
.cart-item {
  display: grid; grid-template-columns: 1fr auto;
  gap: 8px; padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  align-items: start;
}
.cart-item:last-child { border-bottom: none; }
.cart-item-name { font-size: 13px; font-weight: 500; margin-bottom: 2px; }
.cart-item-price { font-size: 12px; color: var(--text-muted); }
.cart-item-controls { display: flex; align-items: center; gap: 6px; }
.qty-btn { width: 24px; height: 24px; background: var(--surface2); border: 1px solid var(--border); border-radius: 4px; color: var(--text); font-size: 14px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.15s; }
.qty-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.qty-input { width: 40px; text-align: center; background: var(--surface); border: 1px solid var(--border); border-radius: 4px; color: var(--text); padding: 3px; font-size: 13px; font-family: var(--mono); }
.cart-item-total { font-size: 13px; font-weight: 600; color: var(--primary); font-family: var(--mono); text-align: right; }

.cart-footer { padding: 14px 16px; border-top: 1px solid var(--border); background: var(--surface2); }
.cart-summary-row { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; font-size: 13px; color: var(--text-muted); }
.cart-summary-row.total { font-size: 16px; font-weight: 700; color: var(--text); border-top: 1px solid var(--border); padding-top: 10px; margin-top: 6px; }
.cart-summary-row.total .amount { color: var(--primary); font-family: var(--mono); }

/* Search Bar */
.search-bar {
  position: relative; margin-bottom: 16px;
}
.search-bar input {
  width: 100%; padding: 10px 16px 10px 38px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-size: 14px; font-family: var(--font);
  outline: none; transition: border-color 0.15s;
}
.search-bar input:focus { border-color: var(--primary); }
.search-bar .search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }

/* Category Filter */
.category-filter { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.cat-btn { padding: 5px 12px; border-radius: 20px; border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); font-size: 12px; font-weight: 500; cursor: pointer; transition: all 0.15s; }
.cat-btn.active, .cat-btn:hover { background: var(--primary-glow); border-color: var(--primary); color: var(--primary); }

/* Modal */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.3); z-index: 1000; align-items: center; justify-content: center; backdrop-filter: blur(2px); }
.modal-overlay.open { display: flex; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); width: 90%; max-width: 600px; max-height: 90vh; overflow-y: auto; box-shadow: 0 8px 32px rgba(0,0,0,0.12); }
.modal-header { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.modal-header h2 { font-size: 15px; font-weight: 600; flex: 1; }
.modal-body { padding: 20px; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 18px; padding: 4px; line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-lg { max-width: 850px; }

/* Image Upload */
.image-upload-area {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 30px; text-align: center; cursor: pointer;
  transition: all 0.2s;
}
.image-upload-area:hover, .image-upload-area.dragover { border-color: var(--primary); background: var(--primary-glow); }
.image-preview { width: 100%; max-height: 180px; object-fit: contain; border-radius: var(--radius-sm); }

/* Alerts */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 16px; border: 1px solid; }
.alert-success { background: rgba(30,142,62,0.08); border-color: var(--success); color: var(--success); }
.alert-danger { background: rgba(217,48,37,0.08); border-color: var(--danger); color: var(--danger); }
.alert-warning { background: rgba(196,122,26,0.08); border-color: var(--warning); color: var(--warning); }
.alert-info { background: rgba(26,115,232,0.08); border-color: var(--accent); color: var(--accent); }

/* Print / Thermal */
@media print {
  body { background: white; color: black; font-family: 'Courier New', monospace; }
  .no-print { display: none !important; }
  .thermal-receipt { width: 80mm; margin: 0 auto; font-size: 11px; }
}
.thermal-receipt { font-family: 'Courier New', monospace; font-size: 12px; width: 300px; background: white; color: black; padding: 16px; }
.thermal-receipt .r-center { text-align: center; }
.thermal-receipt .r-line { border-top: 1px dashed #000; margin: 6px 0; }
.thermal-receipt .r-bold { font-weight: bold; }
.thermal-receipt .r-row { display: flex; justify-content: space-between; font-size: 11px; margin: 2px 0; }
.thermal-receipt .r-title { font-size: 16px; font-weight: bold; }
.thermal-receipt .r-total { font-size: 14px; font-weight: bold; }

/* Pagination */
.pagination { display: flex; gap: 4px; align-items: center; justify-content: center; margin-top: 16px; }
.page-btn { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; font-size: 13px; text-decoration: none; transition: all 0.15s; }
.page-btn:hover, .page-btn.active { background: var(--primary-glow); border-color: var(--primary); color: var(--primary); }

/* Responsive */
@media (max-width: 1024px) {
  .pos-layout { grid-template-columns: 1fr; }
  .pos-right { height: 420px; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
}

/* Utility */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-gap { display: flex; gap: 10px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.text-mono { font-family: var(--mono); }
.text-primary { color: var(--primary); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.w-full { width: 100%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.hidden { display: none; }
.loading { opacity: 0.5; pointer-events: none; }

/* Toast */
#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 18px; border-radius: var(--radius-sm); font-size: 13.5px; color: #fff; box-shadow: 0 4px 16px rgba(0,0,0,0.15); animation: slideUp 0.3s ease; min-width: 220px; display: flex; align-items: center; gap: 8px; }
.toast.success { background: var(--success); color: #fff; }
.toast.error { background: var(--danger); }
.toast.info { background: var(--accent); color: #fff; }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.expiry-warning { background: rgba(196,122,26,0.06); }
.expiry-danger { background: rgba(217,48,37,0.06); }
.low-stock { background: rgba(217,48,37,0.04); }