:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;
}

/* Two-column layout for larger phones and small tablets */
@media (min-width: 576px) and (max-width: 991.98px) {
  .checkout-page .payment-options {
    --bs-gutter-x: 1.25rem;
    --bs-gutter-y: 1rem;
  }
  .checkout-page .payment-options > [class^="col-"],
  .checkout-page .payment-options > [class*=" col-"] {
    flex: 0 0 50% !important;
    max-width: 50% !important;
  }
}

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

body {
    font-family: 'Sarabun', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
    background-color: #f8f9fa;
}

/* Navbar */
.navbar-brand {
    font-size: 1.5rem;
}

/* Hero Section */
.hero-section {
    background: transparent !important;
    color: inherit;
    padding: 0; /* spacing handled by inner elements */
    text-align: center;
}

.hero-section h1 {
    font-size: 3rem;
    font-weight: bold;
    margin-bottom: 1rem;
}

.hero-section p {
    font-size: 1.25rem;
    margin-bottom: 2rem;
}

/* Product Cards */
.product-card {
    border: none;
    border-radius: 15px;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    height: 100%;
}

.product-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.product-card img {
    width: 100%;
    height: 220px;
    object-fit: cover;
}

.product-card .card-body {
    padding: 1.5rem;
}

.product-price {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
}

.product-price-old {
    text-decoration: line-through;
    color: #999;
    font-size: 1rem;
    margin-left: 10px;
}

.badge-featured {
    position: absolute;
    top: 10px;
    right: 10px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.8rem;
}

/* Rating Stars */
.rating-stars {
    color: #ffc107;
}

.rating-stars i {
    font-size: 0.9rem;
}

/* Category Badges */
.category-badge {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 22px;
    margin: 6px 8px;
    border-radius: 999px;
    background: linear-gradient(135deg, #0d6efd 0%, #0b5ed7 100%);
    color: #ffffff;
    text-decoration: none;
    font-weight: 600;
    letter-spacing: .3px;
    text-transform: uppercase;
    box-shadow: 0 6px 16px rgba(13,110,253,0.25);
    transition: transform 0.12s ease, box-shadow 0.2s ease, background-color 0.2s ease, opacity 0.2s ease;
    border: 1px solid rgba(255,255,255,0.12);
}

.category-badge i,
.category-badge svg {
    color: #ffffff !important;
    opacity: .95;
    font-size: 1rem;
    line-height: 1;
}

.category-badge:hover,
.category-badge:focus {
    transform: translateY(-1px);
    color: #ffffff !important;
    box-shadow: 0 10px 24px rgba(13,110,253,0.35);
}

.category-badge:focus-visible {
    outline: 2px solid rgba(255,255,255,0.35);
    outline-offset: 2px;
}

/* Search Box */
.search-box {
    max-width: 600px;
    margin: 0 auto;
}

.search-box input {
    border-radius: 50px;
    padding: 12px 25px;
    border: 2px solid #ddd;
}

.search-box button {
    border-radius: 50px;
    padding: 12px 30px;
}

/* Cart Table */
.cart-table img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 10px;
}

/* Improve cart text clarity */
.cart-table {
    color: #111;
    font-size: 1rem; /* base font size for readability */
}

.cart-table th {
    font-weight: 700;
    color: #000;
    font-size: 0.95rem;
    letter-spacing: 0.2px;
}

.cart-table td {
    vertical-align: middle;
    color: #111;
    font-size: 1rem;
}

.cart-table h6 {
    font-size: 1.05rem;
    font-weight: 600;
    color: #000;
}

.cart-table .small,
.cart-table .text-muted,
.cart-table a.small.text-muted {
    color: #444 !important; /* stronger contrast */
    font-size: 0.95rem;
}

