/* ------------------------------
   Base styles
------------------------------ */

:root {
    --color-background: #ebe7df;
    --color-surface: #ffffff;
    --color-surface-soft: #f7f4ef;

    --color-text: #211a17;
    --color-text-muted: #706762;
    --color-border: #ded7cf;

    --color-primary: #b84f28;
    --color-primary-dark: #913b1e;

    --color-success: #26734d;
    --color-warning: #b56a13;
    --color-danger: #a53b35;

    --shadow-card:
        0 12px 32px rgba(33, 26, 23, 0.1);

    --radius-small: 10px;
    --radius-medium: 16px;
    --radius-large: 24px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100svh;

    color: var(--color-text);
    background-color: var(--color-background);

    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    font-size: 16px;
    line-height: 1.5;
}

button,
textarea,
input {
    font: inherit;
}

button {
    min-height: 44px;
    padding: 10px 16px;

    color: var(--color-text);
    background-color: var(--color-surface);

    border: 1px solid var(--color-border);
    border-radius: var(--radius-small);

    cursor: pointer;

    transition:
        background-color 160ms ease,
        border-color 160ms ease,
        color 160ms ease,
        transform 160ms ease;
}

button:hover {
    border-color: var(--color-primary);
}

button:active {
    transform: scale(0.98);
}

button:focus-visible,
textarea:focus-visible,
input:focus-visible {
    outline: 3px solid rgba(184, 79, 40, 0.25);
    outline-offset: 2px;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1,
h2,
h3 {
    font-family:
        Georgia,
        "Times New Roman",
        serif;

    line-height: 1.15;
}

[hidden] {
    display: none !important;
}


/* ------------------------------
   Page containers
------------------------------ */

.customer-app,
.staff-app,
#staff-login {
    width: 100%;
    min-height: 100svh;
    margin-inline: auto;
    padding: 20px;

    background-color: var(--color-surface);
}

.customer-app,
#staff-login {
    max-width: 720px;
}

.staff-app {
    max-width: 1100px;
}

@media (min-width: 768px) {
    body {
        padding: 32px;
    }

    .customer-app,
    .staff-app,
    #staff-login {
        min-height: calc(100svh - 64px);
        padding: 32px;

        border-radius: var(--radius-large);
        box-shadow: var(--shadow-card);
    }
}

/* ------------------------------
   Customer header
------------------------------ */

.customer-header {
    padding-bottom: 24px;
    border-bottom: 1px solid var(--color-border);
}

.header-label {
    margin-bottom: 6px;

    color: var(--color-primary);

    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.customer-header h1 {
    margin-bottom: 18px;

    font-size: clamp(2rem, 8vw, 3.25rem);
}

.table-info {
    display: inline-flex;
    align-items: center;
    gap: 8px;

    margin-bottom: 0;
    padding: 8px 14px;

    color: var(--color-text-muted);
    background-color: var(--color-surface-soft);

    border: 1px solid var(--color-border);
    border-radius: 999px;

    font-weight: 600;
}

.table-info span {
    color: var(--color-text);
    font-weight: 800;
}

#view-orders-button {
    display: block;
    margin-top: 14px;

    color: var(--color-primary);
    border-color: var(--color-primary);

    font-weight: 700;
}


/* ------------------------------
   Category navigation
------------------------------ */

.category-navigation {
    display: flex;
    gap: 10px;

    margin: 20px 0 28px;
    padding-bottom: 4px;

    overflow-x: auto;
    scrollbar-width: none;
}

.category-navigation::-webkit-scrollbar {
    display: none;
}

.category-button {
    flex-shrink: 0;

    min-height: 42px;
    padding: 8px 16px;

    color: var(--color-text-muted);
    background-color: var(--color-surface-soft);

    border-radius: 999px;

    font-weight: 700;
    white-space: nowrap;
}

.category-button.active {
    color: #ffffff;
    background-color: var(--color-primary);
    border-color: var(--color-primary);
}

.category-button.active:hover {
    background-color: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
}

/* ------------------------------
   Menu section
------------------------------ */

.menu-section {
    padding-bottom: 110px;
}

.menu-heading {
    margin-bottom: 22px;
}

.menu-heading h2 {
    margin-bottom: 8px;

    font-size: clamp(1.75rem, 6vw, 2.4rem);
}

