/* ================================================================
   Terai Roots — Public Storefront Styles
   ================================================================ */

/* Ensure [hidden] always wins over class-level display rules */
[hidden] { display: none !important; }

:root {
    --brand:       #2d6a4f;
    --brand-lt:    #40916c;
    --brand-dk:    #1b4332;
    --accent:      #f4a261;
    --accent-dk:   #e08040;
    --bg:          #f4f7f4;
    --surface:     #ffffff;
    --border:      #d8e8d8;
    --text:        #1e2923;
    --muted:       #6b7c72;
    --success:     #28a745;
    --warning:     #e6a817;
    --danger:      #d63031;
    --info:        #17a2b8;
    --radius:      8px;
    --radius-lg:   12px;
    --shadow:      0 2px 12px rgba(0,0,0,.08);
    --shadow-md:   0 4px 20px rgba(0,0,0,.12);
    --transition:  all .2s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.65;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dk); }
img { max-width: 100%; height: auto; display: block; }
ul { list-style: none; }

/* ── Typography ─────────────────────────────────────────────── */
h1,h2,h3,h4,h5 { font-weight: 700; line-height: 1.3; color: var(--brand-dk); }
h1 { font-size: 2rem; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.05rem; }
p { margin-bottom: .75rem; }
p:last-child { margin-bottom: 0; }

/* ── Layout ─────────────────────────────────────────────────── */
.container    { max-width: 1200px; margin: 0 auto; padding: 0 1.25rem; }
.container-sm { max-width: 700px;  margin: 0 auto; padding: 0 1.25rem; }
.section      { padding: 3rem 0; }
.main-wrap    { flex: 1; }

/* ── Grid ───────────────────────────────────────────────────── */
.grid      { display: grid; gap: 1.5rem; }
.grid-2    { grid-template-columns: repeat(2, 1fr); }
.grid-3    { grid-template-columns: repeat(3, 1fr); }
.grid-4    { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }

