/*=====================================
    1. FRONTEND STYLES (CLIENT-SIDE) 
=====================================*/

/* --- 1.1 General Body & Typography --- */
body {
    font-family: 'Kanit', sans-serif;
    margin: 0;
    padding: 0;
    line-height: 1.6;
    color: #333;
    background-color: #f4f4f4;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

h1, h2, h3, h4 {
    color: #8B0000; /* สีแดงเข้มหลัก */
    margin-bottom: 15px;
}

a {
    color: #DAA520; /* สีทอง */
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* --- 1.2 Buttons (General) --- */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 5px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    font-weight: bold;
    border: none;
    text-decoration: none;
}

.btn-primary {
    background-color: #007bff;
    color: white;
    border-radius: 8px;
    padding: 12px 24px;
    font-size: 1rem;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
}

.btn-primary:hover {
    background-color: #0056b3;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 0.9rem;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.btn-secondary:hover {
    background-color: #545b62;
    box-shadow: 0 3px 7px rgba(0, 0, 0, 0.15);
}

.btn-gold {
    background-color: #ffc107;
    color: #212529;
    border-radius: 8px;
    padding: 12px 24px;
    font-size: 1rem;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
}

.btn-gold:hover {
    background-color: #e0a800;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-outline-gold {
    background-color: transparent;
    color: #DAA520;
    border: 2px solid #DAA520;
}

.btn-outline-gold:hover {
    background-color: #DAA520;
    color: #8B0000;
}

.btn-add-cart {
    background-color: #28a745;
    color: white;
    border-radius: 6px;
    padding: 10px 15px;
    font-size: 0.9rem;
}

.btn-add-cart:hover {
    background-color: #1e7e34;
}

/* --- 1.3 Header & Navigation --- */
header {
    background: linear-gradient(to right, #8B0000, #B22222); /* โทนแดง */
    color: #fff;
    padding: 15px 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: saturate(1.1);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

/* Shrink on scroll */
.header-scrolled header {
    padding: 8px 0;
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}

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

.logo img {
    height: 50px;
}

.logo h1 {
    margin: 0;
    color: #FFD700; /* สีทอง */
    font-size: 2em;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
}

nav ul li {
    margin-left: 25px;
}

nav ul li a {
    color: #fff;
    font-weight: bold;
    padding: 5px 0;
    position: relative;
    transition: color 0.3s ease;
}

nav ul li a:hover,
nav ul li a.active {
    color: #FFD700;
}

nav ul li a.active::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -5px;
    width: 100%;
    height: 2px;
    background-color: #FFD700;
}

/* Enhanced nav link visuals with icons */
nav ul li a.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
}
nav ul li a.nav-link i {
    font-size: 1rem;
    opacity: 0.9;
    transition: transform 0.2s ease, opacity 0.2s ease;
}
nav ul li a.nav-link:hover i,
nav ul li a.nav-link.active i {
    transform: translateY(-1px);
    opacity: 1;
}
/* Underline slide animation */
nav ul li a.nav-link::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -6px;
    width: 100%;
    height: 2px;
    background-color: #FFD700;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.25s ease;
}
nav ul li a.nav-link:hover::after,
nav ul li a.nav-link.active::after { transform: scaleX(1); }

/* Page fade transitions using <html> classes */
html.page-fade-init body { opacity: 0; }
html.page-fade-ready body { opacity: 1; transition: opacity .4s ease; }
html.page-fade-leave body { opacity: 0; transition: opacity .25s ease; }

/* Ripple effect base for interactive elements */
.btn, nav ul li a.nav-link, .single-sort-btn {
    position: relative;
    overflow: hidden;
}
.cart-button-nav { position: relative; overflow: visible; }
.ripple-ink {
    position: absolute;
    border-radius: 50%;
    transform: scale(0);
    animation: ripple 600ms ease-out;
    background: rgba(255,255,255,0.35);
    pointer-events: none;
}
@keyframes ripple {
    to { transform: scale(12); opacity: 0; }
}

.auth-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Cart Button & Count */
.cart-button {
    position: relative;
    padding-right: 15px;
}

.cart-count {
    background-color: #dc3545;
    color: white;
    border-radius: 50%;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: bold;
    position: relative;
    top: -1px;
    margin-left: 5px;
}