.menu-heading p {
    margin-bottom: 0;

    color: var(--color-text-muted);
}

.menu-list {
    display: grid;
    gap: 14px;
}

@media (min-width: 600px) {
    .menu-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* ------------------------------
   Menu cards
------------------------------ */

.menu-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 16px;

    padding: 18px;

    background-color: var(--color-surface-soft);

    border: 1px solid var(--color-border);
    border-radius: var(--radius-medium);

    transition:
        border-color 160ms ease,
        box-shadow 160ms ease,
        transform 160ms ease;
}

.menu-card-info {
    min-width: 0;
}

.menu-card h3 {
    margin-bottom: 6px;

    font-size: 1.2rem;
}

.menu-item-description {
    margin-bottom: 12px;

    color: var(--color-text-muted);

    font-size: 0.95rem;
    line-height: 1.45;
}

.menu-item-price {
    margin-bottom: 0;

    color: var(--color-primary);

    font-size: 1.05rem;
    font-weight: 800;
}

.add-item-button {
    min-width: 72px;

    color: #ffffff;
    background-color: var(--color-primary);
    border-color: var(--color-primary);

    font-weight: 800;
}

.add-item-button:hover {
    color: #ffffff;
    background-color: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
}

@media (hover: hover) {
    .menu-card:hover {
        border-color: rgba(184, 79, 40, 0.45);

        box-shadow:
            0 8px 22px rgba(33, 26, 23, 0.08);

        transform: translateY(-2px);
    }
}

@media (max-width: 380px) {
    .menu-card {
        grid-template-columns: 1fr;
    }

    .add-item-button {
        width: 100%;
    }
}

/* ------------------------------
   Cart
------------------------------ */

.cart-panel {
    padding-bottom: 32px;
}

.back-to-menu-button {
    margin-bottom: 24px;

    color: var(--color-primary);
    background-color: transparent;
    border-color: var(--color-primary);

    font-weight: 700;
}

.cart-header {
    margin-bottom: 22px;
    padding-bottom: 18px;

    border-bottom: 1px solid var(--color-border);
}

.cart-header > p {
    margin-bottom: 6px;

    color: var(--color-text-muted);

    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.cart-header h2 {
    margin-bottom: 0;

    font-size: clamp(1.8rem, 7vw, 2.5rem);
}

.cart-items {
    display: grid;
    gap: 14px;

    margin-bottom: 22px;
}

.cart-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px 18px;

    padding: 18px;

    background-color: var(--color-surface-soft);

    border: 1px solid var(--color-border);
    border-radius: var(--radius-medium);
}

.cart-item-info h3 {
    margin-bottom: 5px;

    font-size: 1.15rem;
}

.cart-item-info p {
    margin-bottom: 0;

    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.quantity-controls {
    display: inline-flex;
    align-items: center;
    gap: 8px;

    grid-column: 1;
}

.quantity-button {
    display: inline-grid;
    place-items: center;

    width: 44px;
    min-width: 44px;
    height: 44px;
    padding: 0;

    color: var(--color-primary);
    background-color: var(--color-surface);

    border-color: var(--color-border);
    border-radius: 50%;

    font-size: 1.35rem;
    font-weight: 800;
}

.item-quantity {
    min-width: 28px;

    text-align: center;
    font-weight: 800;
}

.cart-item-total {
    grid-column: 2;
    grid-row: 2;

    color: var(--color-text);

    font-size: 1.05rem;
}

.order-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;

    margin-bottom: 24px;
    padding: 18px;

    color: #ffffff;
    background-color: var(--color-text);

    border-radius: var(--radius-medium);
}

.order-summary span {
    font-weight: 600;
}

.order-summary strong {
    font-size: 1.3rem;
}

.cart-panel label {
    display: block;

    margin-bottom: 8px;

    font-weight: 700;
}

#order-note {
    display: block;

    width: 100%;
    min-height: 100px;
    margin-bottom: 16px;
    padding: 14px;

    color: var(--color-text);
    background-color: var(--color-surface);

    border: 1px solid var(--color-border);
    border-radius: var(--radius-small);

    resize: vertical;
}

#order-note::placeholder {
    color: #9b928d;
}

.place-order-button {
    width: 100%;
    min-height: 52px;

    color: #ffffff;
    background-color: var(--color-primary);
    border-color: var(--color-primary);

    font-weight: 800;
}

