/* ── Reset & Variables ──────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy: #1a2332;
  --navy-light: #243044;
  --accent: #2e86ab;
  --accent-hover: #256d8b;
  --green: #28a745;
  --orange: #e8871e;
  --red: #dc3545;
  --yellow: #ffc107;
  --grey-50: #f8f9fa;
  --grey-100: #f1f3f5;
  --grey-200: #e9ecef;
  --grey-400: #adb5bd;
  --grey-600: #6c757d;
  --grey-800: #343a40;
  --white: #ffffff;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.1);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.15);
  --max-width: 1100px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body { font-family: var(--font); color: var(--grey-800); line-height: 1.6; background: var(--white); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ── Layout ────────────────────────────────────────────── */
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 1.5rem; }

/* ── Header / Nav ──────────────────────────────────────── */
.site-header { background: var(--navy); color: var(--white); padding: 1rem 0; position: sticky; top: 0; z-index: 100; }
.site-header .container { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem; }
.site-header .logo { font-size: 1.3rem; font-weight: 700; color: var(--white); }
.site-header .logo span { color: var(--accent); }
.site-header nav { display: flex; gap: 1.5rem; align-items: center; }
.site-header nav a { color: var(--grey-200); font-size: 0.95rem; }
.site-header nav a:hover { color: var(--white); text-decoration: none; }
.nav-btn { background: var(--accent); color: var(--white) !important; padding: 0.4rem 1rem; border-radius: var(--radius); font-weight: 600; }
.nav-btn:hover { background: var(--accent-hover); }

/* ── Hero ──────────────────────────────────────────────── */
.hero { background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%); color: var(--white); padding: 5rem 0 4rem; text-align: center; }
.hero h1 { font-size: 2.4rem; margin-bottom: 1rem; line-height: 1.2; }
.hero p { font-size: 1.15rem; color: var(--grey-200); max-width: 600px; margin: 0 auto 2rem; }
.hero .cta-btn { display: inline-block; background: var(--accent); color: var(--white); padding: 0.75rem 2rem; border-radius: var(--radius); font-size: 1.05rem; font-weight: 600; }
.hero .cta-btn:hover { background: var(--accent-hover); text-decoration: none; }

/* ── Services ──────────────────────────────────────────── */
.section { padding: 4rem 0; }
.section-alt { background: var(--grey-50); }
.section h2 { font-size: 1.8rem; text-align: center; margin-bottom: 0.5rem; }
.section .subtitle { text-align: center; color: var(--grey-600); margin-bottom: 2.5rem; }

.services-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.5rem; }
.service-card { background: var(--white); border: 1px solid var(--grey-200); border-radius: var(--radius); padding: 2rem 1.5rem; text-align: center; }
.section-alt .service-card { background: var(--white); }
.service-card .icon { font-size: 2rem; margin-bottom: 1rem; }
.service-card h3 { font-size: 1.1rem; margin-bottom: 0.5rem; }
.service-card p { font-size: 0.92rem; color: var(--grey-600); }

/* ── About ─────────────────────────────────────────────── */
.about-content { max-width: 700px; margin: 0 auto; text-align: center; }
.about-content p { margin-bottom: 1rem; color: var(--grey-600); }

/* ── Chat Widget ───────────────────────────────────────── */
.chat-section { text-align: center; }
.chat-section p.subtitle { max-width: 500px; margin-left: auto; margin-right: auto; }

.chat-box { max-width: 600px; margin: 0 auto; border: 1px solid var(--grey-200); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); text-align: left; }
.chat-messages { height: 320px; overflow-y: auto; padding: 1rem; background: var(--grey-50); display: flex; flex-direction: column; gap: 0.75rem; }
.chat-msg { max-width: 85%; padding: 0.6rem 1rem; border-radius: 12px; font-size: 0.93rem; line-height: 1.5; }
.chat-msg.user { align-self: flex-end; background: var(--accent); color: var(--white); border-bottom-right-radius: 4px; }
.chat-msg.assistant { align-self: flex-start; background: var(--white); border: 1px solid var(--grey-200); border-bottom-left-radius: 4px; }
.chat-msg.assistant .typing { display: inline-block; }
.chat-msg.assistant .typing::after { content: '...'; animation: dots 1.2s steps(4, end) infinite; }
@keyframes dots { 0%{content:''} 25%{content:'.'} 50%{content:'..'} 75%{content:'...'} }

