/* ==========================================================================
   HS TRONICS — DEDICATED ADMIN CONTROL CENTER STYLESHEET (admin.css)
   Fully Responsive for Desktop, Laptop, Tablet, and Mobile Screens
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. GLOBAL RESETS & CONTAINER FOR ADMIN PORTAL
   -------------------------------------------------------------------------- */
body {
  background-color: #f8fafc !important;
  color: #1e293b;
  overflow-x: hidden;
  max-width: 100vw;
  -webkit-font-smoothing: antialiased;
}

.section-container {
  width: 100%;
  box-sizing: border-box;
}

/* --------------------------------------------------------------------------
   2. STICKY TOP ADMIN HEADER
   -------------------------------------------------------------------------- */
.site-header {
  background: #ffffff;
  border-bottom: 1.5px solid #e2e8f0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
  width: 100%;
}

.site-header .nav-container {
  max-width: 1550px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-sizing: border-box;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-family: var(--font-heading, 'Outfit', sans-serif);
  font-size: 1.2rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.01em;
}

.brand-logo span {
  color: #2563eb;
  font-weight: 900;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #0f172a;
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.2);
  flex-shrink: 0;
}

.brand-icon svg {
  width: 22px;
  height: 22px;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-actions .btn-icon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  color: #334155;
  font-size: 0.86rem;
  font-weight: 700;
  text-decoration: none;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.nav-actions .btn-icon:hover {
  background: #e2e8f0;
  color: #0f172a;
}

/* --------------------------------------------------------------------------
   3. ADMIN NAVIGATION TABS BAR
   -------------------------------------------------------------------------- */
.admin-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  border-bottom: 1.5px solid #e2e8f0;
  padding-bottom: 14px;
  flex-wrap: wrap;
}

