/* Bad Dad Brewery — Wholesale Ordering Portal */

:root {
    --coral: #E86B6B;
    --coral-deep: #D45A5A;
    --coral-light: #F09090;
    --coral-wash: #FDF0F0;
    --ink: #1A1A2E;
    --ink-soft: #3D3D54;
    --muted: #8B8B9E;
    --paper: #FAFAFA;
    --white: #FFFFFF;
    --card: #FFFFFF;
    --line: #EAEAEF;
    --good: #2F7D5B;
    --bad: #B3415E;
    --shadow-sm: 0 1px 2px rgba(26,26,46,.06);
    --shadow-md: 0 2px 8px rgba(26,26,46,.08), 0 1px 2px rgba(26,26,46,.04);
    --shadow-lg: 0 4px 20px rgba(26,26,46,.10), 0 2px 6px rgba(26,26,46,.05);
    --radius: 8px;
    --radius-lg: 12px;
    --header-h: 64px;
    --max-w: 1200px;
}

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

body {
    font-family: "Nunito Sans", "Nunito", -apple-system, BlinkMacSystemFont,
                 "Segoe UI", Roboto, sans-serif;
    color: var(--ink);
    background: var(--paper);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--coral); text-decoration: none; }
a:hover { color: var(--coral-deep); }

/* ── Header ─────────────────────────────────────────────────────────── */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--header-h);
    background: var(--ink);
    display: flex;
    align-items: center;
    padding: 0 24px;
    box-shadow: var(--shadow-md);
}

.site-header .logo img {
    height: 24px;
    width: auto;
}

.site-header nav {
    display: flex;
    align-items: center;
    gap: 24px;
    margin-left: 48px;
}

.site-header nav a {
    color: rgba(255,255,255,.7);
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: .5px;
    transition: color .15s;
}

.site-header nav a:hover,
.site-header nav a.active {
    color: #fff;
}

.header-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 16px;
}

.cart-badge {
    position: relative;
    color: #fff;
    cursor: pointer;
    font-size: 20px;
}

.cart-badge .count {
    position: absolute;
    top: -6px;
    right: -8px;
    background: var(--coral);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

.cart-badge .count:empty { display: none; }

.user-menu {
    color: rgba(255,255,255,.8);
    font-size: 13px;
    cursor: pointer;
}

.user-menu:hover { color: #fff; }

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

.page-title {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 24px;
    color: var(--ink);
}

/* ── Buttons ────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: all .15s;
    text-decoration: none;
}

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

.btn-secondary {
    background: transparent;
    color: var(--ink);
    border: 2px solid var(--line);
}
.btn-secondary:hover { border-color: var(--ink-soft); }

.btn-sm { padding: 6px 14px; font-size: 13px; }

.btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

/* ── Cards ──────────────────────────────────────────────────────────── */
.card {
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--line);
    overflow: hidden;
}

/* ── Forms ──────────────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: var(--ink-soft);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: .3px;
}

.form-group input {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--line);
    border-radius: var(--radius);
    font-size: 15px;
    color: var(--ink);
    background: var(--white);
    transition: border-color .15s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--coral);
}

.form-error {
    color: var(--bad);
    font-size: 13px;
    font-weight: 600;
    margin-top: 8px;
}

/* ── Login page ─────────────────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--ink);
}

.login-card {
    width: 400px;
    max-width: 90vw;
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: var(--shadow-lg);
}

.login-card .login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-card .login-logo img {
    height: 40px;
}

.login-card .login-subtitle {
    text-align: center;
    color: var(--muted);
    font-size: 14px;
    margin-top: 8px;
}

.login-card h2 {
    text-align: center;
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 24px;
}

.login-card .btn-primary {
    width: 100%;
    padding: 12px;
    font-size: 15px;
    margin-top: 8px;
}

/* ── Product grid ───────────────────────────────────────────────────── */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
}

.product-card {
    display: flex;
    flex-direction: column;
}

