/* ============================================================
   Admin Panel — Design System
   Stack: Bootstrap 5 + Poppins + Material Symbols
   ============================================================ */

/* ---------- Variables & Reset ---------- */
:root {
  --primary:       #2fcbe0;
  --primary-dark:  #1fa8bf;
  --dark:          #0d1b2a;
  --dark-2:        #1a2b3c;
  --sidebar-width: 240px;
  --radius:        10px;
  --shadow:        0 2px 12px rgba(0, 0, 0, .08);
}

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

body {
  font-family: 'Poppins', sans-serif;
  background: #f4f6f9;
  color: #1a2b3c;
  font-size: .9rem;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--dark);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: width .3s ease;
  overflow: hidden;
}

.sidebar.collapsed {
  width: 60px;
}

/* Brand / logo area */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  white-space: nowrap;
  flex-shrink: 0;
  text-decoration: none;
}

.sidebar-brand .material-symbols-rounded {
  font-size: 28px;
  color: var(--primary);
  flex-shrink: 0;
}

/* Nav list */
.sidebar-nav {
  list-style: none;
  padding: 12px 0;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .12);
  border-radius: 4px;
}

/* Nav links — shared between .sidebar-nav and .sidebar-footer */
.sidebar-nav a,
.sidebar-footer a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  color: #a0b4c8;
  text-decoration: none;
  font-size: .875rem;
  font-weight: 500;
  border-radius: 8px;
  margin: 2px 8px;
  transition: background .2s, color .2s;
  white-space: nowrap;
}

.sidebar-nav a:hover,
.sidebar-footer a:hover {
  background: rgba(255, 255, 255, .08);
  color: #fff;
}

.sidebar-nav a.active {
  background: var(--primary);
  color: #fff;
}

.sidebar-nav .material-symbols-rounded,
.sidebar-footer .material-symbols-rounded {
  font-size: 22px;
  flex-shrink: 0;
}

/* Footer (profile / settings / logout) */
.sidebar-footer {
  padding: 12px 0;
  border-top: 1px solid rgba(255, 255, 255, .08);
  flex-shrink: 0;
}

.sidebar-footer a.text-danger {
  color: #f87171 !important;
}

.sidebar-footer a.text-danger:hover {
  background: rgba(248, 113, 113, .12);
  color: #f87171 !important;
}

/* Collapsed sidebar: hide text labels */
.sidebar.collapsed .brand-name,
.sidebar.collapsed .sidebar-nav span:not(.material-symbols-rounded),
.sidebar.collapsed .sidebar-footer span:not(.material-symbols-rounded) {
  display: none;
}

.sidebar.collapsed .sidebar-nav a,
.sidebar.collapsed .sidebar-footer a {
  justify-content: center;
  padding: 10px 0;
  margin: 2px 6px;
}

/* ---------- Topbar ---------- */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: 60px;
  background: #fff;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 999;
  transition: left .3s ease;
}

.sidebar.collapsed ~ .topbar {
  left: 60px;
}

.sidebar-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--dark);
  display: flex;
  align-items: center;
  padding: 4px;
  border-radius: 6px;
  transition: background .2s;
}

.sidebar-toggle:hover {
  background: #f4f6f9;
}

.sidebar-toggle .material-symbols-rounded {
  font-size: 24px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
  font-weight: 600;
  font-size: .875rem;
  color: var(--dark);
}

/* ---------- Page content ---------- */
.page-content {
  margin-left: var(--sidebar-width);
  padding: 84px 24px 40px;
  min-height: 100vh;
  transition: margin-left .3s ease;
}

.sidebar.collapsed ~ .topbar ~ .page-content,
body.sidebar-collapsed .page-content {
  margin-left: 60px;
}

/* ---------- Page header / breadcrumb ---------- */
.page-header {
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 4px;
}

.page-header .breadcrumb {
  font-size: .78rem;
  color: #6b7280;
  margin: 0;
  padding: 0;
  background: none;
}

.page-header .breadcrumb-item + .breadcrumb-item::before {
  color: #9ca3af;
}

.page-header .breadcrumb a {
  color: #6b7280;
  text-decoration: none;
}

.page-header .breadcrumb a:hover {
  color: var(--primary);
}

