/**
 * shop/assets/css/shop.css
 * ระบบ Shop ทิพย์เทวี - Mobile-first Design v2
 */

:root {
    --primary-50: #f0f9ff;
    --primary-100: #e0f2fe;
    --primary-200: #bae6fd;
    --primary-300: #7dd3fc;
    --primary-400: #38bdf8;
    --primary-500: #0ea5e9;
    --primary-600: #0284c7;
    --primary-700: #0369a1;
    
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    
    --white: #ffffff;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: 'Sarabun', sans-serif;
    line-height: 1.6;
    color: var(--gray-800);
    background: var(--gray-50);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--primary-600); text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* ============== HEADER ============== */
.header {
    background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
    color: var(--white);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
    gap: 1rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--white);
}

.logo img {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
}

.logo span { display: none; }

.nav-menu {
    display: none;
    gap: 1.5rem;
}

.nav-menu a {
    color: var(--white);
    font-weight: 500;
    opacity: 0.9;
}

.nav-menu a:hover { opacity: 1; }

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.cart-btn {
    position: relative;
    background: rgba(255,255,255,0.15);
    border: none;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    color: var(--white);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.cart-btn:hover { background: rgba(255,255,255,0.25); }

.cart-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--danger);
    color: var(--white);
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.menu-toggle {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
}

.menu-toggle span {
    width: 24px;
    height: 2px;
    background: var(--white);
    border-radius: 2px;
}

/* ============== USER STATUS ============== */
.user-status {
    background: var(--primary-50);
    border-bottom: 1px solid var(--primary-100);
    padding: 0.5rem;
    font-size: 0.85rem;
    text-align: center;
}

.user-status strong { color: var(--primary-700); }
.user-status a { margin-left: 0.5rem; font-weight: 500; }

/* ============== MAIN ============== */
main { flex: 1; padding: 1rem 0; }

/* ============== BREADCRUMB ============== */
.breadcrumb {
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    color: var(--white);
    padding: 1.5rem 0;
    margin-bottom: 1rem;
    text-align: center;
}

.breadcrumb h1 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.breadcrumb-nav {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    opacity: 0.9;
}

.breadcrumb-nav a { color: var(--white); }

/* ============== SECTION TITLE ============== */
.section-title {
    margin-bottom: 1rem;
}

.section-title h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 0.25rem;
}

.section-title p {
    color: var(--gray-500);
    font-size: 0.85rem;
}

/* ============== PRODUCT GRID ============== */
.product-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

/* ============== PRODUCT CARD ============== */
.product-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
}

.product-image {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    background: var(--gray-100);
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-badge {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    background: var(--primary-500);
    color: var(--white);
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.2rem 0.4rem;
    border-radius: 0.25rem;
}

.product-badge.package { background: var(--success); }
.product-badge.out-of-stock { background: var(--danger); left: auto; right: 0.5rem; }

.product-content {
    padding: 0.75rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.product-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--gray-800);
    margin-bottom: 0.25rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-code {
    font-size: 0.7rem;
    color: var(--gray-400);
    margin-bottom: 0.5rem;
}

.product-price {
    margin-top: auto;
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary-600);
}

.product-price small {
    font-size: 0.75rem;
    font-weight: 400;
}

.product-actions {
    padding: 0 0.75rem 0.75rem;
}

.btn-view {
    width: 100%;
    padding: 0.5rem;
    background: var(--primary-500);
    color: var(--white);
    border: none;
    border-radius: var(--radius);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    text-decoration: none;
}

.btn-view:hover { background: var(--primary-600); color: var(--white); }

/* ============== CART SECTION ============== */
.cart-section {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.cart-header {
    background: var(--primary-50);
    padding: 1rem;
    border-bottom: 1px solid var(--primary-100);
}

.cart-header h2 {
    font-size: 1rem;
    color: var(--primary-700);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cart-item {
    padding: 1rem;
    border-bottom: 1px solid var(--gray-100);
    display: grid;
    grid-template-columns: 70px 1fr;
    gap: 0.75rem;
    align-items: start;
}

.cart-item:last-child { border-bottom: none; }

.cart-item-image {
    width: 70px;
    height: 70px;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--gray-100);
}

.cart-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cart-item-details {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.cart-item-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--gray-800);
}

.cart-item-code {
    font-size: 0.7rem;
    color: var(--gray-400);
}

.cart-item-price {
    font-weight: 600;
    color: var(--primary-600);
    font-size: 0.9rem;
}