.place-order-button:hover {
    color: #ffffff;
    background-color: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
}

/* ------------------------------
   Floating cart button
------------------------------ */

.cart-button {
    position: fixed;
    left: 50%;
    bottom: max(16px, env(safe-area-inset-bottom));
    z-index: 20;

    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 12px;

    width: min(calc(100% - 32px), 680px);
    min-height: 60px;
    padding: 12px 18px;

    color: #ffffff;
    background-color: var(--color-text);

    border: 0;
    border-radius: var(--radius-medium);

    box-shadow:
        0 14px 35px rgba(33, 26, 23, 0.28);

    transform: translateX(-50%);
}

.cart-button:hover {
    color: #ffffff;
    background-color: #352a25;
    border-color: transparent;
}

.cart-button:active {
    transform:
        translateX(-50%)
        scale(0.98);
}

.cart-button span:first-child {
    text-align: left;
    font-weight: 800;
}

#cart-item-count {
    color: #d8d0ca;

    font-size: 0.9rem;
    white-space: nowrap;
}

#cart-total {
    color: #ffffff;

    font-size: 1.05rem;
    font-weight: 800;
    white-space: nowrap;
}

@media (max-width: 380px) {
    .cart-button {
        grid-template-columns: 1fr auto;
    }

    #cart-item-count {
        display: none;
    }
}

/* ------------------------------
   Order confirmation
------------------------------ */

.order-confirmation {
    padding-bottom: 32px;
}

.confirmation-label {
    margin-bottom: 8px;

    color: var(--color-primary);

    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.order-confirmation > h2 {
    margin-bottom: 12px;

    font-size: clamp(2rem, 8vw, 3rem);
}

.order-confirmation > p:not(.confirmation-label) {
    color: var(--color-text-muted);
}

.confirmation-details {
    margin: 28px 0;
}

.confirmation-details > h3 {
    margin-bottom: 14px;

    font-size: 1.35rem;
}

#customer-orders-list {
    display: grid;
    gap: 14px;
}

.customer-order {
    padding: 18px;

    background-color: var(--color-surface-soft);

    border: 1px solid var(--color-border);
    border-radius: var(--radius-medium);
}

.customer-order p {
    margin-bottom: 8px;
}

.customer-order-number {
    color: var(--color-text);

    font-size: 1.05rem;
    font-weight: 800;
}

.customer-order-table {
    color: var(--color-text-muted);
}

.customer-order-status {
    display: inline-flex;

    margin-top: 4px;
    margin-bottom: 0 !important;
    padding: 6px 10px;

    border-radius: 999px;

    font-size: 0.9rem;
    font-weight: 800;
}

.customer-order[data-status="received"]
.customer-order-status {
    color: #27577c;
    background-color: #e4f1fb;
}

.customer-order[data-status="preparing"]
.customer-order-status {
    color: #85500d;
    background-color: #fff0d7;
}

.customer-order[data-status="ready"]
.customer-order-status {
    color: #1f6845;
    background-color: #dff3e9;
}

.customer-order[data-status="served"]
.customer-order-status {
    color: #625b57;
    background-color: #e8e4e1;
}

.remove-customer-order-button {
    display: block;

    margin-top: 14px;

    color: var(--color-danger);
    background-color: transparent;
    border-color: rgba(165, 59, 53, 0.4);

    font-weight: 700;
}

#order-more-button {
    width: 100%;
    min-height: 52px;

    color: #ffffff;
    background-color: var(--color-primary);
    border-color: var(--color-primary);

    font-weight: 800;
}

#order-more-button:hover {
    color: #ffffff;
    background-color: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
}

.browser-reminder {
    padding: 16px;
    margin-block: 24px;

    color: #6f665f;
    background-color: #f7f3ed;
    border: 1px solid #ded5ca;
    border-radius: 14px;

    font-size: 0.95rem;
    line-height: 1.5;
}

.browser-reminder strong {
    display: block;
    margin-bottom: 4px;

    color: #211915;
}

/* ------------------------------
   Staff login
------------------------------ */

#staff-login {
    display: grid;
    align-content: center;

    max-width: 520px;
}

#staff-login h1 {
    margin-bottom: 12px;

    font-size: clamp(2rem, 8vw, 3rem);
}

#staff-login > p {
    margin-bottom: 26px;

    color: var(--color-text-muted);
}