/* Improved Cart Button in Nav (ใช้ใน header.php) */
.cart-button-nav {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    background-color: #ffffff;
    color: #343a40;
    border-radius: 50%;
    font-size: 1.2rem;
    text-decoration: none;
    transition: background-color 0.2s, color 0.2s, transform 0.2s;
    border: 1px solid rgba(0,0,0,0.06);
    box-shadow: 0 3px 10px rgba(0,0,0,0.08);
    line-height: 1;
    overflow: visible; /* allow badge to overflow */
}

.cart-button-nav:hover {
    background-color: #DAA520;
    color: #fff;
}
.cart-button-nav i { font-size: 1.25rem; }
.cart-wrapper { position: relative; display: inline-block; overflow: visible; }

.cart-wrapper { position: relative; }
.cart-preview {
    position: absolute;
    right: 0;
    top: calc(100% + 10px);
    width: 320px;
    background: #fff;
    color: #333;
    border: 1px solid #eee;
    border-radius: 12px;
    box-shadow: 0 10px 24px rgba(0,0,0,0.15);
    padding: 10px;
    opacity: 0;
    transform: translateY(8px);
    visibility: hidden;
    transition: opacity .2s ease, transform .2s ease, visibility .2s ease;
}
.cart-wrapper:hover .cart-preview,
.cart-preview.show {
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
}
.cart-preview-empty {
    display: flex; align-items: center; gap: 10px; padding: 14px;
}
.cart-preview-empty i { color: #DAA520; }
.cart-preview-list { list-style: none; margin: 0; padding: 0; max-height: 280px; overflow: auto; }
.cart-preview-list li { display: grid; grid-template-columns: 56px 1fr auto; gap: 10px; align-items: center; padding: 8px; border-radius: 8px; }
.cart-preview-list li:hover { background: #f8f9fa; }
.cart-preview-list img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; }
.cart-preview-list .name { font-weight: 600; }
.cart-preview-list .sub { color: #6c757d; font-size: 0.9rem; }
.cart-preview-list .line { font-weight: 700; color: #8B0000; }
.cart-preview-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px; border-top: 1px solid #eee; }
.cart-preview-footer .total span { color: #6c757d; }

/* Cart animations for feedback */
@keyframes cartBump { 0%{ transform: scale(1);} 30%{ transform: scale(1.12);} 60%{ transform: scale(0.98);} 100%{ transform: scale(1);} }
@keyframes badgePulse { 0%,100%{ box-shadow: 0 0 0 0 rgba(220,53,69,0.4);} 50%{ box-shadow: 0 0 0 6px rgba(220,53,69,0);} }
.cart-button-nav.bump { animation: cartBump 400ms ease; }
.cart-count-badge.pulse { animation: badgePulse 800ms ease; }

.cart-count-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background-color: #dc3545;
    color: white;
    border-radius: 999px;
    min-width: 26px;
    height: 26px;
    padding: 0 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 800;
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px rgba(139,0,0,0.4), 0 4px 10px rgba(0,0,0,0.2);
    z-index: 2;
}

/* Improved User Dropdown */
.user-dropdown {
    position: relative;
    display: inline-block;
}

.user-dropdown-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background-color: #f8f9fa;
    color: #343a40;
    border: 1px solid #dee2e6;
    border-radius: 25px; 
    padding: 8px 15px;
    font-weight: 600;
    cursor: pointer;
}

.user-dropdown-toggle .fa-user-circle {
    font-size: 1.4rem;
    color: #6c757d;
}

.user-dropdown-toggle .fa-chevron-down {
    font-size: 0.8rem;
    transition: transform 0.2s ease-in-out;
}

.user-dropdown-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 10px);
    background-color: #fff;
    min-width: 220px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
    border-radius: 8px;
    z-index: 1000;
    border: 1px solid #eee;
    padding: 0.5rem 0;
    opacity: 0;
    transform: translateY(10px);
    visibility: hidden; 
    max-height: 0;    
    overflow: hidden; 
    transition: opacity 0.3s ease, transform 0.3s ease, max-height 0.3s ease, visibility 0.3s ease;
}

.user-dropdown-menu.show {
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
    max-height: 300px; 
}

.user-dropdown-menu a {
    color: #343a40;
    padding: 10px 20px;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.95rem;
}

.user-dropdown-menu a .fas {
    width: 20px;
    text-align: center;
    color: #6c757d;
}