.cart-item-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

/* ============== QUANTITY CONTROL ============== */
.qty-control {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    overflow: hidden;
}

.qty-btn {
    width: 30px;
    height: 30px;
    border: none;
    background: var(--gray-50);
    color: var(--gray-600);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.qty-btn:hover { background: var(--gray-100); }
.qty-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.qty-input {
    width: 40px;
    height: 30px;
    border: none;
    border-left: 1px solid var(--gray-200);
    border-right: 1px solid var(--gray-200);
    text-align: center;
    font-weight: 600;
    font-size: 0.85rem;
}

.qty-input:focus { outline: none; }

.btn-remove {
    padding: 0.25rem 0.5rem;
    background: var(--danger);
    color: var(--white);
    border: none;
    border-radius: 0.25rem;
    font-size: 0.7rem;
    cursor: pointer;
}

.btn-remove:hover { background: #dc2626; }

/* ============== CART EMPTY ============== */
.cart-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--gray-500);
}

.cart-empty svg {
    width: 50px;
    height: 50px;
    margin-bottom: 0.75rem;
    opacity: 0.5;
}

/* ============== CART SUMMARY ============== */
.cart-summary {
    background: var(--gray-50);
    padding: 1rem;
    border-top: 1px solid var(--gray-200);
}

.summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.summary-row.total {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary-700);
    padding-top: 0.5rem;
    border-top: 1px solid var(--gray-200);
    margin-top: 0.5rem;
    margin-bottom: 1rem;
}

/* ============== BUTTONS ============== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-primary { background: var(--primary-500); color: var(--white); }
.btn-primary:hover { background: var(--primary-600); color: var(--white); }

.btn-secondary { background: var(--white); color: var(--gray-700); border: 1px solid var(--gray-300); }
.btn-secondary:hover { background: var(--gray-50); color: var(--gray-800); }

.btn-success { background: var(--success); color: var(--white); }
.btn-success:hover { background: #059669; color: var(--white); }

.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { background: #dc2626; color: var(--white); }

.btn-block { width: 100%; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* ============== FORMS ============== */
.form-group { margin-bottom: 0.75rem; }

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 0.25rem;
}

.form-label .required { color: var(--danger); }

.form-control {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 1rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    background: var(--white);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px var(--primary-100);
}

.form-control:read-only {
    background: var(--gray-100);
}

/* ============== SUGGESTIONS ============== */
.suggestions-wrapper { position: relative; }

.suggestions-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}

.suggestions-list.show { display: block; }

.suggestion-item {
    padding: 0.625rem 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.9rem;
}

.suggestion-item:last-child { border-bottom: none; }
.suggestion-item:hover { background: var(--primary-50); }
.suggestion-item .district { font-size: 0.75rem; color: var(--gray-500); }

/* ============== CHECKOUT ============== */
.checkout-section {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
}

.checkout-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--gray-100);
}

.checkout-header h3 {
    font-size: 1rem;
    color: var(--gray-800);
}

.checkout-body { padding: 1rem; }

.btn-copy-address {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    background: var(--primary-100);
    color: var(--primary-700);
    border: none;
    border-radius: 0.25rem;
    cursor: pointer;
    margin-bottom: 0.75rem;
}

.order-summary {
    background: var(--primary-50);
    border: 1px solid var(--primary-100);
    border-radius: var(--radius);
    padding: 0.75rem;
}

.order-item {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--primary-100);
    font-size: 0.85rem;
}

.order-item:last-of-type { border-bottom: none; }

.order-item-image {
    width: 40px;
    height: 40px;
    border-radius: 0.25rem;
    overflow: hidden;
    flex-shrink: 0;
}

.order-item-image img { width: 100%; height: 100%; object-fit: cover; }

.order-item-info { flex: 1; min-width: 0; }
.order-item-name { font-weight: 500; font-size: 0.8rem; }
.order-item-meta { font-size: 0.7rem; color: var(--gray-500); }

/* ============== PAYMENT ============== */
.payment-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    text-align: center;
    padding: 1.5rem 1rem;
    max-width: 400px;
    margin: 0 auto;
}