#staff-login-form {
    display: grid;
    gap: 10px;
}

#staff-login-form label {
    margin-top: 8px;

    font-weight: 700;
}

#staff-email,
#staff-password {
    width: 100%;
    min-height: 48px;
    padding: 10px 12px;

    color: var(--color-text);
    background-color: var(--color-surface);

    border: 1px solid var(--color-border);
    border-radius: var(--radius-small);
}

#staff-login-button {
    min-height: 50px;
    margin-top: 12px;

    color: #ffffff;
    background-color: var(--color-primary);
    border-color: var(--color-primary);

    font-weight: 800;
}

#staff-login-error {
    margin-bottom: 0;
    padding: 10px 12px;

    color: var(--color-danger);
    background-color: #fbe9e7;

    border-radius: var(--radius-small);

    font-weight: 700;
}


/* ------------------------------
   Staff header
------------------------------ */

.staff-header {
    display: flex;
    flex-direction: column;
    gap: 14px;

    margin-bottom: 20px;
    padding-bottom: 20px;

    border-bottom: 1px solid var(--color-border);
}

.staff-header h1 {
    margin-bottom: 0;

    font-size: clamp(2rem, 7vw, 3rem);
}

.pending-orders {
    align-self: flex-start;

    padding: 8px 13px;

    color: var(--color-text);
    background-color: var(--color-surface-soft);

    border: 1px solid var(--color-border);
    border-radius: 999px;

    font-weight: 600;
}

#active-order-count {
    color: var(--color-primary);
}

#staff-logout-button {
    align-self: flex-start;

    color: var(--color-danger);
    background-color: transparent;
    border-color: rgba(165, 59, 53, 0.4);

    font-weight: 700;
}

#new-order-alert {
    margin-bottom: 0;
    padding: 12px 14px;

    color: #ffffff;
    background-color: var(--color-success);

    border-radius: var(--radius-small);

    font-weight: 800;
}


/* ------------------------------
   Staff controls
------------------------------ */

.order-view-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;

    margin-bottom: 24px;
}

.order-view-controls button {
    font-weight: 700;
}

#active-orders-button[aria-pressed="true"],
#order-history-button[aria-pressed="true"] {
    color: #ffffff;
    background-color: var(--color-text);
    border-color: var(--color-text);
}

#enable-sound-button:disabled {
    color: var(--color-success);
    background-color: #e4f3eb;
    border-color: #b8deca;

    opacity: 1;
}

#refresh-orders-button {
    color: var(--color-primary);
    border-color: var(--color-primary);
}

@media (min-width: 700px) {
    .staff-header {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto auto;
        align-items: center;
    }

    .staff-header > div:first-child {
        grid-row: 1 / 3;
    }

    .pending-orders {
        align-self: center;
    }

    #staff-logout-button {
        align-self: center;
    }

    #new-order-alert {
        grid-column: 2 / 4;
    }
}

/* ------------------------------
   Staff order cards
------------------------------ */

#empty-orders-message {
    padding: 24px;

    color: var(--color-text-muted);
    background-color: var(--color-surface-soft);

    border: 1px dashed var(--color-border);
    border-radius: var(--radius-medium);

    text-align: center;
}

.orders-list {
    display: grid;
    gap: 16px;
}

.order-card {
    padding: 20px;

    background-color: var(--color-surface);

    border: 1px solid var(--color-border);
    border-left: 5px solid var(--color-border);
    border-radius: var(--radius-medium);

    box-shadow:
        0 8px 24px rgba(33, 26, 23, 0.07);
}

.order-card[data-status="received"] {
    border-left-color: #3977a8;
}

.order-card[data-status="preparing"] {
    border-left-color: var(--color-warning);
}

.order-card[data-status="ready"] {
    border-left-color: var(--color-success);
}

.order-card[data-status="served"] {
    border-left-color: var(--color-text-muted);
}

.order-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;

    margin-bottom: 18px;
}

.order-card-header h2 {
    margin-bottom: 5px;

    font-size: 1.5rem;
}