.user-dropdown-menu a:hover {
    background-color: #f8f9fa;
    text-decoration: none;
}

.user-dropdown-menu .dropdown-divider {
    height: 1px;
    margin: 0.5rem 0;
    overflow: hidden;
    background-color: #e9ecef;
    border: 0;
}

/* Language Switcher Styles */
.lang-switcher { /* แก้ไขชื่อคลาสให้ตรงกับที่ใช้ใน header.php (lang-switcher) */
    display: flex;
    align-items: center;
    background-color: rgba(0,0,0,0.2);
    border-radius: 20px;
    padding: 4px;
    margin-right: 1rem;
}
.lang-switcher a {
    color: #fff;
    padding: 4px 12px;
    text-decoration: none;
    font-weight: bold;
    font-size: 0.9em;
    border-radius: 20px;
    transition: all 0.3s ease;
}
.lang-switcher a:hover {
    background-color: rgba(255,255,255,0.2);
}
.lang-switcher a.active {
    background-color: #fff;
    color: #8B0000;
}

/* Scroll reveal utility */
.reveal {
    opacity: 0;
    transform: translateY(18px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}
.reveal.reveal-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Subtle entrance for hero block */
@keyframes fadeUpOnce {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}
.hero-text { animation: fadeUpOnce 700ms ease both; }

/* Footer styling */
footer {
    background: linear-gradient( to right, #7a0000, #8B0000 );
    color: #fff;
    padding: 24px 0;
    border-top: 4px solid #DAA520;
}
footer .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

/* Featured products slider */
.featured-section { padding: 60px 0; background: linear-gradient(180deg,#fff 0%,#fafafa 100%); }
.featured-section .section-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:16px }
.featured-section .link-more{ color:#8B0000; font-weight:700 }
.slider-wrap{ position:relative }
.slider{ display:flex; gap:16px; overflow:auto; scroll-behavior:smooth; padding:6px 8px }
.slider::-webkit-scrollbar{ height:8px }
.slider::-webkit-scrollbar-thumb{ background:#e3e3e3; border-radius:999px }
.slide-card{ flex:0 0 280px; background:#fff; border:1px solid #eee; border-radius:14px; box-shadow:0 10px 24px rgba(0,0,0,.06); overflow:hidden; display:flex; flex-direction:column }
.slide-card .thumb{ height:160px; background-size:cover; background-position:center }
.slide-card .info{ padding:12px 14px; display:flex; flex-direction:column; gap:8px }
.slide-card .name{ font-weight:700; color:#1f2937; white-space:nowrap; overflow:hidden; text-overflow:ellipsis }
.slide-card .meta{ display:flex; justify-content:space-between; color:#6b7280; font-size:.9rem }
.slide-card .actions{ margin-top:8px }
.slider-btn{ position:absolute; top:50%; transform:translateY(-50%); border:0; width:40px; height:40px; border-radius:999px; background:#fff; box-shadow:0 6px 16px rgba(0,0,0,.15); cursor:pointer; font-size:22px; color:#8B0000 }
.slider-btn.prev{ left:-10px }
.slider-btn.next{ right:-10px }
.slider-btn:hover{ background:#8B0000; color:#fff }

/* Stats counters */
.stats-section{ padding:50px 0; background:#ffffff }
.stats-grid{ display:grid; grid-template-columns:repeat(3,1fr); gap:20px }
.stat{ background:#fff; border:1px solid #eee; border-top:4px solid #DAA520; border-radius:14px; text-align:center; padding:22px; box-shadow:0 10px 24px rgba(0,0,0,.06) }
.stat .num{ font-size:2.2rem; color:#8B0000; font-weight:800 }
.stat .label{ color:#6b7280; font-weight:600 }
@media (max-width: 900px){ .stats-grid{ grid-template-columns:1fr; } .slider-btn.prev{ left:4px } .slider-btn.next{ right:4px } }

/* Reveal on scroll reuse */
.reveal{ opacity:0; transform:translateY(16px); transition:opacity .6s ease, transform .6s ease }
.reveal.reveal-visible{ opacity:1; transform:translateY(0) }
footer p { margin: 0; }
footer a {
    color: #FFD700;
    font-weight: 600;
}
footer a:hover { color: #fff; text-decoration: none; }

/* Sound toggle pill */
.sound-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 36px;
    margin-left: 8px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.5);
    background: rgba(255,255,255,0.15);
    color: #fff;
    cursor: pointer;
    transition: background-color .2s ease, transform .2s ease, box-shadow .2s ease;
}
.sound-toggle:hover { 
    background: rgba(255,255,255,0.25); 
    transform: translateY(-1px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}
.sound-toggle.muted { color: #ffd2d2; opacity: 0.9; }
.lang-switcher span {
    color: rgba(255,255,255,0.5);
    font-size: 1em;
}

/* --- 1.4 Homepage Sections (index.php) --- */
/* Hero Section */
.hero-section {
    position: relative;
    height: 650px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #fff;
    background: linear-gradient(135deg, #8B0000 0%, #B22222 50%, #DAA520 100%);
}

.hero-text {
    position: relative;
    z-index: 2;
    padding: 30px 40px;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 12px;
    max-width: 900px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

.hero-text h2 {
    color: #FFD700;
    font-size: 3.5em;
    margin-bottom: 25px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.hero-text p {
    font-size: 1.3em;
    margin-bottom: 40px;
    line-height: 1.8;
    color: #f0f0f0;
}

.hero-buttons .btn {
    margin: 0 15px;
    padding: 12px 28px;
    font-size: 1.1em;
    border-radius: 8px;
}

/* Other Sections (Padding) */
.quality-section, .products-grid-section, .order-form-section, .contact-section, .dashboard-main {
    padding: 60px 0;
}

/* Contact Page */
.contact-header-block {
    text-align: center;
    margin-bottom: 30px;
}
.contact-header-block h2 {
    margin: 0 0 8px 0;
    color: #fff;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    border-radius: 10px;
    background: linear-gradient(135deg, #8B0000, #A52A2A);
    border-bottom: 3px solid #DAA520;
    box-shadow: 0 6px 16px rgba(0,0,0,0.15);
}
.contact-header-block .contact-subtitle {
    color: #555;
    font-weight: 600;
}

.contact-layout {
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    gap: 30px;
}

.contact-info-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.contact-item {
    background: #fff;
    border: 1px solid #eee;
    border-top: 4px solid #DAA520;
    border-radius: 12px;
    padding: 20px 22px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.06);
    transition: transform .25s ease, box-shadow .25s ease;
}
.contact-item:hover { 
    transform: translateY(-6px); 
    box-shadow: 0 14px 28px rgba(0,0,0,0.12);
}
.contact-item h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #8B0000;
    margin-top: 0;
}
.contact-item h3 i { color: #DAA520; }
.contact-item a { color: #8B0000; font-weight: 600; }
.contact-item a:hover { color: #DAA520; text-decoration: none; }

.map-embed iframe {
    width: 100%;
    height: 300px;
    border: 0;
    border-radius: 10px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.08);
}

.contact-form-section { align-self: start; }
.contact-form-card {
    background: #fff;
    border: 1px solid #eee;
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.06);
    padding: 24px;
}
.contact-form-card h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #8B0000;
    margin-top: 0;
}
.contact-form-card .form-group label i {
    color: #DAA520;
    margin-right: 6px;
}

@media (max-width: 992px) {
    .contact-layout { grid-template-columns: 1fr; }
}

/* Quality Section */
.quality-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 30px;
}

.quality-item {
    background-color: #f9f9f9;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    text-align: center;
}

/* Dashboard (Member) */
.dashboard-main {
    background-color: #f8f9fa; 
}

.dashboard-header {
    text-align: center;
    margin-bottom: 50px;
}

.dashboard-header h2 {
    font-size: 2.8rem;
    font-weight: 700;
    color: #8B0000;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 30px;
    max-width: 1200px;
    margin: 0 auto;
}

.dashboard-card {
    background-color: #ffffff;
    border-radius: 12px;
    padding: 40px 30px;
    text-align: center;
    box-shadow: 0 5px 20px rgba(0,0,0,0.07);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.dashboard-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

.dashboard-card .icon {
    font-size: 3.5rem;
    color: #cdaa7c; 
    margin-bottom: 25px;
}

.dashboard-card h4 {
    font-size: 1.6rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: #343a40;
}

.dashboard-card p {
    color: #6c757d;
    font-size: 1rem;
    line-height: 1.6;
}

.dashboard-card a {
    text-decoration: none;
    color: inherit;
}

/* --- 1.5 Products Page Styles (products.php) --- */
.products-header {
    padding: 60px 20px;
    background: linear-gradient(135deg, #8B0000, #A52A2A);
    border-bottom: 5px solid #DAA520;
    color: #fff;
    text-align: center;
}

.products-header h2 {
    font-size: 3.2em;
    font-weight: 700;
    color: #fff;
    text-shadow: 2px 2px 5px rgba(0,0,0,0.4);
    margin: 0;
}

/* Filter/Sort Controls */
.filter-sort-controls {
    max-width: 850px;
    margin: 40px auto 0 auto;
    background-color: rgba(255, 255, 255, 0.98);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
    display: flex;
    flex-wrap: wrap;
    gap: 25px;
    justify-content: center;
    align-items: center;
}

.filter-sort-controls label {
    color: #333;
    font-weight: bold;
}

.filter-sort-controls input[type="text"],
.filter-sort-controls select {
    padding: 12px 18px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-family: 'Kanit', sans-serif;
    font-size: 1rem;
    min-width: 250px;
    transition: all 0.3s ease;
}

.filter-sort-controls input[type="text"]:focus,
.filter-sort-controls select:focus {
    outline: none;
    border-color: #DAA520;
    box-shadow: 0 0 0 4px rgba(218, 165, 32, 0.2);
}

/* Products Grid */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 30px;
}

.product-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease; 
}

.product-card:hover {
    transform: translateY(-12px); /* การ์ดลอยขึ้น */
    box-shadow: 0 15px 30px rgba(0,0,0,0.15); /* เพิ่มเงาให้ชัดขึ้น */
}

.product-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.product-card:hover img {
    transform: scale(1.05);
}

.product-card h3 {
    font-size: 1.5em; 
    color: #8B0000;
    min-height: 50px; 
}

.product-card .product-price {
    font-size: 1.6em; 
    color: #DAA520; 
    font-weight: bold;
    margin: 15px 0;
}

.product-card .product-actions {
    padding: 15px;
    border-top: 1px solid #f0f0f0;
    background-color: #fafafa;
}

/* Add to Cart Form */
.add-to-cart-form {
    display: flex;
    gap: 10px;
    align-items: center;
}

.quantity-input {
    width: 60px;
    text-align: center;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 5px;
}

.btn-add-cart {
    flex-grow: 1;
    background: linear-gradient(45deg, #28a745, #218838); 
    color: white;
    border: none;
    border-radius: 6px;
    padding: 10px 15px;
    font-size: 1rem; 
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px; 
}

.btn-add-cart:hover {
    background: linear-gradient(45deg, #218838, #1e7e34); 
    transform: scale(1.05); 
}

/* Price Sort Group Styles (Advanced CSS/JS features) */
.price-sort-group {
    display: flex;
    align-items: center;
    gap: 15px;
}

.single-sort-btn {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 16px 28px;
    border: none;
    background: linear-gradient(145deg, #ffffff, #f0f2f5);
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    font-size: 16px;
    font-weight: 700;
    color: #333;
    position: relative;
    overflow: hidden;
    min-width: 240px;
    justify-content: space-between;
    box-shadow: 
        0 8px 25px rgba(0,0,0,0.15),
        inset 0 1px 0 rgba(255,255,255,0.6);
    border: 2px solid transparent;
}

.single-sort-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg, 
        transparent, 
        rgba(255,255,255,0.8), 
        transparent
    );
    transition: left 0.8s ease;
}

.single-sort-btn:hover::before {
    left: 100%;
}

.single-sort-btn:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 
        0 20px 40px rgba(0,0,0,0.2),
        0 0 20px rgba(218, 165, 32, 0.3),
        inset 0 1px 0 rgba(255,255,255,0.8);
    border-color: rgba(218, 165, 32, 0.5);
}

.single-sort-btn.sort-default {
    background: linear-gradient(145deg, #667eea, #764ba2);
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.single-sort-btn.sort-default:hover {
    background: linear-gradient(145deg, #764ba2, #667eea);
    box-shadow: 
        0 20px 40px rgba(102, 126, 234, 0.4),
        0 0 30px rgba(118, 75, 162, 0.6);
}

.single-sort-btn.sort-low-high {
    background: linear-gradient(145deg, #11998e, #38ef7d);
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    animation: pulseGreen 3s infinite;
}

.single-sort-btn.sort-low-high:hover {
    background: linear-gradient(145deg, #38ef7d, #11998e);
    box-shadow: 
        0 20px 40px rgba(17, 153, 142, 0.5),
        0 0 40px rgba(56, 239, 125, 0.7);
}

.single-sort-btn.sort-high-low {
    background: linear-gradient(145deg, #ee0979, #ff6a00);
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    animation: pulseOrange 3s infinite;
}

.single-sort-btn.sort-high-low:hover {
    background: linear-gradient(145deg, #ff6a00, #ee0979);
    box-shadow: 
        0 20px 40px rgba(238, 9, 121, 0.5),
        0 0 40px rgba(255, 106, 0, 0.7);
}

.single-sort-btn i {
    font-size: 20px;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
    padding: 8px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    backdrop-filter: blur(10px);
}

.single-sort-btn:hover i {
    transform: scale(1.3) rotate(360deg);
    background: rgba(255,255,255,0.3);
}

.single-sort-btn.sort-low-high i {
    animation: floatUp 2s ease-in-out infinite;
}

.single-sort-btn.sort-high-low i {
    animation: floatDown 2s ease-in-out infinite;
}

.single-sort-btn.sort-default i {
    animation: wiggle 3s ease-in-out infinite;
}

.sort-indicator {
    background: rgba(255,255,255,0.25);
    backdrop-filter: blur(10px);
    padding: 6px 16px;
    border-radius: 25px;
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    border: 1px solid rgba(255,255,255,0.3);
    transition: all 0.3s ease;
    box-shadow: 
        0 4px 15px rgba(0,0,0,0.1),
        inset 0 1px 0 rgba(255,255,255,0.5);
}

.single-sort-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: radial-gradient(circle, rgba(255,255,255,0.8), transparent);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.6s ease;
    pointer-events: none;
}

.single-sort-btn:active::after {
    width: 300px;
    height: 300px;
    opacity: 0;
}

.single-sort-btn:active {
    transform: translateY(-4px) scale(0.98);
    transition: all 0.1s ease;
}

/* Animations */
@keyframes pulseGreen {
    0%, 100% { 
        box-shadow: 
            0 8px 25px rgba(17, 153, 142, 0.3),
            0 0 20px rgba(56, 239, 125, 0.2);
    }
    50% { 
        box-shadow: 
            0 12px 35px rgba(17, 153, 142, 0.5),
            0 0 40px rgba(56, 239, 125, 0.4);
    }
}

@keyframes pulseOrange {
    0%, 100% { 
        box-shadow: 
            0 8px 25px rgba(238, 9, 121, 0.3),
            0 0 20px rgba(255, 106, 0, 0.2);
    }
    50% { 
        box-shadow: 
            0 12px 35px rgba(238, 9, 121, 0.5),
            0 0 40px rgba(255, 106, 0, 0.4);
    }
}

@keyframes floatUp {
    0%, 100% { transform: translateY(0) scale(1.3); }
    50% { transform: translateY(-8px) scale(1.4); }
}

@keyframes floatDown {
    0%, 100% { transform: translateY(0) scale(1.3); }
    50% { transform: translateY(8px) scale(1.4); }
}

@keyframes wiggle {
    0%, 100% { transform: rotate(0deg) scale(1.3); }
    25% { transform: rotate(5deg) scale(1.35); }
    75% { transform: rotate(-5deg) scale(1.35); }
}

/* Loading animation during sort */
.single-sort-btn.sorting {
    pointer-events: none;
}

.single-sort-btn.sorting i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Product card animations */
.product-card.sorting {
    opacity: 0.6;
    transform: scale(0.95) rotateY(5deg);
    transition: all 0.3s ease;
}

.product-card.sorted {
    animation: slideInUp 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.9) rotateX(10deg);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1) rotateX(0deg);
    }
}


/* --- 1.6 Order & Cart Styles (order.php) --- */
/* Layout หลักของหน้า */
.order-form-section .container {
    max-width: 960px; 
}

.order-form-section h2 {
    text-align: center;
    font-size: 2.8em;
    color: #8B0000;
    margin-bottom: 40px;
}

/* ตะกร้าสินค้า */
.cart-summary {
    background-color: #ffffff;
    border-radius: 12px;
    padding: 35px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
    margin-bottom: 40px;
}

/*รายการสินค้าแต่ละชิ้นในตะกร้า */
.cart-item-editable {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-bottom: 1px solid #f0f0f0;
}
.cart-item-editable:last-child {
    border-bottom: none;
}

.cart-item-details {
    display: flex; /* จัดให้อิมเมจและรายละเอียดอยู่บรรทัดเดียวกัน */
    align-items: center;
}

.cart-item-img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    margin-right: 20px;
    border: 1px solid #eee;
}

.cart-item-details p {
    margin: 0;
    font-size: 1.1em;
    font-weight: bold;
    color: #333;
}

.cart-item-price {
    font-size: 0.9em;
    color: #777;
    font-weight: normal;
}

/*ปุ่ม "อัปเดต" และ "ลบ" */
.cart-item-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Pretty quantity stepper */
.quantity-stepper {
    display: inline-flex;
    align-items: center;
    border: 1px solid #ccc;
    border-radius: 10px;
    background: #fff;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}
.quantity-stepper .qty-btn {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    color: #343a40;
    border: none;
    cursor: pointer;
    transition: background-color .2s ease, color .2s ease;
}
.quantity-stepper .qty-btn:hover { background: #DAA520; color: #fff; }
.quantity-stepper .qty-btn:active { transform: translateY(1px); }
.quantity-stepper .quantity-input-cart,
.quantity-stepper input[type="number"] {
    width: 64px;
    padding: 8px 4px;
    text-align: center;
    border: none;
    outline: none;
    font-weight: 600;
    font-size: 1rem;
    background: transparent;
}
/* remove default spinners */
.quantity-stepper .quantity-input-cart::-webkit-outer-spin-button,
.quantity-stepper .quantity-input-cart::-webkit-inner-spin-button,
.quantity-stepper input[type="number"]::-webkit-outer-spin-button,
.quantity-stepper input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.quantity-stepper .quantity-input-cart,
.quantity-stepper input[type="number"] { -moz-appearance: textfield; }

.btn-update, .btn-remove {
    border: none;
    border-radius: 6px;
    padding: 10px 16px;
    font-size: 0.9rem;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    }

.btn-update { background-color: #007bff; }
.btn-update:hover { background-color: #0056b3; transform: scale(1.05); }

.btn-remove { background-color: #dc3545; }
.btn-remove:hover { background-color: #c82333; transform: scale(1.05); }

/* สรุปยอดรวมและฟอร์ม */
.cart-total {
    text-align: right;
    font-size: 1.8em;
    font-weight: bold;
    color: #8B0000;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid #f0f0f0;
}

.cart-totals { margin-top: 14px; }
.cart-totals .cart-subtotal,
.cart-totals .cart-discount {
    text-align: right;
    color: #333;
    margin: 6px 0;
}
.cart-totals .cart-discount span { color: #dc3545; font-weight: 700; }
.coupon-form { margin-top: 16px; }
.coupon-form label { font-weight: 700; color: #8B0000; display: block; margin-bottom: 6px; }
.coupon-form .coupon-row { display:flex; gap: 8px; align-items:center; }
.coupon-form input[type="text"] { flex: 1; padding: 10px 12px; border: 1px solid #ccc; border-radius: 8px; font-size: 1rem; }
.coupon-form input[type="text"]:focus { outline: none; border-color: #DAA520; box-shadow: 0 0 0 4px rgba(218,165,32,0.2); }

#orderForm h3 {
    margin-top: 30px;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
    color: #DAA520;
    font-size: 1.5em;
}

.form-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: bold;
    color: #555;
    font-size: 1.1em;
}

.form-group input[type="text"],
.form-group input[type="tel"],
.form-group input[type="email"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 15px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 1rem;
    box-sizing: border-box; 
    transition: all 0.3s ease;
}

.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
    outline: none;
    border-color: #DAA520;
    box-shadow: 0 0 0 4px rgba(218, 165, 32, 0.2);
}

/* ปุ่มยืนยันคำสั่งซื้อ */
#orderForm button[type="submit"] {
    width: 100%;
    padding: 18px;
    font-size: 1.4rem;
    font-weight: bold;
    border-radius: 8px;
    border: none;
    background: linear-gradient(45deg, #DAA520, #B8860B);
    color: white;
    margin-top: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
}

#orderForm button[type="submit"]:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 15px rgba(218, 165, 32, 0.4);
}

/* --- 1.7 Utility Styles --- */
/* Notification Styles */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast-notification {
    background-color: #28a745; 
    color: white;
    padding: 15px 25px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    opacity: 0;
    transform: translateX(100%);
    transition: opacity 0.5s ease, transform 0.5s ease;
    font-weight: bold;
}

.toast-notification.error {
    background-color: #dc3545; 
}

.toast-notification.show {
    opacity: 1;
    transform: translateX(0);
}

/* Forms (General) - จัดการในส่วนบนแล้ว */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #555;
}

.form-group input, .form-group textarea, .form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 1em;
    box-sizing: border-box;
}


/* --- 1.8 Responsive Adjustments --- */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        text-align: center;
    }

    nav ul {
        flex-direction: column;
        align-items: center;
        margin-top: 15px;
    }
    nav ul li {
        margin: 5px 0;
    }

    .auth-buttons {
        margin-top: 15px;
    }

    .hero-section {
        height: auto;
        padding: 60px 20px;
    }
    .hero-text h2 {
        font-size: 2.5em;
    }
    .hero-text p {
        font-size: 1em;
    }
    .hero-buttons {
        display: flex;
        flex-direction: column;
        gap: 15px;
    }
    .hero-buttons .btn {
        margin: 0;
        width: 100%;
    }
    
    .single-sort-btn {
        width: 100%;
        min-width: auto;
        padding: 18px 24px;
        font-size: 15px;
    }
    
    .single-sort-btn i {
        font-size: 18px;
    }
    
    .filter-sort-controls {
        padding: 20px;
    }
}


/*=====================================
    2. BACKEND STYLES (ADMIN PANEL)
=====================================*/
:root {
    --admin-bg: #f4f7fc; 
    --sidebar-bg: #ffffff;
    --sidebar-width: 260px;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --accent-color: #4a6cf7; 
    --border-color: #e5e7eb;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

.admin-wrapper {
    display: flex;
}

/* --- 2.1 Sidebar --- */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    padding: 1rem;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
}

.sidebar-brand .fas {
    margin-right: 10px;
    color: var(--accent-color);
}

.sidebar-divider {
    margin: 1rem 0;
    border-top: 1px solid var(--border-color);
}

.sidebar .nav-item {
    margin-bottom: 0.25rem;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    padding: 0.85rem 1rem;
    border-radius: 0.5rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-decoration: none;
    transition: background-color 0.2s, color 0.2s;
}

.sidebar .nav-link .fas {
    width: 25px;
    margin-right: 0.75rem;
    font-size: 1.1rem;
    text-align: center;
}

.sidebar .nav-link:hover {
    background-color: #f0f2f5;
    color: var(--text-primary);
}

/* Active Link Style */
body.admin-page-dashboard .sidebar a[href="admin_dashboard.php"],
body.admin-page-products .sidebar a[href="admin_products.php"],
body.admin-page-orders .sidebar a[href="admin_orders.php"],
body.admin-page-users .sidebar a[href="admin_users.php"],
body.admin-page-messages .sidebar a[href="admin_messages.php"],
body.admin-page-settings .sidebar a[href="admin_settings.php"] {
    background-color: var(--accent-color);
    color: #fff;
    box-shadow: 0 4px 10px -2px rgba(74, 108, 247, 0.4);
}
body.admin-page-dashboard .sidebar a[href="admin_dashboard.php"] .fas,
body.admin-page-products .sidebar a[href="admin_products.php"] .fas,
body.admin-page-orders .sidebar a[href="admin_orders.php"] .fas,
body.admin-page-users .sidebar a[href="admin_users.php"] .fas,
body.admin-page-messages .sidebar a[href="admin_messages.php"] .fas,
body.admin-page-settings .sidebar a[href="admin_settings.php"] .fas {
    color: #fff;
}


/* --- 2.2 Main Content & Navbar --- */
.admin-main-content {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    padding: 1.5rem;
}

.admin-navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #ffffff;
    border-radius: 0.5rem;
    box-shadow: var(--shadow);
    padding: 0.75rem 1.5rem;
    margin-bottom: 1.5rem;
}

/* --- 2.3 General Components (Admin) --- */
.card {
    border: none;
    border-radius: 0.5rem;
    box-shadow: var(--shadow);
}

.table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
}

.table thead th {
    background-color: #f8f9fa;
    border-bottom: 2px solid var(--border-color);
    border-top: none;
}

.table td, .table th {
    border-top: 1px solid var(--border-color);
}