.product-card .product-img {
    aspect-ratio: 1;
    background: var(--paper);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.product-card .product-img img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.product-card .product-info {
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.product-card .product-name {
    font-weight: 700;
    font-size: 15px;
    margin-bottom: 4px;
}

.product-card .product-uom {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 8px;
}

.product-card .product-price {
    font-weight: 800;
    font-size: 18px;
    color: var(--coral);
    margin-top: auto;
    margin-bottom: 12px;
}

.product-card .add-to-cart-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.product-card .qty-input {
    width: 60px;
    padding: 6px 8px;
    border: 2px solid var(--line);
    border-radius: var(--radius);
    text-align: center;
    font-size: 14px;
    font-weight: 700;
}

/* ── Cart ────────────────────────────────────────────────────────────── */
.cart-table {
    width: 100%;
    border-collapse: collapse;
}

.cart-table th {
    text-align: left;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--muted);
    padding: 12px 16px;
    border-bottom: 2px solid var(--line);
}

.cart-table td {
    padding: 16px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

.cart-table .item-name {
    font-weight: 700;
}

.cart-table .item-uom {
    color: var(--muted);
    font-size: 13px;
}

.cart-summary {
    display: flex;
    justify-content: flex-end;
    padding: 24px 0;
    gap: 32px;
    align-items: center;
}

.cart-total {
    font-size: 20px;
    font-weight: 800;
}

/* ── Orders ──────────────────────────────────────────────────────────── */
.orders-table {
    width: 100%;
    border-collapse: collapse;
}

.orders-table th {
    text-align: left;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--muted);
    padding: 12px 16px;
    border-bottom: 2px solid var(--line);
}

.orders-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
}

.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.status-badge.submitted { background: #E8F5E9; color: var(--good); }
.status-badge.locked    { background: #FFF3E0; color: #E67E22; }
.status-badge.cancelled { background: #FFEBEE; color: var(--bad); }
.status-badge.error     { background: #FFEBEE; color: var(--bad); }

/* ── Delivery week picker ────────────────────────────────────────────── */
.week-picker {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin: 20px 0;
}

.week-option {
    padding: 16px 24px;
    border: 2px solid var(--line);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all .15s;
    text-align: center;
}

.week-option:hover { border-color: var(--coral-light); }
.week-option.selected {
    border-color: var(--coral);
    background: var(--coral-wash);
}

.week-option .week-label {
    font-weight: 700;
    font-size: 15px;
}

.week-option .week-cutoff {
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
}

/* ── Empty states ────────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
}

.empty-state .empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.empty-state h3 {
    font-size: 18px;
    color: var(--ink-soft);
    margin-bottom: 8px;
}

/* ── Toast notifications ─────────────────────────────────────────────── */
.toast-container {
    position: fixed;
    top: 80px;
    right: 24px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    animation: toast-in .3s ease;
    max-width: 360px;
}

.toast.success { background: var(--good); color: #fff; }
.toast.error   { background: var(--bad); color: #fff; }
.toast.info    { background: var(--ink); color: #fff; }

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

/* ── Loading spinner ─────────────────────────────────────────────────── */
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--line);
    border-top-color: var(--coral);
    border-radius: 50%;
    animation: spin .6s linear infinite;
    margin: 40px auto;
}

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

/* ── Table scroll wrapper ───────────────────────────────────────────── */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .site-header { padding: 0 12px; }
    .site-header nav { gap: 12px; margin-left: 16px; }
    .site-header nav a { font-size: 11px; }
    .container { padding: 16px; }
    .product-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
    .page-title { font-size: 22px; }

    .cart-summary { flex-direction: column; align-items: flex-end; gap: 16px; }
    .week-picker { flex-direction: column; }
    .week-option { text-align: left; }

    .cart-table th, .cart-table td,
    .orders-table th, .orders-table td { padding: 10px 8px; font-size: 13px; }

    .user-menu { font-size: 12px; max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

@media (max-width: 480px) {
    .site-header .logo img { height: 20px; }
    .site-header nav { gap: 8px; margin-left: 10px; }
    .site-header nav a { font-size: 10px; letter-spacing: 0; }
    .header-right { gap: 10px; }
    .product-grid { grid-template-columns: 1fr 1fr; }
    .container { padding: 12px; }
    .page-title { font-size: 20px; }
}