.admin-nav a {
  padding: 8px 18px;
  border-radius: 20px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #475569;
  font-size: 0.88rem;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.admin-nav a:hover {
  background: #1e293b;
  border-color: #1e293b;
  color: #ffffff;
  transform: translateY(-1px);
}

.admin-nav a.active {
  background: #1e293b;
  border-color: #1e293b;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.2);
}

/* --------------------------------------------------------------------------
   4. STATS GRID CARDS
   -------------------------------------------------------------------------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: 12px;
  padding: 20px 22px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px -4px rgba(0, 0, 0, 0.08);
}

.stat-card-title {
  color: #64748b;
  font-size: 0.86rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stat-number {
  font-family: var(--font-heading, 'Outfit', sans-serif);
  font-size: 2rem;
  font-weight: 900;
  color: #0f172a;
  margin-top: 8px;
  line-height: 1.1;
}

/* --------------------------------------------------------------------------
   5. ORDERS FILTER TABS BAR
   -------------------------------------------------------------------------- */
.order-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.tab-btn {
  padding: 9px 18px;
  border-radius: 8px;
  border: 1.5px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
  font-weight: 700;
  font-size: 0.88rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  white-space: nowrap;
}

.tab-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.tab-btn.active {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

/* --------------------------------------------------------------------------
   6. ADMIN TABLE CONTAINERS (SMOOTH HORIZONTAL TOUCH-SCROLL)
   -------------------------------------------------------------------------- */
.admin-table-container {
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
  position: relative;
}

/* Custom Sleek Scrollbar for Admin Tables */
.admin-table-container::-webkit-scrollbar {
  height: 8px;
}
.admin-table-container::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 4px;
}
.admin-table-container::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
.admin-table-container::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.admin-table th {
  padding: 12px 16px;
  background: #f8fafc;
  border-bottom: 2px solid #cbd5e1;
  color: #475569;
  font-weight: 800;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.admin-table td {
  padding: 14px 16px;
  border-bottom: 1px solid #e2e8f0;
  color: #334155;
  font-size: 0.88rem;
  vertical-align: middle;
}

.admin-table tr:hover td {
  background: #f8fafc;
}

/* --------------------------------------------------------------------------
   7. FORM CONTROLS & BUTTONS
   -------------------------------------------------------------------------- */
.form-control,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  box-sizing: border-box;
  max-width: 100%;
}

/* --------------------------------------------------------------------------
   8. RESPONSIVE BREAKPOINTS (TABLETS & MOBILE PHONES)
   -------------------------------------------------------------------------- */

/* TABLETS (max-width: 1024px) */
@media (max-width: 1024px) {
  /* Workspace Grids Stack to Single Column */
  .admin-dashboard-grid,
  .admin-products-workspace,
  .admin-coupons-grid {
    grid-template-columns: 1fr !important;
    gap: 24px !important;
  }

  /* Sticky Form becomes static on mobile/tablets */
  #product-form {
    position: static !important;
    top: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
}

/* SMALL TABLETS & MOBILE PHONES (max-width: 768px) */
@media (max-width: 768px) {
  /* Admin Container Padding */
  .section-container {
    padding-left: 14px !important;
    padding-right: 14px !important;
    margin-top: 16px !important;
    margin-bottom: 30px !important;
  }

  /* Header Compact */
  .site-header .nav-container {
    padding: 10px 14px;
    gap: 10px;
  }
  .brand-logo {
    font-size: 1.05rem;
  }
  .brand-icon {
    width: 32px;
    height: 32px;
  }
  .brand-icon svg {
    width: 18px;
    height: 18px;
  }
  .nav-actions .btn-icon {
    padding: 6px 10px;
    font-size: 0.8rem;
    gap: 4px;
  }

  /* Horizontal Swipeable Admin Navigation Tabs */
  .admin-nav {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 10px !important;
    margin-bottom: 18px !important;
    gap: 8px !important;
    scrollbar-width: none;
    scroll-snap-type: x mandatory;
  }
  .admin-nav::-webkit-scrollbar {
    display: none;
  }
  .admin-nav a {
    flex-shrink: 0 !important;
    padding: 8px 14px !important;
    font-size: 0.82rem !important;
    scroll-snap-align: start;
    border-radius: 999px !important;
  }

  /* Horizontal Swipeable Orders Filter Tabs */
  .order-tabs {
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px !important;
    margin-bottom: 16px !important;
    gap: 8px !important;
    scrollbar-width: none;
    scroll-snap-type: x mandatory;
  }
  .order-tabs::-webkit-scrollbar {
    display: none;
  }
  .order-tabs .tab-btn {
    flex-shrink: 0 !important;
    padding: 8px 14px !important;
    font-size: 0.82rem !important;
    scroll-snap-align: start;
  }

  /* Top Page Title & Action Bars */
  .admin-title-row {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 12px !important;
    margin-bottom: 18px !important;
  }
  .admin-title-row > * {
    width: 100% !important;
  }
  .admin-title-row h1,
  .admin-title-row h2 {
    font-size: 1.35rem !important;
  }
  .admin-title-row .btn-primary,
  .admin-title-row button {
    width: 100% !important;
    justify-content: center !important;
  }

  /* Stat Cards: 2 Columns on Mobile */
  .stat-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
    margin-bottom: 20px !important;
  }
  .stat-card {
    padding: 14px 12px !important;
    border-radius: 10px !important;
  }
  .stat-card:last-child:nth-child(odd) {
    grid-column: span 2;
  }
  .stat-number {
    font-size: 1.5rem !important;
    margin-top: 6px !important;
  }

  /* Search & Toolbar Form */
  .admin-search-form,
  .filter-toolbar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    padding: 12px !important;
  }
  .search-wrap {
    min-width: 100% !important;
    flex-direction: column !important;
    gap: 8px !important;
  }
  .search-wrap > div {
    width: 100% !important;
  }
  .search-suggest-box {
    width: 100% !important;
    max-width: 100% !important;
  }
  .admin-search-form .btn-primary,
  .admin-search-form .btn-icon,
  .filter-toolbar .btn-primary,
  .filter-toolbar .btn-icon {
    width: 100% !important;
    justify-content: center !important;
    text-align: center !important;
    padding: 11px !important;
  }

  /* Catalog Cards Grid on Products Page */
  .catalog-deck {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
    margin-bottom: 18px !important;
  }
  .catalog-badge-card {
    padding: 10px 12px !important;
    border-radius: 10px !important;
  }
  .catalog-title {
    font-size: 0.82rem !important;
  }
  .catalog-count {
    font-size: 0.72rem !important;
    padding: 3px 7px !important;
  }

  /* Payment Method Cards */
  .method-card {
    padding: 16px 14px !important;
    border-radius: 12px !important;
    margin-bottom: 16px !important;
  }
  .method-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 12px !important;
    padding-bottom: 12px !important;
    margin-bottom: 14px !important;
  }
  .switch-wrap {
    width: 100% !important;
    justify-content: space-between !important;
  }

  /* ========================================================================
     MOBILE APP CARDS TRANSFORMATION (ZERO HORIZONTAL SLIDING)
     ======================================================================== */
  .admin-table-container {
    overflow-x: visible !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
  }
  .admin-table-container > div {
    overflow-x: visible !important;
  }
  .admin-table,
  .admin-table thead,
  .admin-table tbody,
  .admin-table tr,
  .admin-table td {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }
  .admin-table thead {
    display: none !important; /* Hide wide table headers on mobile */
  }

  /* 1. ORDER CARDS (orders.php) */
  .order-card-row {
    background: #ffffff !important;
    border: 1.5px solid #cbd5e1 !important;
    border-radius: 16px !important;
    padding: 16px 14px !important;
    margin-bottom: 18px !important;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05) !important;
  }
  .order-card-row.new-row {
    border-left: 5px solid #ef4444 !important;
  }
  .order-col-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: flex-start !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    padding: 0 0 10px 0 !important;
    border-bottom: 1.5px solid #e2e8f0 !important;
    margin-bottom: 10px !important;
  }
  .order-col-customer {
    padding: 0 0 10px 0 !important;
    border-bottom: 1.5px solid #e2e8f0 !important;
    margin-bottom: 10px !important;
  }
  .order-col-payment {
    background: #f8fafc !important;
    border: 1.5px solid #e2e8f0 !important;
    border-radius: 10px !important;
    padding: 10px 12px !important;
    margin-bottom: 12px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
  }
  .order-col-items {
    padding: 0 0 10px 0 !important;
    border-bottom: 1.5px solid #e2e8f0 !important;
    margin-bottom: 10px !important;
  }
  .order-col-actions {
    padding: 0 !important;
    border-bottom: none !important;
  }
  .order-col-actions .fulfillment-card {
    background: #f0fdf4 !important;
    border: 1.5px solid #86efac !important;
    border-radius: 10px !important;
    padding: 12px !important;
  }
  .order-col-actions .ctrl-row {
    flex-direction: column !important;
    gap: 8px !important;
  }
  .order-col-actions .ctrl-row .admin-select,
  .order-col-actions .ctrl-row input,
  .order-col-actions .ctrl-row button {
    width: 100% !important;
    justify-content: center !important;
    text-align: center !important;
    padding: 10px 12px !important;
    font-size: 0.88rem !important;
  }

  /* 2. PRODUCT CARDS (products.php) */
  .prod-card-row {
    background: #ffffff !important;
    border: 1.5px solid #cbd5e1 !important;
    border-radius: 14px !important;
    padding: 14px !important;
    margin-bottom: 14px !important;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04) !important;
  }
  .prod-col-id {
    display: inline-block !important;
    width: auto !important;
    padding: 0 !important;
    font-weight: 800 !important;
    color: #94a3b8 !important;
  }
  .prod-col-cat {
    display: inline-block !important;
    width: auto !important;
    padding: 0 !important;
    margin-left: 8px !important;
  }
  .prod-col-stock {
    display: inline-block !important;
    width: auto !important;
    float: right !important;
    padding: 0 !important;
  }
  .prod-col-details {
    clear: both !important;
    padding: 10px 0 !important;
    border-bottom: 1px dashed #e2e8f0 !important;
    margin-bottom: 8px !important;
  }
  .prod-col-price {
    display: block !important;
    padding: 4px 0 !important;
    font-size: 1.15rem !important;
    color: #0f172a !important;
  }
  .prod-col-actions {
    text-align: left !important;
    padding: 10px 0 0 0 !important;
    border-top: 1px solid #e2e8f0 !important;
  }
  .prod-col-actions div {
    display: flex !important;
    width: 100% !important;
    gap: 8px !important;
  }
  .prod-col-actions .btn-icon {
    flex: 1 !important;
    justify-content: center !important;
    padding: 10px !important;
    text-align: center !important;
  }

  /* 3. RECENT ORDERS CARDS (index.php) */
  .recent-order-card {
    background: #ffffff !important;
    border: 1.5px solid #cbd5e1 !important;
    border-radius: 12px !important;
    padding: 12px 14px !important;
    margin-bottom: 12px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
  }
  .recent-order-card td {
    padding: 2px 0 !important;
    border: none !important;
  }

  /* 4. COUPON CARDS (coupons.php) */
  .coupon-card-row {
    background: #ffffff !important;
    border: 1.5px solid #cbd5e1 !important;
    border-radius: 12px !important;
    padding: 14px !important;
    margin-bottom: 12px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
  }
  .coupon-card-row td {
    padding: 2px 0 !important;
    border: none !important;
  }
  .coupon-card-row .c-col-act button {
    width: 100% !important;
    padding: 9px !important;
    text-align: center !important;
  }

  /* 5. USER CARDS (users.php) */
  .user-card-row {
    background: #ffffff !important;
    border: 1.5px solid #cbd5e1 !important;
    border-radius: 12px !important;
    padding: 14px !important;
    margin-bottom: 12px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
  }
  .user-card-row td {
    padding: 2px 0 !important;
    border: none !important;
  }
  .user-card-row .u-col-action form {
    width: 100% !important;
    display: flex !important;
    gap: 6px !important;
  }
  .user-card-row .u-col-action input {
    flex: 1 !important;
    width: auto !important;
  }

  /* Inputs font-size 16px to prevent iOS Safari auto-zoom */
  .form-control,
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* EXTRA SMALL MOBILE PHONES (max-width: 480px) */
@media (max-width: 480px) {
  .brand-logo span {
    display: none; /* Shows HS Tronics Admin neatly */
  }
  .catalog-deck {
    grid-template-columns: 1fr !important;
  }
  .admin-login-card {
    padding: 24px 18px !important;
    border-radius: 14px !important;
  }
  #order-detail-modal {
    padding: 10px !important;
  }
  #order-modal-body {
    padding: 16px 12px !important;
  }
}
