/* ============================================
   GASHAM - Admin Panel | Mobile-first
   ============================================ */

@import url('style.css');



/* === DASHBOARD LAYOUT === */
#dashboard-screen { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }

/* === MOBILE TOP BAR === */
.mobile-topbar {
  position: sticky; top: 0; z-index: 100;
  background: var(--bg-glass); backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--border);
  padding: 10px 14px; display: flex;
  align-items: center; justify-content: space-between;
  min-height: 50px;
}
.mobile-topbar-title { font-size: 16px; font-weight: 700; }
.mobile-topbar .btn-icon { width: 36px; height: 36px; }

/* === MAIN CONTENT (mobile first) === */
.main-content { flex: 1; padding: 14px; overflow-y: auto; }
.page { display: none; }
.page.active { display: block; }
.page-title { font-size: 22px; font-weight: 800; margin-bottom: 16px; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; flex-wrap: wrap; gap: 8px; }
.page-header h1 { font-size: 22px; font-weight: 800; }
.page-actions { display: flex; gap: 6px; }

/* === STATS GRID (mobile first: 2 cols) === */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-card {
  background: var(--bg-card); backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow-sm);
  display: flex; align-items: center; gap: 12px;
}
.stat-card.full-width { grid-column: 1 / -1; flex-direction: column; align-items: flex-start; }
.stat-header { font-size: 13px; font-weight: 600; color: var(--text2); margin-bottom: 8px; }
.stat-icon {
  width: 40px; height: 40px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-icon.green { background: rgba(52,199,89,0.15); color: var(--success); }
.stat-icon.orange { background: rgba(255,149,0,0.15); color: #ff9500; }
.stat-icon.purple { background: rgba(155,89,182,0.15); color: #9b59b6; }
.stat-icon.pink { background: rgba(255,45,85,0.15); color: #ff2d55; }
.stat-info { display: flex; flex-direction: column; }
.stat-label { font-size: 10px; color: var(--text2); text-transform: uppercase; letter-spacing: 0.3px; font-weight: 600; }
.stat-value { font-size: 20px; font-weight: 800; }
.recent-list { width: 100%; }
.recent-item { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; display: flex; justify-content: space-between; align-items: center; }
.recent-item:last-child { border-bottom: none; }

/* === SIDEBAR (desktop only) === */
.sidebar {
  display: none;
}
.sidebar.open {
  display: flex; position: fixed; inset: 0; z-index: 200;
  background: var(--bg-secondary, var(--bg-card));
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  width: 280px; flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: mIn 0.25s ease;
}
.sidebar-header { padding: 20px; text-align: center; border-bottom: 1px solid var(--border); position: relative; }
.sidebar-brand { font-size: 24px; font-weight: 800; background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.sidebar-brand-sub { font-size: 11px; color: var(--text2); }
.sidebar-close-btn { position: absolute; top: 12px; right: 12px; }
.sidebar-nav { flex: 1; padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: var(--radius);
  color: var(--text2); font-size: 14px; font-weight: 500;
  transition: all 0.2s; width: 100%; text-align: left;
}
.nav-item:active { background: var(--primary-light); color: var(--primary); }
.nav-item.active { background: var(--primary); color: #fff; }
.sidebar-footer { padding: 14px 16px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }

/* === TOOLBAR === */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; align-items: center; flex-direction: column; }
.toolbar-left, .toolbar-right { display: flex; gap: 6px; flex-wrap: wrap; width: 100%; }
.toolbar-right { justify-content: flex-start; }
.search-input {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--text); font-size: 14px; outline: none;
  min-width: 0; width: 100%; flex: 1;
}
.search-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.select-input {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--text); font-size: 14px; outline: none;
  flex: 1; min-width: 0;
}

/* === TABLE (horizontal scroll on mobile) === */
.table-container { overflow-x: auto; margin-top: 6px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--bg-card); -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 700px; }
.data-table th { text-align: left; padding: 10px 10px; font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.3px; color: var(--text2); border-bottom: 2px solid var(--border); white-space: nowrap; background: var(--bg); }
.data-table td { padding: 10px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:active { background: var(--primary-light); }
.data-table img { width: 36px; height: 36px; border-radius: 8px; object-fit: cover; }
.status-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.status-badge.active { background: var(--primary-light); color: var(--primary); }
.status-badge.Təsdiqlənib, .status-badge.completed { background: rgba(52,199,89,0.12); color: var(--success); }
.status-badge.inactive { background: rgba(255,59,48,0.12); color: var(--danger); }

/* === BUTTONS (touch-friendly) === */
.btn {
  padding: 10px 16px; font-size: 13px; border-radius: var(--radius);
  font-weight: 600; transition: all 0.2s;
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { transform: scale(0.96); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:active { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:active { opacity: 0.8; }
.btn-sm { padding: 8px 12px; font-size: 12px; min-height: 34px; }

/* === SCANNER PAGE === */
.scanner-page-layout { display: flex; flex-direction: column; gap: 16px; }
.scanner-section { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.scanner-view { max-width: 300px; margin: 0 auto; }
.scanner-view #admin-scanner-element { width: 100%; height: 100%; }
.product-form-section {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}
.product-form-section h3 { font-size: 16px; font-weight: 700; margin-bottom: 14px; }
.form-row { display: flex; flex-direction: column; gap: 0; }
.form-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.form-actions .btn { flex: 1; justify-content: center; }

/* === SETTINGS === */
.settings-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
  display: flex; flex-direction: column; gap: 14px; align-items: flex-start;
}
.settings-card h3 { font-size: 17px; font-weight: 700; }
.settings-card p { font-size: 13px; line-height: 1.6; color: var(--text2); }
.mt-1 { margin-top: 8px; }

/* === ORDER EDIT === */
.order-edit-item { display: flex; align-items: center; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.order-edit-item .item-name { flex: 1; font-weight: 600; font-size: 13px; min-width: 80px; }
.item-qty-input { width: 44px; padding: 4px 6px; text-align: center; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); font-size: 14px; font-weight: 600; }
.item-price-input { width: 72px; padding: 4px 6px; text-align: center; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); font-size: 14px; }
.btn-remove-item { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 700; background: rgba(255,59,48,0.12); color: var(--danger); flex-shrink: 0; }
.btn-remove-item:active { background: var(--danger); color: #fff; }
.order-edit-total { margin-top: 12px; text-align: right; font-size: 18px; font-weight: 800; padding-top: 10px; border-top: 2px solid var(--border); color: var(--primary); }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 18px; border-top: 1px solid var(--border); }

/* === TABLET === */
@media (min-width: 600px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .main-content { padding: 20px 24px; }
  .toolbar { flex-direction: row; }
  .toolbar-left, .toolbar-right { width: auto; }
  .search-input { width: auto; min-width: 140px; }
  .select-input { flex: none; }
  .form-row { flex-direction: row; gap: 10px; }
  .form-row .form-group { flex: 1; }
  .scanner-page-layout { flex-direction: row; }
  .scanner-section { flex: 1; }
  .product-form-section { flex: 1; }
  .settings-card { flex-direction: row; align-items: flex-start; }
}

/* === DESKTOP === */
@media (min-width: 900px) {
  #dashboard-screen { flex-direction: row; }
  .sidebar { display: flex; width: 240px; flex-shrink: 0; height: 100vh; position: sticky; top: 0; border-right: 1px solid var(--border); background: var(--bg-card); backdrop-filter: blur(24px); flex-direction: column; }
  .sidebar.open { position: static; box-shadow: none; }
  .mobile-topbar { display: none; }
  .main-content { padding: 28px 32px; max-height: 100vh; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .toolbar { flex-direction: row; }
  #history-list { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 1200px) {
  .main-content { padding: 32px 40px; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .sidebar { width: 260px; }
}

/* === RESPONSIVE TABLE WRAPPER === */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 8px;
  border-radius: var(--radius);
}
.table-responsive::-webkit-scrollbar { height: 4px; }
.table-responsive::-webkit-scrollbar-track { background: var(--bg); }
.table-responsive::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* === SETTINGS REFINEMENTS === */
.settings-card p { max-width: 480px; }

/* === SIDEBAR OVERLAY ON MOBILE === */
.sidebar.open::before {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: -1;
}

/* === ORDER CARDS IMPROVEMENTS === */
.order-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}
.order-card:active {
  transform: scale(0.98);
  background: var(--primary-light);
}
.order-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}
.order-card-number {
  font-size: 15px;
  font-weight: 700;
}
.order-card-time {
  font-size: 12px;
  color: var(--text2);
  margin-top: 2px;
}
.order-card-total {
  font-size: 18px;
  font-weight: 800;
  color: var(--primary);
}
.order-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text2);
}
.order-card-status {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}
.order-card-status.completed {
  background: rgba(52,199,89,0.12);
  color: var(--success);
}

/* === HISTORY LIST GRID === */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* === MODAL IMPROVEMENTS === */
.modal-content {
  max-height: 90vh;
  overflow-y: auto;
}

/* === DASHBOARD PAGE DASH === */
.page {
  animation: pageIn 0.25s ease;
}
@keyframes pageIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* === TABLET+ REFINEMENTS === */
@media (min-width: 600px) {
  .history-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .order-card {
    margin-bottom: 0;
  }
}

@media (min-width: 900px) {
  .history-list {
    grid-template-columns: 1fr 1fr 1fr;
  }
  .sidebar.open::before {
    display: none;
  }
}

/* === SAFE AREA === */
@supports (padding: max(0px)) {
  .main-content {
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }
  .mobile-topbar {
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
  }
}

/* === TABLE CONTAINER (responsive fallback) === */
.table-container {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
}