.order-card-header p {
    margin-bottom: 0;

    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.order-status {
    flex-shrink: 0;

    padding: 6px 10px;

    border-radius: 999px;

    font-size: 0.85rem;
    text-transform: capitalize;
}

.order-card[data-status="received"] .order-status {
    color: #27577c;
    background-color: #e4f1fb;
}

.order-card[data-status="preparing"] .order-status {
    color: #85500d;
    background-color: #fff0d7;
}

.order-card[data-status="ready"] .order-status {
    color: #1f6845;
    background-color: #dff3e9;
}

.order-card[data-status="served"] .order-status {
    color: #625b57;
    background-color: #e8e4e1;
}

.staff-order-items {
    display: grid;
    gap: 10px;

    margin: 0;
    padding: 0;

    list-style: none;
}

.staff-order-items li {
    display: flex;
    justify-content: space-between;
    gap: 16px;

    padding-bottom: 10px;

    border-bottom: 1px solid var(--color-border);
}

.staff-order-total {
    display: flex;
    justify-content: space-between;
    gap: 16px;

    margin: 18px 0 0;

    font-size: 1.05rem;
}

.order-note {
    margin: 16px 0 0;
    padding: 12px;

    color: var(--color-text);
    background-color: #fff4df;

    border-radius: var(--radius-small);
}

.order-actions {
    margin-top: 18px;
}

.update-order-button {
    width: 100%;
    min-height: 48px;

    color: #ffffff;
    background-color: var(--color-primary);
    border-color: var(--color-primary);

    font-weight: 800;
}

.update-order-button:hover {
    color: #ffffff;
    background-color: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
}

.completed-order-label {
    margin-bottom: 0;

    color: var(--color-success);
    font-weight: 800;
}

@media (min-width: 850px) {
    .orders-list {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }
}

/* ------------------------------
   Responsive finishing
------------------------------ */

@media (min-width: 768px) {
    .customer-app,
    .staff-app,
    #staff-login {
        min-height: calc(100svh - 64px);
        padding: 32px;

        border-radius: var(--radius-large);

        box-shadow: var(--shadow-card);
    }
}

@media (max-width: 480px) {
    .customer-app,
    .staff-app,
    #staff-login {
        padding: 18px;
    }

    .order-card-header {
        flex-direction: column;
        gap: 10px;
    }

    .order-status {
        align-self: flex-start;
    }

    .order-view-controls {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .order-view-controls button {
        width: 100%;
    }

    #enable-sound-button,
    #refresh-orders-button {
        grid-column: 1 / -1;
    }
}


/* ------------------------------
   Reduced motion
------------------------------ */

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

/* ------------------------------
   Unavailable menu items
------------------------------ */

.menu-card-unavailable {
    background-color: var(--color-surface-soft);
    border-style: dashed;
}

.menu-card-unavailable .menu-card-info {
    opacity: 0.55;
}

.add-item-button:disabled {
    min-width: 120px;

    color: var(--color-muted);
    background-color: var(--color-border);

    cursor: not-allowed;
    box-shadow: none;
}

.add-item-button:disabled:hover,
.add-item-button:disabled:active {
    background-color: var(--color-border);
    transform: none;
}

/* ------------------------------
   Staff menu management
------------------------------ */

.menu-management {
    margin-top: 24px;

    overflow: hidden;

    background-color: var(--color-surface-soft);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-medium);
}

.menu-management summary {
    padding: 18px 20px;

    font-weight: 800;

    cursor: pointer;
}

.menu-management summary::marker {
    color: var(--color-primary);
}

.menu-management-content {
    padding: 20px;

    border-top: 1px solid var(--color-border);
}

.menu-management-content > p {
    margin-top: 0;
    color: var(--color-muted);
}

.staff-menu-list {
    display: grid;
    gap: 10px;
}

.staff-menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;

    padding: 14px;

    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-small);
}

.staff-menu-item > div {
    display: grid;
    gap: 4px;
}

.availability-status {
    color: var(--color-muted);
    font-size: 0.875rem;
    font-weight: 700;
}

.staff-menu-item[data-available="true"]
.availability-status {
    color: var(--color-success);
}

.staff-menu-item[data-available="false"]
.availability-status {
    color: var(--color-danger);
}

.update-availability-button {
    flex-shrink: 0;

    padding: 10px 14px;

    color: var(--color-primary-dark);
    background-color: transparent;
    border: 1px solid var(--color-primary);
}

@media (max-width: 480px) {
    .staff-menu-item {
        align-items: stretch;
        flex-direction: column;
    }

    .update-availability-button {
        width: 100%;
    }
}