.chat-input-row { display: flex; border-top: 1px solid var(--grey-200); }
.chat-input-row input { flex: 1; padding: 0.75rem 1rem; border: none; outline: none; font-size: 0.95rem; font-family: var(--font); }
.chat-input-row button { background: var(--accent); color: var(--white); border: none; padding: 0.75rem 1.25rem; cursor: pointer; font-size: 0.95rem; font-weight: 600; }
.chat-input-row button:hover { background: var(--accent-hover); }
.chat-input-row button:disabled { background: var(--grey-400); cursor: not-allowed; }
.chat-powered { text-align: center; font-size: 0.78rem; color: var(--grey-400); padding: 0.4rem; }

/* ── Footer ────────────────────────────────────────────── */
.site-footer { background: var(--navy); color: var(--grey-400); padding: 2rem 0; text-align: center; font-size: 0.88rem; }
.site-footer a { color: var(--grey-200); }

/* ── Auth Page ─────────────────────────────────────────── */
.auth-page { min-height: 80vh; display: flex; align-items: center; justify-content: center; background: var(--grey-50); }
.auth-card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 2.5rem 2rem; width: 100%; max-width: 420px; }
.auth-card h2 { text-align: center; margin-bottom: 1.5rem; }

.tab-row { display: flex; border-bottom: 2px solid var(--grey-200); margin-bottom: 1.5rem; }
.tab-row button { flex: 1; background: none; border: none; padding: 0.6rem; font-size: 1rem; cursor: pointer; color: var(--grey-600); border-bottom: 2px solid transparent; margin-bottom: -2px; font-family: var(--font); }
.tab-row button.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.88rem; font-weight: 600; margin-bottom: 0.3rem; color: var(--grey-800); }
.form-group input { width: 100%; padding: 0.6rem 0.75rem; border: 1px solid var(--grey-200); border-radius: var(--radius); font-size: 0.95rem; font-family: var(--font); }
.form-group input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(46,134,171,0.15); }