/* ---------- Stat cards ---------- */
.stat-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  border: none;
  transition: transform .2s, box-shadow .2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .12);
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon .material-symbols-rounded {
  font-size: 26px;
  color: #fff;
}

.stat-icon.teal   { background: var(--primary); }
.stat-icon.blue   { background: #3b82f6; }
.stat-icon.green  { background: #22c55e; }
.stat-icon.orange { background: #f59e0b; }

.stat-value {
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--dark);
  line-height: 1;
}

.stat-label {
  font-size: .78rem;
  color: #6b7280;
  font-weight: 500;
  margin-top: 4px;
}

.stat-link {
  text-decoration: none;
  color: inherit;
  display: block;
}

/* ---------- Cards ---------- */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: none;
}

.card-header {
  background: transparent;
  border-bottom: 1px solid #f0f0f0;
  padding: 16px 20px;
  font-weight: 600;
  font-size: .95rem;
  color: var(--dark);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-body {
  padding: 20px;
}

.card-body.pt-0 {
  padding-top: 0;
}

/* ---------- Tables ---------- */
.table {
  font-size: .85rem;
  width: 100%;
  margin-bottom: 0;
}

.table th {
  font-weight: 600;
  color: #6b7280;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 2px solid #f0f0f0;
  padding: 12px 16px;
  background: #fafafa;
  white-space: nowrap;
}

.table td {
  padding: 12px 16px;
  vertical-align: middle;
  border-bottom: 1px solid #f3f4f6;
  color: #374151;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover td {
  background: #f9fafb;
}

.table .text-end {
  text-align: right;
}

/* ---------- Badges ---------- */
.badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  display: inline-block;
  line-height: 1.4;
}

.badge-pending    { background: #fef3c7; color: #d97706; }
.badge-paid       { background: #d1fae5; color: #065f46; }
.badge-rejected   { background: #fee2e2; color: #991b1b; }
.badge-dispatched { background: #dbeafe; color: #1e40af; }
.badge-delivered  { background: #d1fae5; color: #065f46; }
.badge-warning    { background: #fef3c7; color: #d97706; }
.badge-success    { background: #d1fae5; color: #065f46; }
.badge-danger     { background: #fee2e2; color: #991b1b; }
.badge-info       { background: #dbeafe; color: #1e40af; }

/* ---------- Buttons ---------- */
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}

.btn-primary:hover,
.btn-primary:focus {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: #fff;
}

.btn-icon-action {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  transition: background .2s, color .2s;
  text-decoration: none;
  font-size: 0;
}

.btn-icon-action .material-symbols-rounded {
  font-size: 20px;
}

.btn-icon-action.add     { background: #fef3c7; color: #d97706; }
.btn-icon-action.upload  { background: #d1fae5; color: #065f46; }
.btn-icon-action.delete  { background: #fee2e2; color: #991b1b; }
.btn-icon-action.export  { background: #dbeafe; color: #1e40af; }
.btn-icon-action.download { background: #ede9fe; color: #6d28d9; }

.btn-icon-action:hover {
  opacity: .85;
  transform: translateY(-1px);
}

/* ---------- Action icons (inside table cells) ---------- */
.act-icon {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}

.act-icon .icon {
  cursor: pointer;
  font-size: 20px;
  transition: opacity .2s;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  line-height: 1;
}

.act-icon .icon.success { color: #22c55e; }
.act-icon .icon.danger  { color: #ef4444; }

.act-icon .icon:hover {
  opacity: .7;
}

/* ---------- Forms ---------- */
.form-control,
.form-select {
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  padding: 10px 14px;
  font-size: .875rem;
  font-family: 'Poppins', sans-serif;
  transition: border-color .2s, box-shadow .2s;
  color: var(--dark-2);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47, 203, 224, .18);
  outline: none;
}

.form-label {
  font-weight: 600;
  font-size: .875rem;
  color: #374151;
  margin-bottom: 6px;
  display: block;
}

/* Search box wrapper */
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-wrap .search-icon {
  position: absolute;
  left: 12px;
  font-size: 20px;
  color: #9ca3af;
  pointer-events: none;
}

.search-wrap input[name="search"] {
  padding-left: 40px;
  min-width: 260px;
}

.search-wrap .clear-type-filter {
  position: absolute;
  right: 8px;
  cursor: pointer;
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 20px;
  display: flex;
  align-items: center;
}

.search-wrap .clear-type-filter.hide {
  display: none;
}

/* tableCount select */
select.tableCount {
  width: auto;
  min-width: 80px;
  font-size: .8rem;
  padding: 6px 10px;
}

/* ---------- Dropdown (status changer) ---------- */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown .menu {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .8rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  background: #f3f4f6;
  transition: background .2s;
}

.dropdown .menu:hover {
  background: #e5e7eb;
}

.dropdown .menu .material-symbols-outlined {
  font-size: 16px;
}

.dropdown .items {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, .15);
  min-width: 170px;
  z-index: 200;
  list-style: none;
  padding: 6px 0;
  border: 1px solid #f0f0f0;
}

.dropdown:hover .items,
.dropdown.open .items {
  display: block;
}

.dropdown .items li {
  padding: 8px 16px;
  cursor: pointer;
  font-size: .82rem;
  color: #374151;
  transition: background .15s;
}

.dropdown .items li:hover {
  background: #f9fafb;
  color: var(--dark);
}

/* ---------- Dispatch modal ---------- */
.dispatch-modal {
  display: none;
}

.dispatch-modal.show {
  display: flex !important;
}

/* ---------- Pagination ---------- */
.pagination {
  gap: 4px;
  margin: 0;
}

.pagination .page-link {
  border-radius: 6px !important;
  border: 1px solid #e5e7eb;
  color: var(--dark-2);
  font-size: .82rem;
  padding: 6px 12px;
}

.pagination .page-item.active .page-link {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.pagination .page-link:hover {
  background: #f4f6f9;
  border-color: #d1d5db;
  color: var(--dark);
}

/* ---------- Login page ---------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--dark) 0%, var(--dark-2) 100%);
  padding: 20px;
}

.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}

.login-brand {
  text-align: center;
  margin-bottom: 32px;
}

.login-brand h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--dark);
  margin-top: 10px;
  margin-bottom: 4px;
}

.login-brand p {
  color: #6b7280;
  font-size: .875rem;
}

/* ---------- DB error bar ---------- */
.db_error {
  background: #fee2e2;
  color: #991b1b;
  padding: 10px 24px;
  text-align: center;
  font-size: .875rem;
  font-weight: 500;
}

/* ---------- City paragraph (invoice table) ---------- */
p.city {
  font-size: .78rem;
  color: #6b7280;
  margin: 2px 0 0;
}

/* ---------- Order/refresh row header ---------- */
.order_refresh {
  font-size: .8rem;
  color: #9ca3af;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  margin: 0;
}

.order_refresh .material-symbols-rounded {
  font-size: 18px;
}

/* ---------- File upload button ---------- */
.file_upload {
  position: relative;
  overflow: hidden;
}

.file_upload input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

/* ---------- Table image thumb ---------- */
.product-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}

/* ---------- Misc helpers ---------- */
.text-muted   { color: #6b7280 !important; }
.fw-bolder    { font-weight: 700 !important; }
.fw-bold      { font-weight: 600 !important; }
.text-primary { color: var(--primary) !important; }

.no-data td {
  text-align: center;
  color: #9ca3af;
  padding: 40px 16px;
  font-size: .875rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .sidebar {
    width: 60px;
  }

  .sidebar .brand-name,
  .sidebar .sidebar-nav span:not(.material-symbols-rounded),
  .sidebar .sidebar-footer span:not(.material-symbols-rounded) {
    display: none;
  }

  .sidebar .sidebar-nav a,
  .sidebar .sidebar-footer a {
    justify-content: center;
    padding: 10px 0;
    margin: 2px 6px;
  }

  .sidebar.collapsed {
    width: 0;
    padding: 0;
  }

  .topbar {
    left: 60px;
  }

  .page-content {
    margin-left: 60px;
    padding: 80px 16px 32px;
  }

  .sidebar.collapsed ~ .topbar {
    left: 0;
  }

  .sidebar.collapsed ~ .page-content {
    margin-left: 0;
  }
}

@media (max-width: 576px) {
  .login-card {
    padding: 28px 20px;
  }

  .stat-value {
    font-size: 1.5rem;
  }

  .search-wrap input[name="search"] {
    min-width: 160px;
  }
}