/* ── Flex helpers ───────────────────────────────────────────── */
.flex         { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-center  { display: flex; align-items: center; justify-content: center; }
.flex-wrap    { flex-wrap: wrap; }
.gap-1  { gap: .5rem;  }
.gap-2  { gap: 1rem;   }
.gap-3  { gap: 1.5rem; }

/* ── Spacing ────────────────────────────────────────────────── */
.mt-1 { margin-top: .5rem;  }
.mt-2 { margin-top: 1rem;   }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem;   }
.mb-1 { margin-bottom: .5rem;  }
.mb-2 { margin-bottom: 1rem;   }
.mb-3 { margin-bottom: 1.5rem; }
.py-2 { padding-top: 1rem;   padding-bottom: 1rem;   }
.py-3 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.px-2 { padding-left: 1rem;  padding-right: 1rem;    }
.text-right  { text-align: right;  }
.text-center { text-align: center; }
.text-muted  { color: var(--muted); }
.fw-bold     { font-weight: 700; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: .45rem;
    padding: .55rem 1.25rem; border: 2px solid transparent;
    border-radius: var(--radius); font-size: .93rem; font-weight: 600;
    cursor: pointer; transition: var(--transition);
    text-decoration: none; line-height: 1.4; white-space: nowrap;
    font-family: inherit;
}
.btn:disabled { opacity: .6; cursor: not-allowed; pointer-events: none; }
.btn-primary  { background: var(--brand);  color: #fff; border-color: var(--brand);  }
.btn-primary:hover { background: var(--brand-dk); border-color: var(--brand-dk); color: #fff; }
.btn-outline  { background: transparent; color: var(--brand); border-color: var(--brand); }
.btn-outline:hover { background: var(--brand); color: #fff; }
.btn-accent   { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-accent:hover { background: var(--accent-dk); border-color: var(--accent-dk); color: #fff; }
.btn-danger   { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #b02026; border-color: #b02026; color: #fff; }
.btn-secondary { background: #e2e8e2; color: var(--text); border-color: #e2e8e2; }
.btn-secondary:hover { background: #cdd6cd; border-color: #cdd6cd; }
.btn-sm  { padding: .35rem .85rem; font-size: .83rem; }
.btn-lg  { padding: .75rem 1.75rem; font-size: 1.05rem; }
.btn-block { width: 100%; justify-content: center; }

/* ── Forms ───────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.2rem; }
.form-label { display: block; font-weight: 600; margin-bottom: .38rem; font-size: .9rem; color: var(--brand-dk); }
.form-control {
    width: 100%; padding: .6rem .9rem;
    border: 1.5px solid var(--border); border-radius: var(--radius);
    font-size: .95rem; font-family: inherit;
    transition: border-color .2s, box-shadow .2s;
    background: var(--surface); color: var(--text);
}
.form-control:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(45,106,79,.15); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 100px; }
.form-text  { font-size: .8rem; color: var(--muted); margin-top: .3rem; }
.form-error { color: var(--danger); font-size: .83rem; margin-top: .3rem; }
.form-row   { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.required::after { content: ' *'; color: var(--danger); }

/* ── Cards ───────────────────────────────────────────────────── */
.card       { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow: hidden; }
.card-body  { padding: 1.5rem; }
.card-title { font-size: 1.1rem; font-weight: 700; margin-bottom: .75rem; }

/* ── Alerts ──────────────────────────────────────────────────── */
.alert {
    padding: .85rem 1.1rem; border-radius: var(--radius);
    margin-bottom: 1rem; font-size: .92rem;
    border-left: 4px solid transparent;
}
.alert-success { background: #d4edda; border-color: var(--success); color: #145a2a; }
.alert-error,
.alert-danger  { background: #fde9e9; border-color: var(--danger);  color: #7b1a1a; }
.alert-warning { background: #fff4d0; border-color: var(--warning);  color: #7a5a00; }
.alert-info    { background: #d1ecf1; border-color: var(--info);     color: #0c5460; }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
    display: inline-block; padding: .22rem .65rem; border-radius: 100px;
    font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
}
.badge-success   { background: #d4edda; color: #145a2a; }
.badge-warning   { background: #fff4d0; color: #7a5a00; }
.badge-danger    { background: #fde9e9; color: #7b1a1a; }
.badge-info      { background: #d1ecf1; color: #0c5460; }
.badge-primary   { background: #d4e8df; color: var(--brand-dk); }
.badge-secondary { background: #e2e8e2; color: #44534a; }

/* ── Tables ──────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { padding: .75rem 1rem; text-align: left; }
th { background: var(--brand); color: #fff; font-weight: 600; font-size: .86rem; text-transform: uppercase; letter-spacing: .05em; }
td { border-bottom: 1px solid var(--border); font-size: .92rem; }
tr:last-child td { border-bottom: none; }
tr:nth-child(even) td { background: #f6faf6; }
tr:hover td { background: #edf5ed; transition: background .15s; }

/* ── Status badges ───────────────────────────────────────────── */
.status-pending    { background: #fff4d0; color: #7a5a00;  }
.status-confirmed  { background: #d1ecf1; color: #0c5460;  }
.status-processing { background: #d4edda; color: #145a2a;  }
.status-shipped    { background: #d4e4f7; color: #1a4d7a;  }
.status-delivered  { background: #c8f0da; color: #0e5228;  }
.status-cancelled  { background: #fde9e9; color: #7b1a1a;  }

/* ── Stock labels ────────────────────────────────────────────── */
.in-stock    { color: var(--success); font-weight: 600; font-size: .85rem; }
.low-stock   { color: var(--warning); font-weight: 600; font-size: .85rem; }
.out-of-stock{ color: var(--danger);  font-weight: 600; font-size: .85rem; }

/* ── Navbar ──────────────────────────────────────────────────── */
.navbar {
    background: var(--brand); color: #fff;
    box-shadow: 0 2px 10px rgba(0,0,0,.15);
    position: sticky; top: 0; z-index: 200;
}
.navbar-inner {
    display: flex; align-items: center; justify-content: space-between;
    padding: .7rem 1.25rem; max-width: 1200px; margin: 0 auto;
}
.navbar-brand {
    font-size: 1.4rem; font-weight: 800; color: #fff;
    display: flex; align-items: center; gap: .6rem;
    text-decoration: none;
}
.navbar-brand img { height: 40px; width: auto; }
.navbar-brand:hover { color: #d4f5e2; }
.navbar-nav { display: flex; align-items: center; gap: 1.5rem; }
.navbar-nav a { color: rgba(255,255,255,.88); font-weight: 500; font-size: .93rem; transition: color .2s; text-decoration: none; }
.navbar-nav a:hover { color: #fff; }
.navbar-cart { position: relative; }
.cart-count {
    position: absolute; top: -8px; right: -10px;
    background: var(--accent); color: #fff;
    border-radius: 50%; width: 18px; height: 18px;
    font-size: .68rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}
.navbar-toggle { display: none; background: none; border: none; color: #fff; font-size: 1.5rem; cursor: pointer; padding: .25rem; }

/* ── Hero ────────────────────────────────────────────────────── */
.hero {
    background: linear-gradient(135deg, var(--brand-dk) 0%, var(--brand-lt) 100%);
    color: #fff; padding: 4.5rem 1.25rem; text-align: center;
}
.hero h1 { font-size: 2.6rem; color: #fff; margin-bottom: 1rem; text-shadow: 0 2px 8px rgba(0,0,0,.2); }
.hero p { font-size: 1.15rem; color: rgba(255,255,255,.88); max-width: 580px; margin: 0 auto 2rem; }

/* ── Product Card ────────────────────────────────────────────── */
.product-card {
    background: var(--surface); border-radius: var(--radius-lg);
    box-shadow: var(--shadow); overflow: hidden;
    transition: transform .22s ease, box-shadow .22s ease;
    display: flex; flex-direction: column;
}
.product-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-md); }
.product-img {
    height: 200px; width: 100%; object-fit: cover; display: block;
}
.product-img-placeholder {
    height: 200px; background: #e0ede6;
    display: flex; align-items: center; justify-content: center;
    color: #aac5b5; font-size: 3.5rem;
}
.product-body { padding: 1rem 1.1rem; flex: 1; display: flex; flex-direction: column; }
.product-name { font-weight: 700; font-size: .97rem; margin-bottom: .35rem; color: var(--brand-dk); }
.product-desc { font-size: .84rem; color: var(--muted); margin-bottom: .75rem; flex: 1; }
.product-price { font-size: 1.1rem; font-weight: 800; color: var(--brand); }
.product-sale  { text-decoration: line-through; color: var(--muted); font-weight: 400; font-size: .88rem; margin-left: .4rem; }
.product-footer { padding: .75rem 1.1rem; border-top: 1px solid var(--border); background: #fafcfa; }

/* ── Category pills ──────────────────────────────────────────── */
.cat-strip { display: flex; gap: .65rem; flex-wrap: wrap; margin-bottom: 2rem; }
.cat-pill {
    padding: .42rem 1.05rem; border-radius: 100px;
    border: 1.5px solid var(--border); background: var(--surface);
    color: var(--text); font-size: .88rem; font-weight: 500;
    cursor: pointer; transition: var(--transition); text-decoration: none;
}
.cat-pill:hover, .cat-pill.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ── Cart ────────────────────────────────────────────────────── */
.cart-item-img { width: 60px; height: 60px; object-fit: cover; border-radius: var(--radius); }
.cart-qty { width: 65px; text-align: center; }
.cart-totals { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 1.5rem; }
.cart-total-row { display: flex; justify-content: space-between; padding: .55rem 0; border-bottom: 1px solid var(--border); font-size: .93rem; }
.cart-total-row:last-child { border: none; font-weight: 800; font-size: 1.05rem; }

/* ── Checkout ────────────────────────────────────────────────── */
.checkout-grid { display: grid; grid-template-columns: 1fr 360px; gap: 2rem; align-items: start; }
.order-summary-card { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 1.5rem; position: sticky; top: 80px; }
.order-sum-item { display: flex; justify-content: space-between; padding: .5rem 0; border-bottom: 1px solid var(--border); font-size: .91rem; }
.order-sum-item:last-child { border: none; }
.order-sum-total { font-weight: 800; font-size: 1.05rem; color: var(--brand-dk); }

/* ── Tracking ────────────────────────────────────────────────── */
.track-wrap { max-width: 680px; margin: 3rem auto; padding: 0 1.25rem; }
.track-card { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 2.5rem; }
.track-status-icon { font-size: 4rem; text-align: center; margin-bottom: .75rem; }
.track-info-row { display: flex; justify-content: space-between; padding: .65rem 0; border-bottom: 1px solid var(--border); font-size: .92rem; }
.track-info-row:last-child { border: none; }
.track-label { color: var(--muted); }

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 4rem 1rem; color: var(--muted); }
.empty-state-icon { font-size: 4rem; margin-bottom: 1rem; }
.empty-state h3 { color: var(--muted); font-weight: 600; }

/* ── Auth ────────────────────────────────────────────────────── */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; background: var(--bg); }
.auth-card { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); padding: 2.5rem; width: 100%; max-width: 440px; }
.auth-logo { text-align: center; margin-bottom: 1.75rem; }
.auth-logo .brand { font-size: 1.6rem; font-weight: 800; color: var(--brand); }
.auth-logo .tagline { font-size: .85rem; color: var(--muted); }
.auth-title { font-size: 1.3rem; font-weight: 700; text-align: center; margin-bottom: 1.5rem; color: var(--brand-dk); }
.auth-links { text-align: center; margin-top: 1.25rem; font-size: .88rem; color: var(--muted); }
.auth-divider { display: flex; align-items: center; gap: .75rem; margin: 1.25rem 0; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.btn-google { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: .7rem 1rem; border: 1.5px solid #dadce0; border-radius: var(--radius); background: #fff; color: #3c4043; font-size: .95rem; font-weight: 500; cursor: pointer; text-decoration: none; transition: background .15s, box-shadow .15s; }
.btn-google:hover { background: #f8f9fa; box-shadow: 0 1px 4px rgba(0,0,0,.15); color: #3c4043; text-decoration: none; }
.btn-google svg { flex-shrink: 0; }

/* ── Footer ──────────────────────────────────────────────────── */
.site-footer {
    background: var(--brand-dk); color: rgba(255,255,255,.75);
    padding: 2rem 1.25rem; text-align: center; font-size: .88rem; margin-top: auto;
}
.site-footer a { color: rgba(255,255,255,.6); }
.site-footer a:hover { color: #fff; }

/* ── Toast ───────────────────────────────────────────────────── */
.toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999; display: flex; flex-direction: column; gap: .65rem; }
.toast {
    background: #1e2923; color: #fff; padding: .85rem 1.2rem;
    border-radius: var(--radius); box-shadow: var(--shadow-md);
    font-size: .9rem; max-width: 340px;
    display: flex; align-items: center; gap: .75rem;
    animation: toastIn .3s ease forwards;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.warning { background: #c87a00; }
@keyframes toastIn  { from { transform: translateX(110%); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toastOut { to   { transform: translateX(110%); opacity: 0; } }
.toast.leaving { animation: toastOut .3s ease forwards; }

/* ── Modal ───────────────────────────────────────────────────── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 800; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal { background: var(--surface); border-radius: var(--radius-lg); box-shadow: 0 20px 60px rgba(0,0,0,.25); max-width: 560px; width: 100%; max-height: 90vh; overflow-y: auto; }
.modal-header { padding: 1.2rem 1.5rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 1.05rem; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--muted); line-height: 1; padding: .2rem; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 1.5rem; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); display: flex; gap: .75rem; justify-content: flex-end; }

/* ── Spinner ─────────────────────────────────────────────────── */
.spinner { display: inline-block; width: 1.1em; height: 1.1em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .6s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Section title ───────────────────────────────────────────── */
.section-title { text-align: center; margin-bottom: 2rem; }
.section-title h2 { margin-bottom: .4rem; }
.section-title p { color: var(--muted); max-width: 520px; margin: 0 auto; font-size: .95rem; }

/* ── Pagination ──────────────────────────────────────────────── */
.pagination { display: flex; gap: .4rem; justify-content: center; margin-top: 2rem; flex-wrap: wrap; }
.page-btn { padding: .42rem .85rem; border-radius: var(--radius); border: 1.5px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; font-size: .88rem; transition: var(--transition); text-decoration: none; display: inline-block; }
.page-btn:hover, .page-btn.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.page-btn.disabled { opacity: .45; pointer-events: none; }

/* ── Success page ────────────────────────────────────────────── */
.success-wrap { max-width: 580px; margin: 4rem auto; padding: 0 1.25rem; text-align: center; }
.success-icon { font-size: 5rem; margin-bottom: 1.25rem; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 1000px) {
    .checkout-grid { grid-template-columns: 1fr; }
    .order-summary-card { position: static; }
}
@media (max-width: 768px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .grid-4 { grid-template-columns: repeat(2,1fr); }
    .navbar-nav { display: none; flex-direction: column; position: absolute; top: 100%; left: 0; right: 0; background: var(--brand-dk); padding: 1rem 1.25rem; gap: 1rem; z-index: 199; }
    .navbar-nav.open { display: flex; }
    .navbar { position: relative; }
    .navbar-toggle { display: block; }
    h1 { font-size: 1.6rem; }
    .hero h1 { font-size: 1.85rem; }
    .hero { padding: 2.5rem 1.25rem; }
    .auth-card { padding: 1.75rem; }
}
@media (max-width: 480px) {
    .grid-4 { grid-template-columns: 1fr; }
}