.btn { display: block; width: 100%; padding: 0.7rem; border: none; border-radius: var(--radius); font-size: 1rem; font-weight: 600; cursor: pointer; font-family: var(--font); }
.btn-primary { background: var(--accent); color: var(--white); }
.btn-primary:hover { background: var(--accent-hover); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.alert { padding: 0.6rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: 0.9rem; }
.alert-error { background: #fde8e8; color: var(--red); border: 1px solid #f5c6cb; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }

/* ── Middle Acres ──────────────────────────────────────── */
.ma-header { background: linear-gradient(135deg, #2d4a22 0%, #3a5f2c 100%); color: var(--white); padding: 2rem 0; }
.ma-header h1 { font-size: 1.8rem; }
.ma-header p { color: #c5ddbf; }
.ma-header .container { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1rem; }
.ma-nav { display: flex; gap: 1rem; align-items: center; }
.ma-nav a { color: #c5ddbf; font-size: 0.95rem; }
.ma-nav a:hover { color: var(--white); text-decoration: none; }

.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.5rem; }
.category-label { grid-column: 1 / -1; font-size: 1.3rem; font-weight: 700; margin-top: 1rem; padding-bottom: 0.5rem; border-bottom: 2px solid var(--grey-200); }
.product-card { background: var(--white); border: 1px solid var(--grey-200); border-radius: var(--radius); padding: 1.25rem; display: flex; flex-direction: column; }
.product-card h4 { margin-bottom: 0.3rem; }
.product-card .price { font-size: 1.15rem; font-weight: 700; color: var(--green); margin-bottom: 0.25rem; }
.product-card .desc { font-size: 0.88rem; color: var(--grey-600); flex: 1; margin-bottom: 0.75rem; }
.product-card .stock { font-size: 0.8rem; margin-bottom: 0.5rem; }
.stock-in { color: var(--green); }
.stock-out { color: var(--red); }
.add-row { display: flex; gap: 0.5rem; align-items: center; }
.add-row input { width: 60px; padding: 0.35rem 0.5rem; border: 1px solid var(--grey-200); border-radius: var(--radius); text-align: center; font-size: 0.9rem; }
.add-row button { padding: 0.35rem 0.8rem; background: var(--accent); color: var(--white); border: none; border-radius: var(--radius); cursor: pointer; font-size: 0.88rem; font-weight: 600; }
.add-row button:hover { background: var(--accent-hover); }

/* Cart */
.cart-bar { position: sticky; bottom: 0; background: var(--navy); color: var(--white); padding: 0.75rem 0; z-index: 50; display: none; }
.cart-bar.visible { display: block; }
.cart-bar .container { display: flex; justify-content: space-between; align-items: center; }
.cart-bar .cart-summary { font-size: 0.95rem; }
.cart-bar button { background: var(--green); color: var(--white); border: none; padding: 0.5rem 1.5rem; border-radius: var(--radius); font-weight: 600; cursor: pointer; font-size: 0.95rem; }
.cart-bar button:hover { background: #219838; }

/* Cart modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 200; display: none; align-items: center; justify-content: center; }
.modal-overlay.visible { display: flex; }
.modal { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 2rem; width: 90%; max-width: 500px; max-height: 80vh; overflow-y: auto; }
.modal h3 { margin-bottom: 1rem; }
.modal-items { margin-bottom: 1rem; }
.modal-item { display: flex; justify-content: space-between; padding: 0.4rem 0; border-bottom: 1px solid var(--grey-100); font-size: 0.92rem; }
.modal-item .remove { color: var(--red); cursor: pointer; font-size: 0.85rem; }
.modal-total { font-size: 1.1rem; font-weight: 700; text-align: right; margin-bottom: 1rem; }
.modal-actions { display: flex; gap: 0.75rem; }
.modal-actions button { flex: 1; padding: 0.6rem; border: none; border-radius: var(--radius); cursor: pointer; font-weight: 600; font-size: 0.95rem; }
.btn-cancel { background: var(--grey-200); color: var(--grey-800); }
.btn-confirm { background: var(--green); color: var(--white); }

/* ── Orders Page ───────────────────────────────────────── */
.order-list { max-width: 700px; margin: 0 auto; }
.order-card { background: var(--white); border: 1px solid var(--grey-200); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; cursor: pointer; }
.order-card:hover { box-shadow: var(--shadow); }
.order-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.order-header .order-date { font-weight: 600; }
.order-header .order-total { font-size: 1.1rem; font-weight: 700; }
.status-badge { display: inline-block; padding: 0.15rem 0.6rem; border-radius: 12px; font-size: 0.78rem; font-weight: 600; text-transform: uppercase; }
.status-pending { background: #fff3cd; color: #856404; }
.status-confirmed { background: #cce5ff; color: #004085; }
.status-ready { background: #d4edda; color: #155724; }
.status-completed { background: var(--grey-200); color: var(--grey-600); }
.status-cancelled { background: #f8d7da; color: #721c24; }
.order-items-detail { margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid var(--grey-100); display: none; }
.order-items-detail.open { display: block; }
.order-items-detail table { width: 100%; font-size: 0.9rem; }
.order-items-detail th { text-align: left; padding: 0.3rem 0; color: var(--grey-600); font-weight: 600; }
.order-items-detail td { padding: 0.3rem 0; }

/* ── API Guide ─────────────────────────────────────────── */
.guide-content { max-width: 750px; margin: 0 auto; }
.guide-content h2 { font-size: 1.4rem; margin: 2rem 0 0.75rem; border-bottom: 1px solid var(--grey-200); padding-bottom: 0.3rem; }
.guide-content h3 { font-size: 1.1rem; margin: 1.5rem 0 0.5rem; }
.guide-content p { margin-bottom: 0.75rem; color: var(--grey-600); }
.guide-content code { background: var(--grey-100); padding: 0.15rem 0.4rem; border-radius: 4px; font-size: 0.88rem; }
.guide-content pre { background: var(--grey-800); color: #e9ecef; padding: 1rem; border-radius: var(--radius); overflow-x: auto; margin-bottom: 1rem; font-size: 0.85rem; line-height: 1.5; }
.guide-content pre code { background: none; padding: 0; color: inherit; }
.guide-content ul, .guide-content ol { margin: 0 0 1rem 1.5rem; color: var(--grey-600); }
.guide-content li { margin-bottom: 0.3rem; }

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 768px) {
  .hero h1 { font-size: 1.8rem; }
  .hero { padding: 3rem 0; }
  .site-header .container { flex-direction: column; }
  .services-grid { grid-template-columns: 1fr; }
  .product-grid { grid-template-columns: 1fr; }
}
