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

:root {
    --green:       #2d7a2d;
    --green-light: #e8f5e8;
    --green-dark:  #1e5c1e;
    --accent:      #f4a024;
    --text:        #222;
    --muted:       #666;
    --border:      #ddd;
    --radius:      8px;
    --shadow:      0 2px 8px rgba(0,0,0,.08);
}

html { overflow-x: hidden; }        /* on html (not body) so position:sticky keeps working */

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: #f5f7f5;
    color: var(--text);
    min-height: 100vh;
}

a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navbar ────────────────────────────────────────────────── */
.navbar {
    background: var(--green);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    height: 60px;
    box-shadow: 0 2px 6px rgba(0,0,0,.15);
}

.navbar .brand {
    font-size: 1.4rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: .5px;
}

.navbar nav a {
    color: rgba(255,255,255,.85);
    margin-left: 1.4rem;
    font-size: .95rem;
    transition: color .2s;
}
.navbar nav a:hover,
.navbar nav a.active { color: #fff; text-decoration: none; }

.navbar nav a.btn-logout {
    background: rgba(255,255,255,.15);
    padding: .3rem .8rem;
    border-radius: 20px;
}
.navbar nav a.btn-logout:hover { background: rgba(255,255,255,.25); }

/* ── Layout ────────────────────────────────────────────────── */
.container {
    max-width: 960px;
    margin: 2rem auto;
    padding: 0 1rem;
}

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

/* ── Card ──────────────────────────────────────────────────── */
.card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
}

.card h2 {
    color: var(--green-dark);
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
}

/* ── Forms ─────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 1.1rem;
}

.form-group label {
    display: block;
    font-size: .875rem;
    font-weight: 600;
    margin-bottom: .35rem;
    color: var(--muted);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: .55rem .85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .95rem;
    transition: border-color .2s, box-shadow .2s;
    background: #fff;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(45,122,45,.12);
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
    display: inline-block;
    padding: .6rem 1.4rem;
    border-radius: var(--radius);
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background .2s, transform .1s;
}
.btn:active { transform: scale(.98); }

.btn-primary {
    background: var(--green);
    color: #fff;
}
.btn-primary:hover { background: var(--green-dark); color: #fff; text-decoration: none; }

.btn-secondary {
    background: #fff;
    color: var(--green);
    border: 1.5px solid var(--green);
}
.btn-secondary:hover { background: var(--green-light); text-decoration: none; }

.btn-accent {
    background: var(--accent);
    color: #fff;
}
.btn-accent:hover { background: #d8891e; color: #fff; text-decoration: none; }

.btn-danger {
    background: #d9534f;
    color: #fff;
}
.btn-danger:hover { background: #b94040; text-decoration: none; color: #fff; }

.btn-sm { padding: .35rem .9rem; font-size: .85rem; }

/* ── Alerts ────────────────────────────────────────────────── */
.alert {
    padding: .8rem 1.1rem;
    border-radius: var(--radius);
    margin-bottom: 1.2rem;
    font-size: .92rem;
}
.alert-error   { background: #fdecea; color: #b00020; border-left: 4px solid #d9534f; }
.alert-success { background: #e8f5e8; color: #1e5c1e; border-left: 4px solid var(--green); }
.alert-info    { background: #e8f0fe; color: #174ea6; border-left: 4px solid #4285f4; }

.product-card.has-error { border: 2px solid #d9534f; box-shadow: 0 0 0 2px rgba(217, 83, 79, .15); }
.product-card.has-error input[type="number"] { border-color: #d9534f; }

/* ── Login page ────────────────────────────────────────────── */
.login-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--green-light) 0%, #fff 100%);
}

.login-box {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 4px 24px rgba(0,0,0,.10);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 380px;
}

.login-box .logo {
    text-align: center;
    margin-bottom: 1.8rem;
}

.login-box .logo h1 {
    color: var(--green);
    font-size: 2rem;
}

.login-box .logo p {
    color: var(--muted);
    font-size: .9rem;
    margin-top: .3rem;
}

/* ── Order toolbar (sticky search + category nav) ──────────── */
.order-toolbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: #fff;
    margin: -2rem -2rem 1rem;              /* counter .card padding, span full width */
    padding: 1rem 2rem .7rem;
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
}
.order-toolbar .search-bar { margin-bottom: .6rem; }

/* ── Category quick-nav ────────────────────────────────────── */
.category-nav {
    display: flex;
    gap: .4rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: .1rem;
}
.category-nav::-webkit-scrollbar { display: none; }
.cat-chip {
    flex: 0 0 auto;
    padding: .3rem .8rem;
    border-radius: 16px;
    background: var(--green-light);
    color: var(--green-dark);
    font-size: .82rem;
    font-weight: 600;
    white-space: nowrap;
    transition: background .15s, color .15s;
}
.cat-chip:hover,
.cat-chip.active {
    background: var(--green);
    color: #fff;
    text-decoration: none;
}

/* ── Scroll-to-bottom button ───────────────────────────────── */
.fab-scroll {
    position: fixed;
    bottom: 1.2rem;
    right: 1.2rem;
    z-index: 30;                           /* above content, below modal (1000) */
    width: 46px;
    height: 46px;
    border: none;
    border-radius: 50%;
    background: var(--green);
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(0,0,0,.25);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity .2s, transform .2s, visibility .2s, background .15s;
}
.fab-scroll::before {                      /* downward chevron ("v") drawn from borders */
    content: "";
    width: 13px;
    height: 13px;
    margin-top: -5px;
    border-right: 2.5px solid #fff;
    border-bottom: 2.5px solid #fff;
    transform: rotate(45deg);
}
.fab-scroll.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.fab-scroll:hover { background: var(--green-dark); }

/* ── Search bar ────────────────────────────────────────────── */
.search-bar {
    width: 100%;
    padding: .6rem 1rem .6rem 2.4rem;
    border: 1.5px solid var(--border);
    border-radius: 24px;
    font-size: .95rem;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") no-repeat .7rem center;
    transition: border-color .2s, box-shadow .2s;
    margin-bottom: 1.2rem;
}
.search-bar:focus {
    outline: none;
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(45,122,45,.12);
}

/* ── Product grid ──────────────────────────────────────────── */
.section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--green-dark);
    text-transform: uppercase;
    letter-spacing: .8px;
    margin: 1.5rem 0 .8rem;
    padding-bottom: .3rem;
    border-bottom: 2px solid var(--green-light);
    scroll-margin-top: 120px;              /* land below the sticky toolbar on anchor jump */
}