/* Checkout */
.checkout-summary {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* Make the whole right column (summary + actions) sticky */
.checkout-sidebar {
    position: sticky;
    top: 100px;
}

/* Improve summary readability */
.checkout-summary h5 {
    color: #000;
    font-weight: 700;
}

.checkout-summary .d-flex span,
.checkout-summary .d-flex strong {
    color: #000;
    font-size: 1rem;
}

.checkout-summary .fs-4 {
    font-size: 1.75rem !important; /* ensure total stands out */
}

/* Checkout page typography improvements */
.checkout-page h2,
.checkout-page h5 {
    color: #000;
}

.checkout-page .card-header.bg-primary.text-white h5 {
    color: #fff; /* keep header white on primary bg */
}

.checkout-page .checkout-table {
    color: #111;
    font-size: 1rem;
}

.checkout-page .checkout-table th {
    color: #000;
    font-weight: 700;
    font-size: 0.95rem;
}

.checkout-page .checkout-table td {
    color: #111;
    font-size: 1rem;
}

.checkout-page strong {
    color: #000;
}

.checkout-page .text-muted,
.checkout-page small.text-muted {
    color: #444 !important; /* increase contrast on muted text */
}

.checkout-page .form-check {
    background: #fff;
}

.checkout-page .form-check .form-check-label strong {
    font-weight: 600;
    color: #000;
}

.checkout-page .alert-info,
.checkout-page .alert-success {
    color: #0b2e13; /* darker text for better readability on alerts */
}

/* Horizontal payment options on checkout */
.checkout-page .payment-options { 
    align-items: stretch; 
    /* Increase gutters specifically for this row */
    --bs-gutter-x: 2.5rem; /* ~40px between columns */
    --bs-gutter-y: 1rem;
    gap: 0; /* rely on column padding for consistent spacing */
}
.checkout-page .payment-options > [class^="col-"],
.checkout-page .payment-options > [class*=" col-"] {
    padding-left: 18px;  /* explicit padding so borders never touch */
    padding-right: 18px;
}
.checkout-page .payment-options .form-check {
    margin: 0;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 12px;
    height: 100%;
}
.checkout-page .payment-options .form-check-label { width: 100% !important; display: block; }
.checkout-page .payment-options .d-flex { gap: .5rem; }
/* Keep radio dot away from edges to avoid looking cramped */
.checkout-page .payment-options .form-check-input { margin-top: .15rem; margin-left: .15rem; }

/* Download Links */
.download-card {
    background: white;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.download-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    padding: 12px 30px;
    border-radius: 50px;
    transition: all 0.3s ease;
}

.download-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

/* Admin Panel */
.admin-sidebar {
    background: #ffffff;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    color: #0f172a;
    border: 1px solid #e5e7eb;
}

/* Ensure Admin Panel title and its icon are solid black for clarity */
.admin-sidebar h5,
.admin-sidebar h5 i {
    color: #000 !important;
}

.admin-sidebar .nav-link {
    color: #0f172a;
    padding: 12px 20px;
    margin-bottom: 5px;
    border-radius: 10px;
    transition: all 0.3s ease;
}

.admin-sidebar .nav-link:hover,
.admin-sidebar .nav-link.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

/* Ensure sidebar is always visible and not overlapped on backend pages */
.admin-page .admin-sidebar {
  position: sticky;
  top: 90px; /* below navbar */
  z-index: 1100; /* below navbar(1200) but above content */
  display: block;
}
.admin-page .admin-sidebar h5,
.admin-page .admin-sidebar h5 i { color: #0f172a !important; }
.admin-page .admin-sidebar .nav-link { color: #0f172a; background: #f8fafc; border: 1px solid #e5e7eb; }
.admin-page .admin-sidebar .nav-link + .nav-link { margin-top: 6px; }
.admin-page .admin-sidebar .nav-link:hover { background: #eef2ff; color: #111827; border-color: #c7d2fe; }
.admin-page .admin-sidebar .nav-link.active { background: #4f46e5; border-color: #4338ca; color: #fff; }

/* Stats Cards */
.stats-card {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    text-align: center;
}

.stats-card h3 {
    font-size: 2.5rem;
    font-weight: bold;
    margin-bottom: 10px;
}

/* Ensure feature titles are black for better contrast */
.stats-card h5 { color: #000 !important; }

.stats-card.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

/* Blue variant for dashboard cards */
.stats-card.blue {
    background: linear-gradient(135deg, #60a5fa 0%, #2563eb 100%);
    color: #ffffff;
}

.stats-card.success {
    background: linear-gradient(135deg, #56ab2f 0%, #a8e063 100%);
    color: white;
}

.stats-card.warning {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

/* Ensure dashboard stat cards are always visible above background layers */
.admin-page .stats-card {
  position: relative;
  z-index: 1; /* sit above starfield/background */
}
/* Force inner texts to inherit the intended color on gradient cards */
.stats-card.blue h3, .stats-card.blue p,
.stats-card.success h3, .stats-card.success p,
.stats-card.warning h3, .stats-card.warning p,
.stats-card.primary h3, .stats-card.primary p {
  color: inherit !important;
}

/* Form Styling */
.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.btn-primary {
    background: linear-gradient(180deg, #0d6efd 0%, #0b5ed7 100%);
    border: 1px solid #0b5ed7;
    padding: 12px 30px;
    border-radius: 50px;
    transition: transform 0.15s ease, box-shadow 0.2s ease, background-color 0.2s ease;
    color: #fff;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(13,110,253,0.35);
    background: linear-gradient(180deg, #0b5ed7 0%, #0a58ca 100%);
    border-color: #0a58ca;
}

.btn-primary:active {
    transform: translateY(0);
    background: linear-gradient(180deg, #0a58ca 0%, #094db4 100%);
    border-color: #094db4;
}

/* Keep active visual state when .active class is applied (avoid blink then revert) */
.btn-primary.active {
    transform: translateY(0);
    background: linear-gradient(180deg, #0a58ca 0%, #094db4 100%);
    border-color: #094db4;
}

/* Secondary button with same shape/behavior but gray theme */
.btn-secondary {
    background: linear-gradient(180deg, #6b7280 0%, #4b5563 100%);
    border: 1px solid #4b5563;
    padding: 12px 30px;
    border-radius: 50px;
    transition: transform 0.15s ease, box-shadow 0.2s ease, background-color 0.2s ease;
    color: #ffffff;
}
.btn-secondary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.25);
    background: linear-gradient(180deg, #4b5563 0%, #374151 100%);
    border-color: #374151;
}
.btn-secondary:active {
    transform: translateY(0);
    background: linear-gradient(180deg, #374151 0%, #1f2937 100%);
    border-color: #1f2937;
}
.btn-secondary.active {
    transform: translateY(0);
    background: linear-gradient(180deg, #374151 0%, #1f2937 100%);
    border-color: #1f2937;
}

/* Outline primary to match blue theme */
.btn-outline-primary {
    color: #0d6efd;
    border: 1px solid #0d6efd;
    padding: 12px 30px;
    border-radius: 50px;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.btn-outline-primary:hover {
    background: #0d6efd;
    color: #fff;
    transform: translateY(-1px);
}

/* Keep active visual state for outline primary when .active is applied */
.btn-outline-primary.active,
.btn-outline-primary:active {
    background: #0d6efd;
    color: #fff;
    transform: translateY(0);
    border-color: #0a58ca;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease;
}

/* Responsive */
@media (max-width: 768px) {
    .hero-section h1 {
        font-size: 2rem;
    }
    
    .hero-section p {
        font-size: 1rem;
    }
    
    .product-card img {
        height: 180px;
    }
}

/* Mobile-first tweaks for checkout payment options without affecting desktop */
@media (max-width: 767.98px) {
  /* Reduce side gutters and vertical gaps for tighter mobile layout */
  .checkout-page .payment-options {
    --bs-gutter-x: 1rem;
    --bs-gutter-y: 0.75rem;
  }
  .checkout-page .payment-options > [class^="col-"],
  .checkout-page .payment-options > [class*=" col-"] {
    padding-left: 10px;
    padding-right: 10px;
    /* Ensure 1 item per row on small screens regardless of other classes */
    flex: 0 0 100% !important;
    max-width: 100% !important;
  }

  /* Make each option look compact but still tappable */
  .checkout-page .payment-options .form-check {
    padding: 12px;
    border-radius: 10px;
  }
  .checkout-page .payment-options .form-check-input {
    width: 1.15rem;
    height: 1.15rem;
    margin-top: 0.1rem;
  }
  .checkout-page .payment-options .d-flex {
    gap: 0.75rem;
    align-items: center;
  }
  /* Slightly smaller icon and texts to prevent wrapping too early */
  .checkout-page .payment-options i.fs-3 {
    font-size: 1.6rem !important;
  }
  .checkout-page .payment-options .form-check-label strong {
    font-size: 0.98rem;
    line-height: 1.2;
  }
  .checkout-page .payment-options .form-check-label small {
    font-size: 0.86rem;
    line-height: 1.2;
  }

  /* Disable sticky sidebar on small screens to avoid clipping */
  .checkout-sidebar {
    position: static;
    top: auto;
  }
}

/* Loading Spinner */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

/* Active heading state for tools page title */
body main .d-flex.align-items-center.mb-3 h1.active {
    color: var(--primary-color) !important;
    text-shadow: 0 0 0 transparent, 0 1px 0 rgba(0,0,0,0.05);
}

/* Admin Tables */
.admin-table th,
.admin-table td {
    vertical-align: middle;
    white-space: normal; /* allow wrapping so table fits without scroll */
}

/* Keep compact columns from wrapping to save space */
.admin-table th:nth-child(1), /* Order No */
.admin-table td:nth-child(1),
.admin-table th:nth-child(3), /* Qty */
.admin-table td:nth-child(3),
.admin-table th:nth-child(4), /* Amount */
.admin-table td:nth-child(4),
.admin-table th:nth-child(6), /* Status */
.admin-table td:nth-child(6),
.admin-table th:nth-child(7), /* Date */
.admin-table td:nth-child(7) {
    white-space: nowrap;
}

.admin-table .customer-email {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;   /* allow wrapping in the cell */
    word-break: break-word; /* break long emails/usernames if needed */
}

.admin-table .badge {
    font-weight: 600;
    padding: .45em .8em;
    color: #fff; /* ensure contrast on colored badges */
}

.table-responsive {
    overflow-x: auto;
}

/* Sidebar categories: force single-line labels with ellipsis */
.sidebar-cats .list-group-item {
    display: block;
    white-space: nowrap;
    overflow: visible; /* allow full text to be visible */
    word-break: keep-all;        /* prevent breaking words and hyphenated terms */
    overflow-wrap: normal;       /* don't wrap long words */
    hyphens: manual;             /* do not auto insert hyphens */
}
.sidebar-cats .list-group-item .cat-icon-text {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    width: 100%;
    min-width: 0; /* allow inner label to shrink for ellipsis */
}
.sidebar-cats .list-group-item .cat-label {
    display: inline-block;
    overflow: visible; /* show full text */
    text-overflow: clip;
    white-space: nowrap;
    max-width: 100%;
}

/* Sidebar category list should respect column width on desktop to avoid overlap */
.sidebar-cats { width: 100%; overflow-x: hidden; }

/* Mobile navbar: center collapsed menu text only */
/* Mobile navbar: center collapsed menu text only */
@media (max-width: 991.98px) {
  .navbar .navbar-collapse {
    text-align: center;
  }
  .navbar .navbar-collapse .navbar-nav {
    width: 100%;
  }
  /* Reset margins that might push items to the side (like ms-auto) */
  .navbar .navbar-collapse .navbar-nav .nav-item {
    margin-left: 0 !important;
    margin-right: 0 !important;
    width: 100%;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
  }
  .navbar .navbar-collapse .navbar-nav .nav-link {
    text-align: center;
    width: 100%;
    justify-content: center;
  }
  .navbar .dropdown-menu {
    text-align: center;
    background-color: transparent !important;
    border: none;
    box-shadow: none;
  }
  .navbar .dropdown-menu .dropdown-item {
    text-align: center;
    justify-content: center;
    display: flex;
    align-items: center;
  }
}

/* --- Fallback background animation styles (in case theme.css is cached/missing) --- */
/* Ensure the starfield canvas sits beneath content and fills the viewport */
#starfield {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}
/* When used inside a scoped container, keep it within that area */
.galaxy-wrap { position: relative; min-height: 100vh; }
.galaxy-wrap > #starfield { position: absolute; inset: 0; z-index: 0; }
.galaxy-wrap > .container { position: relative; z-index: 1; }

/* --- Custom thin scrollbar for product descriptions --- */
/* Reusable class: apply to any overflow container needing a nicer scrollbar */
.product-desc-scroll {
  /* sizing/behavior typically applied inline, but keep defaults here too */
  max-height: 260px;
  overflow: auto;
  padding-right: .5rem;
  /* Firefox */
  scrollbar-width: thin; /* auto | thin | none */
  scrollbar-color: #6b7280 rgba(255,255,255,0.08); /* thumb | track */
}
/* WebKit (Chrome, Edge, Safari, Opera) */
.product-desc-scroll::-webkit-scrollbar {
  width: 8px;
}
.product-desc-scroll::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.06);
  border-radius: 8px;
}
.product-desc-scroll::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #9ca3af 0%, #6b7280 100%);
  border-radius: 8px;
  border: 2px solid rgba(0,0,0,0.25); /* creates padding around thumb */
}
.product-desc-scroll:hover::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #60a5fa 0%, #2563eb 100%);
}
