:root {
    --primary: #667eea;
    --primary-dark: #5a67d8;
    --primary-light: #818cf8;
    --secondary: #ec4899;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    
    --bg: #f8fafc;
    --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --card: #ffffff;
    --card-hover: #f1f5f9;
    
    --text: #1e293b;
    --text-light: #64748b;
    --text-muted: #94a3b8;
    
    --border: #e2e8f0;
    --border-dark: #cbd5e1;
    
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.15);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    background-image: 
        radial-gradient(circle at 20% 50%, rgba(102, 126, 234, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(236, 72, 153, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 20%, rgba(16, 185, 129, 0.1) 0%, transparent 50%);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    color: var(--text);
    margin-top: 0;
    font-weight: 600;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: all 0.3s ease;
}

a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    background: var(--bg-gradient);
    color: #fff;
    border: none;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-md);
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.2);
    transition: left 0.5s ease;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    text-decoration: none;
}

.btn:hover::before {
    left: 100%;
}

.btn:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

.btn.outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

.btn.outline:hover {
    background: var(--primary);
    color: #fff;
}

.btn.success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.btn.danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.btn.warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

/* Navigation */
.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav .logo {
    font-weight: 700;
    font-size: 1.5rem;
    background: var(--bg-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Grid */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin: 1.5rem 0;
}

/* Cards */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--bg-gradient);
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-xl);
    border-color: var(--primary-light);
}

.card img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-radius: 0.75rem;
    margin-bottom: 1rem;
    transition: transform 0.3s ease;
}

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

.card h3 {
    margin-bottom: 0.5rem;
    color: var(--text);
}

.card p {
    color: var(--text-light);
    margin: 0.5rem 0;
}

/* Forms */
.input, select, textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    border: 2px solid var(--border);
    background: var(--card);
    color: var(--text);
    font-size: 1rem;
    transition: all 0.3s ease;
}

.input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.input::placeholder {
    color: var(--text-muted);
}

/* Tables */
.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--card);
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.table th {
    background: var(--bg-gradient);
    color: #fff;
    padding: 1rem;
    text-align: left;
    font-weight: 600;
}

.table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

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

.table tr:hover {
    background: var(--card-hover);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.35rem 0.75rem;
    border-radius: 2rem;
    background: var(--bg-gradient);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

.badge.success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.badge.warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.badge.danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.badge.info {
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
}

/* Alerts */
.alert {
    padding: 1rem 1.5rem;
    border-radius: 0.75rem;
    margin: 1rem 0;
    border-left: 4px solid;
    box-shadow: var(--shadow-md);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(-20px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.alert.error {
    background: #fee2e2;
    color: #991b1b;
    border-color: #ef4444;
}

.alert.success {
    background: #d1fae5;
    color: #065f46;
    border-color: #10b981;
}

.alert.warning {
    background: #fef3c7;
    color: #92400e;
    border-color: #f59e0b;
}

.alert.info {
    background: #cffafe;
    color: #083344;
    border-color: #06b6d4;
}

/* Footer */
.footer {
    color: var(--text-muted);
    text-align: center;
    padding: 3rem 0;
    margin-top: 3rem;
    border-top: 1px solid var(--border);
    background: linear-gradient(to bottom, transparent, rgba(102, 126, 234, 0.05));
}

/* Header */
.header {
    padding: 2rem 0;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(236, 72, 153, 0.1) 100%);
    border-radius: 1rem;
    margin-bottom: 2rem;
}

/* Horizontal Rule */
hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2rem 0;
    position: relative;
}

hr::after {
    content: '✦';
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg);
    padding: 0 1rem;
    color: var(--primary);
}

/* Quantity Input */
.qty {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.qty input {
    width: 80px;
    text-align: center;
    border-radius: 0.5rem;
    border: 2px solid var(--border);
    padding: 0.5rem;
}

.qty button {
    width: 36px;
    height: 36px;
    border-radius: 0.5rem;
    border: 2px solid var(--primary);
    background: var(--card);
    color: var(--primary);
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
}

.qty button:hover {
    background: var(--primary);
    color: #fff;
}

/* Flex Utilities */
.flex {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.right {
    margin-left: auto;
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--border);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 1s linear infinite;
}

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

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    .grid {
        grid-template-columns: 1fr;
    }
    
    .nav {
        flex-direction: column;
        gap: 1rem;
    }
    
    .table {
        font-size: 0.9rem;
    }
    
    .table th, .table td {
        padding: 0.75rem 0.5rem;
    }
}

  /* ถ้าหน้าใดมีแถบลอยล่าง (เช่น sticky bar ใน cart/checkout) ให้เลื่อนบับเบิลขึ้น */
  body.has-sticky #chatBubble { bottom: 76px; }

  /* ทำให้หน้าต่างแชทพอดีกับมือถือ */
  @media (max-width: 600px){
    #chatPane { width: calc(100vw - 24px); height: 60vh; }
  }