/* ── Product list ──────────────────────────────────────────── */
.product-grid {
    display: flex;
    flex-direction: column;
    gap: .4rem;
    margin-bottom: 1.5rem;
}

.product-card {
    display: flex;
    align-items: center;
    gap: .6rem;
    background: #fff;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: .5rem .7rem;
    transition: border-color .2s, box-shadow .2s;
}
.product-card:hover { border-color: var(--green); box-shadow: var(--shadow); }
.product-card.has-value { border-color: var(--green); background: var(--green-light); }

.btn-fav {
    flex: 0 0 auto;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--border);
    padding: 0;
    line-height: 1;
    transition: color .15s, transform .15s;
}
.btn-fav:hover { transform: scale(1.25); color: var(--accent); }
.btn-fav[data-favorite="1"] { color: var(--accent); }

.product-card.is-favorite { border-color: var(--accent); }

.product-card .product-name {
    flex: 1;
    min-width: 0;
    font-weight: 600;
    font-size: .95rem;
}

.product-card .qty-row {
    flex: 0 0 auto;
    display: flex;
    gap: .4rem;
    align-items: center;
}

.product-card input[type=number] {
    width: 64px;
    padding: .35rem .5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .9rem;
    text-align: center;
}

.product-card select {
    flex: 0 0 84px;                        /* fixed unit-box width so rows align */
    width: 84px;
    padding: .35rem .4rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .9rem;
}

/* single-unit label: match the select's fixed size so it lines up with dropdown rows */
.product-card .qty-row > span {
    flex: 0 0 84px !important;
    width: 84px;
    text-align: center;
}

/* ── Table ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .92rem;
}

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

td {
    padding: .65rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--green-light); }

/* ── Badges ────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: .2rem .65rem;
    border-radius: 20px;
    font-size: .78rem;
    font-weight: 600;
    text-transform: capitalize;
}
.badge-pending   { background: #fff3cd; color: #856404; }
.badge-confirmed { background: #d1ecf1; color: #0c5460; }
.badge-delivered { background: #d4edda; color: #155724; }
.badge-cancelled { background: #f8d7da; color: #721c24; }
.badge-hotel     { background: #e0d4f7; color: #4a1d8a; }
.badge-bar       { background: #fde8c8; color: #7a3e00; }
.badge-person    { background: #d4e8fd; color: #0a3d6b; }
.badge-ristorante { background: #fce4ec; color: #7b1034; }

/* ── Page header ───────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: .8rem;
}
.page-header h1 { font-size: 1.4rem; color: var(--green-dark); }

/* ── Empty state ───────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--muted);
}
.empty-state svg { opacity: .3; margin-bottom: 1rem; }

/* ── Order confirmation modal ──────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0,0,0,.18);
    padding: 2rem;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.modal-body {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}
.modal h2 {
    font-size: 1.2rem;
    color: var(--green-dark);
    margin-bottom: .5rem;
}
.modal-row {
    display: flex;
    justify-content: space-between;
    padding: .35rem 0;
    border-bottom: 1px solid var(--border);
    font-size: .92rem;
}
.modal-row:last-of-type { border-bottom: none; }
.modal-label { color: var(--muted); }
.modal-actions {
    display: flex;
    gap: .75rem;
    margin-top: .75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 600px) {
    .navbar { padding: 0 1rem; }
    .navbar .brand { font-size: 1.1rem; }
    .navbar nav a { margin-left: .8rem; font-size: .85rem; }
    .brand-admin { display: none; }
    .card { padding: 1.2rem; }
    .order-toolbar { margin: -1.2rem -1.2rem 1rem; padding: .8rem 1.2rem .6rem; }

    /* Prevent iOS Safari auto-zoom on input focus (triggers below 16px) */
    input, select, textarea {
        font-size: 16px !important;
    }

    /* Keep rows horizontal on mobile — compact input + unit inline */
    .product-card { gap: .4rem; padding: .5rem; }
    .product-card .qty-row { flex-direction: row; align-items: center; gap: .3rem; }
    .product-card input[type=number] { width: 52px; text-align: center; }
    .product-card select,
    .product-card .qty-row > span { flex-basis: 74px !important; width: 74px; }
}