.payment-card h2 {
    color: var(--success);
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.payment-warning {
    background: #fef2f2;
    color: var(--danger);
    padding: 0.5rem;
    border-radius: var(--radius);
    font-size: 0.8rem;
    margin-bottom: 0.75rem;
}

.payment-invoice {
    font-size: 0.85rem;
    color: var(--gray-600);
    margin-bottom: 0.75rem;
}

.payment-invoice strong {
    display: block;
    font-size: 1.1rem;
    color: var(--primary-600);
}

.payment-timer {
    background: var(--primary-50);
    padding: 0.75rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.payment-timer p { font-size: 0.8rem; color: var(--gray-600); margin-bottom: 0.25rem; }
.payment-timer .countdown { font-size: 1.5rem; font-weight: 700; color: var(--primary-600); }

.qr-container {
    background: var(--white);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 0.75rem;
    display: inline-block;
    margin-bottom: 0.75rem;
}

.qr-container img { max-width: 180px; }

.qr-warning {
    background: #fef3c7;
    color: #92400e;
    padding: 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.7rem;
    margin-bottom: 0.75rem;
}

.payment-total {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-700);
    margin-bottom: 0.25rem;
}

.payment-account {
    font-size: 0.8rem;
    color: var(--gray-600);
    margin-bottom: 1rem;
}

.status-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 0.75rem;
}

.status-icon.success { background: #d1fae5; color: var(--success); }
.status-icon.fail { background: #fee2e2; color: var(--danger); }
.status-icon svg { width: 30px; height: 30px; }

/* ============== FOOTER ============== */
.footer {
    background: var(--gray-800);
    color: var(--gray-300);
    padding: 1.5rem 0;
    margin-top: auto;
}

.footer-content { text-align: center; }
.footer-logo { font-size: 1.1rem; font-weight: 700; color: var(--white); margin-bottom: 0.5rem; }
.footer-address { font-size: 0.8rem; line-height: 1.6; margin-bottom: 0.75rem; }
.footer-address a { color: var(--primary-300); }
.footer-copyright { font-size: 0.75rem; color: var(--gray-500); padding-top: 0.75rem; border-top: 1px solid var(--gray-700); }

/* ============== ALERTS ============== */
.alert {
    padding: 0.625rem 0.75rem;
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
}

.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: var(--primary-50); color: var(--primary-800); border: 1px solid var(--primary-200); }

/* ============== TOAST ============== */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 0.75rem 1rem;
    min-width: 260px;
    max-width: 320px;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }

.toast-icon { flex-shrink: 0; width: 20px; }
.toast-content { flex: 1; }
.toast-title { font-weight: 600; font-size: 0.85rem; }
.toast-message { font-size: 0.8rem; color: var(--gray-600); }
.toast-close { background: none; border: none; cursor: pointer; color: var(--gray-400); padding: 0; font-size: 1.2rem; line-height: 1; }

/* ============== LOADING ============== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
}

.loading-overlay.show { opacity: 1; visibility: visible; }

.spinner {
    width: 30px;
    height: 30px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary-500);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ============== MOBILE MENU ============== */
.mobile-menu {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100vh;
    background: var(--white);
    z-index: 2000;
    transition: left 0.3s ease;
    box-shadow: var(--shadow-lg);
}

.mobile-menu.open { left: 0; }

.mobile-menu-header {
    background: var(--primary-600);
    color: var(--white);
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}

.mobile-menu-close {
    background: none;
    border: none;
    color: var(--white);
    font-size: 1.5rem;
    cursor: pointer;
}

.mobile-menu-nav { padding: 0.5rem 0; }

.mobile-menu-nav a {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--gray-700);
    font-weight: 500;
    border-bottom: 1px solid var(--gray-100);
}

.mobile-menu-nav a:hover { background: var(--gray-50); color: var(--primary-600); }

.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
}

.menu-overlay.show { opacity: 1; visibility: visible; }

/* ============== UTILITIES ============== */
.text-center { text-align: center; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.hidden { display: none !important; }

/* ============== RESPONSIVE ============== */
@media (min-width: 640px) {
    .product-grid { grid-template-columns: repeat(3, 1fr); gap: 1rem; }
    .btn-group { flex-direction: row; }
    .btn-group .btn { flex: 1; }
}

@media (min-width: 768px) {
    .logo span { display: inline; }
    .nav-menu { display: flex; }
    .menu-toggle { display: none; }
    .breadcrumb h1 { font-size: 1.5rem; }
    .cart-item { grid-template-columns: 80px 1fr; }
    .cart-item-image { width: 80px; height: 80px; }
    .checkout-grid { display: grid; grid-template-columns: 1fr 350px; gap: 1rem; }
    .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
}

@media (min-width: 1024px) {
    .product-grid { grid-template-columns: repeat(4, 1fr); }
}
