/* ========================================
   RestauPOS Bridge — Design System
   Dark premium theme optimized for touch
   ======================================== */

:root {
    /* Colors */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --bg-card-hover: #334155;
    --bg-elevated: #273548;
    --bg-input: #0f172a;

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-glow: rgba(59, 130, 246, 0.15);

    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.12);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.12);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.12);
    --orange: #f97316;

    --border: #334155;
    --border-light: rgba(255,255,255,0.06);

    /* Spacing */
    --gap-xs: 4px;
    --gap-sm: 8px;
    --gap-md: 16px;
    --gap-lg: 24px;
    --gap-xl: 32px;

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 50%;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);
    --shadow-glow: 0 0 20px var(--accent-glow);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;

    /* Font */
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ========== Reset ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
}

/* ========== Header ========== */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--gap-md);
    height: 56px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 100;
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: var(--gap-sm);
}

.header-title {
    font-size: 1.1rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), #818cf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-user {
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding: 4px 12px;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
}

.header-credit {
    font-size: 0.8rem;
    font-weight: 700;
    color: #fff;
    padding: 4px 10px;
    background: linear-gradient(135deg, #10b981, #059669);
    border-radius: var(--radius-sm);
    white-space: nowrap;
    cursor: default;
}
.header-credit:empty { display: none; }

/* ========== Buttons ========== */
.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}
.btn-icon:hover { background: var(--bg-elevated); color: var(--text-primary); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--gap-sm);
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    touch-action: manipulation;
    min-height: 48px;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #6366f1);
    color: white;
    box-shadow: var(--shadow-glow);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--accent-hover), #4f46e5); }

.btn-success {
    background: linear-gradient(135deg, var(--success), #16a34a);
    color: white;
}

.btn-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(239,68,68,0.2);
}
.btn-danger:hover { background: var(--danger); color: white; }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-elevated); color: var(--text-primary); }

.btn-sm { padding: 8px 16px; font-size: 0.85rem; min-height: 36px; }
.btn-lg { padding: 16px 32px; font-size: 1.1rem; min-height: 56px; }
.btn-block { width: 100%; }

/* ========== Main Content ========== */
#app-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/* ========== Login View ========== */
.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: var(--gap-lg);
    background: radial-gradient(ellipse at 50% 0%, rgba(59,130,246,0.08) 0%, transparent 60%);
}

.login-logo {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: var(--gap-xs);
    background: linear-gradient(135deg, var(--accent), #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: var(--gap-xl);
}

.pin-display {
    display: flex;
    gap: var(--gap-sm);
    margin-bottom: var(--gap-lg);
    height: 56px;
}

.pin-dot {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    border: 2px solid var(--border);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
    transition: all var(--transition-fast);
}
.pin-dot.active {
    border-color: var(--accent);
    box-shadow: var(--shadow-glow);
}
.pin-dot.filled {
    background: var(--accent-glow);
    border-color: var(--accent);
}

.pin-pad {
    display: grid;
    grid-template-columns: repeat(3, 80px);
    gap: var(--gap-sm);
    max-width: 280px;
}

.pin-key {
    width: 80px;
    height: 64px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 1.5rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}
.pin-key:hover { background: var(--bg-elevated); }
.pin-key:active { transform: scale(0.95); background: var(--accent-glow); }
.pin-key.key-clear { font-size: 1rem; color: var(--danger); }
.pin-key.key-enter {
    background: linear-gradient(135deg, var(--accent), #6366f1);
    color: white;
    border: none;
    font-size: 1rem;
}
.pin-key.key-enter:hover { background: linear-gradient(135deg, var(--accent-hover), #4f46e5); }

.login-error {
    margin-top: var(--gap-md);
    color: var(--danger);
    font-size: 0.85rem;
    min-height: 20px;
}

/* ========== Tables View ========== */
.tables-view {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.floor-tabs {
    display: flex;
    gap: var(--gap-xs);
    padding: var(--gap-md);
    overflow-x: auto;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-secondary);
}

.floor-tab {
    padding: 10px 20px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition-fast);
}
.floor-tab:hover { background: var(--bg-elevated); }
.floor-tab.active {
    background: var(--accent);
    color: white;
}

.tables-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--gap-md);
    padding: var(--gap-md);
    flex: 1;
    overflow-y: auto;
    align-content: start;
}

.table-card {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--gap-xs);
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}
.table-card::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity var(--transition-normal);
    border-radius: inherit;
}
.table-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.table-card:active { transform: scale(0.97); }

.table-card.free {
    border-color: rgba(34, 197, 94, 0.3);
}
.table-card.free::before {
    background: linear-gradient(135deg, rgba(34,197,94,0.06), transparent);
    opacity: 1;
}

.table-card.busy {
    border-color: rgba(249, 115, 22, 0.5);
}
.table-card.busy::before {
    background: linear-gradient(135deg, rgba(249,115,22,0.1), transparent);
    opacity: 1;
}

.table-name {
    font-size: 1.3rem;
    font-weight: 700;
    z-index: 1;
}

.table-status {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    z-index: 1;
    padding: 3px 10px;
    border-radius: var(--radius-sm);
}
.table-card.free .table-status { color: var(--success); background: var(--success-bg); }
.table-card.busy .table-status { color: var(--orange); background: var(--warning-bg); }

/* Table occupée par un AUTRE serveur — verrouillée */
.table-card.other-server {
    border-color: rgba(239, 68, 68, 0.4);
    opacity: 0.55;
    cursor: not-allowed;
}
.table-card.other-server::before {
    background: linear-gradient(135deg, rgba(239,68,68,0.08), rgba(0,0,0,0.15));
    opacity: 1;
}
.table-card.other-server:hover {
    transform: none;
    box-shadow: none;
}
.table-card.other-server .table-status {
    color: var(--danger);
    background: var(--danger-bg);
    font-size: 0.65rem;
}
.table-server {
    font-size: 0.65rem;
    color: var(--text-muted);
    z-index: 1;
}

/* ========== Order View ========== */
.order-view {
    display: flex;
    height: 100%;
}

.order-menu {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-right: 1px solid var(--border);
}

/* Top bar with categories + display toggle */
.menu-top-bar {
    display: flex;
    align-items: stretch;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}
.menu-top-bar .category-bar {
    flex: 1;
    border-bottom: none;
}

.btn-display-mode,
.btn-cat-expand {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    min-width: 44px;
    background: var(--bg-elevated);
    border: none;
    border-left: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.2rem;
    transition: all var(--transition-fast);
}
.btn-display-mode:hover,
.btn-cat-expand:hover { background: var(--bg-card-hover); }
.btn-display-mode:active,
.btn-cat-expand:active { transform: scale(0.9); }

/* Bouton "voir toutes les catégories" — utile seulement quand la barre déborde */
.btn-cat-expand { display: none; }
.btn-cat-expand.visible { display: flex; }
.btn-cat-expand .chevron {
    display: inline-block;
    font-size: 0.9rem;
    transition: transform var(--transition-fast);
}
.btn-cat-expand.expanded {
    background: var(--accent);
    color: white;
}
.btn-cat-expand.expanded .chevron { transform: rotate(180deg); }

.category-bar {
    display: flex;
    gap: var(--gap-xs);
    padding: var(--gap-sm) var(--gap-md);
    overflow-x: auto;
    flex-shrink: 0;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-light);
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
}
.category-bar::-webkit-scrollbar,
.subcategory-bar::-webkit-scrollbar { height: 0; display: none; }

/* Mode déplié : toutes les catégories visibles d'un coup, en grille */
.category-bar.expanded,
.subcategory-bar.expanded {
    flex-wrap: wrap;
    overflow-x: visible;
    overflow-y: auto;
    max-height: 40vh;
}

.cat-chip {
    padding: 8px 16px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 20px;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition-fast);
    scroll-snap-align: center;
    flex-shrink: 0;
}
.cat-chip:hover { background: var(--bg-elevated); color: var(--text-primary); }
.cat-chip.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* Subcategory bar */
.subcategory-bar {
    display: flex;
    gap: var(--gap-xs);
    padding: 6px var(--gap-md);
    overflow-x: auto;
    flex-shrink: 0;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border-light);
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
}

.subcat-chip {
    padding: 6px 14px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 16px;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition-fast);
    scroll-snap-align: center;
    flex-shrink: 0;
}
.subcat-chip:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.subcat-chip.active {
    background: #7c3aed;
    color: white;
    border-color: #7c3aed;
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: var(--gap-sm);
    padding: var(--gap-md);
    overflow-y: auto;
    flex: 1;
    align-content: start;
}

.product-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--gap-md) var(--gap-sm);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: center;
    min-height: 100px;
    overflow: hidden;
}
.product-card:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.product-card:active { transform: scale(0.97); }

/* Color mode */
.product-card--color {
    border-color: rgba(255,255,255,0.15);
}
.product-card--color .product-price {
    color: rgba(255,255,255,0.9);
    font-weight: 800;
}
.product-card--color:hover {
    filter: brightness(1.15);
    border-color: rgba(255,255,255,0.4);
}

/* Image mode */
.product-card--image {
    padding-top: 0;
    position: relative;
}
.product-img {
    width: 100%;
    height: 70px;
    object-fit: contain;
    margin-bottom: var(--gap-xs);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.product-name {
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: var(--gap-xs);
    word-break: break-word;
}

.product-price {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent);
}

/* Cart panel */
.order-cart {
    width: 320px;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.cart-header {
    padding: var(--gap-md);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--gap-sm);
}
.cart-count { font-weight: 500; color: var(--text-secondary); font-size: 0.85rem; }
.cart-header-right { display: none; align-items: center; gap: var(--gap-sm); }
.cart-header-total { font-weight: 800; color: var(--accent); font-size: 1.05rem; }
.cart-toggle { font-size: 1.3rem; color: var(--text-secondary); line-height: 1; }

.cart-header h2 {
    font-size: 1rem;
    font-weight: 700;
}

.cart-header .table-indicator {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: var(--gap-sm);
}

.cart-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-style: italic;
}

.cart-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--gap-xs) var(--gap-sm);
    padding: var(--gap-sm) var(--gap-sm);
    border-radius: var(--radius-sm);
    margin-bottom: var(--gap-xs);
    transition: background var(--transition-fast);
}
/* Outils de la ligne (quantite, extra, note, retrait) : a droite sur un grand
   ecran, sur une rangee a part sous le nom quand la place manque. */
.cart-item-tools {
    display: flex;
    align-items: center;
    gap: var(--gap-sm);
    flex-shrink: 0;
    margin-left: auto;
}
/* Ligne d'article : nom, note et prix sur toute la largeur, boutons en
   dessous (le nom n'est plus ecrase par les boutons dans la colonne). */
.cart-item:not(.cart-item-com) .cart-item-info { flex: 1 1 100%; }
.cart-item:not(.cart-item-com) .cart-item-tools { flex: 1 1 100%; justify-content: flex-end; }
@media (min-width: 1000px) {
    .order-cart { width: 360px; }
}
.cart-item-sub {
    float: right;
    color: var(--text-primary);
    font-weight: 700;
    margin-left: var(--gap-sm);
}
.cart-item:hover { background: var(--bg-elevated); }
.cart-item.sent { opacity: 0.5; }

.cart-item-info {
    flex: 1;
    min-width: 0;
}

.cart-item-name {
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.25;
    word-break: break-word;
}

.cart-item-price {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.cart-item-note {
    font-size: 0.78rem;
    color: #f59e0b;
    font-style: italic;
    margin-top: 2px;
    line-height: 1.3;
    word-break: break-word;
    cursor: pointer;
}

.cart-item-note-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.8rem;
    padding: 2px 4px;
    opacity: 0.4;
    transition: opacity var(--transition-fast);
    flex-shrink: 0;
}
.cart-item-note-btn:hover { opacity: 1; }

.cart-item-extra-btn {
    background: none;
    border: 1px solid rgba(251, 191, 36, 0.3);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 2px 6px;
    border-radius: 6px;
    opacity: 0.7;
    transition: all var(--transition-fast);
    flex-shrink: 0;
    background: rgba(251, 191, 36, 0.08);
}
.cart-item-extra-btn:hover {
    opacity: 1;
    background: rgba(251, 191, 36, 0.18);
    border-color: rgba(251, 191, 36, 0.5);
}

.qty-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.qty-btn {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    background: var(--bg-primary);
    color: var(--text-primary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}
.qty-btn:hover { background: var(--accent-glow); border-color: var(--accent); }

.qty-value {
    font-size: 0.85rem;
    font-weight: 700;
    min-width: 24px;
    text-align: center;
}

/* Quantité verrouillée : envoyée en cuisine, boutons +/- masqués */
.qty-sent {
    font-size: 0.85rem;
    font-weight: 700;
    min-width: 60px;
    text-align: center;
    color: var(--success);
    letter-spacing: 0.04em;
}

.cart-item-remove {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all var(--transition-fast);
}
.cart-item-remove:hover { color: var(--danger); background: var(--danger-bg); }

/* Bouton annulation pour article déjà envoyé en cuisine */
.cart-item-remove.sent-remove {
    color: #f59e0b;
    opacity: 0.75;
}
.cart-item-remove.sent-remove:hover {
    color: var(--danger);
    background: var(--danger-bg);
    opacity: 1;
}

/* Section headers for sent vs new items */
.cart-section-header {
    display: flex;
    align-items: center;
    padding: 6px 10px;
    margin-bottom: var(--gap-xs);
    border-radius: var(--radius-sm);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.cart-section-header.sent-header {
    background: rgba(245, 158, 11, 0.10);
    color: #f59e0b;
    border-left: 3px solid rgba(245, 158, 11, 0.5);
}
.cart-section-header.new-header {
    background: rgba(34, 197, 94, 0.10);
    color: var(--success);
    border-left: 3px solid rgba(34, 197, 94, 0.5);
    margin-top: var(--gap-sm);
}

/* New editable items — visually distinct from locked sent items */
.cart-item.new-item {
    border-left: 3px solid rgba(34, 197, 94, 0.4);
    padding-left: calc(var(--gap-sm) - 3px);
}
.cart-item.new-item:hover {
    background: var(--bg-elevated);
    border-left-color: var(--success);
}

/* Ligne verrouillée — envoyée en cuisine, modifications bloquées */
.cart-item.locked {
    background: repeating-linear-gradient(
        135deg,
        transparent,
        transparent 8px,
        rgba(245, 158, 11, 0.04) 8px,
        rgba(245, 158, 11, 0.04) 16px
    );
    border-left: 3px solid rgba(245, 158, 11, 0.5);
    padding-left: calc(var(--gap-sm) - 3px);
    opacity: 0.7;
    pointer-events: none;
    position: relative;
    transition: opacity var(--transition-normal), background var(--transition-normal);
}
.cart-item.locked .cart-item-name {
    color: var(--text-muted);
}
.cart-item.locked .cart-item-price {
    color: var(--text-muted);
}

/* Icône cadenas sur ligne verrouillée */
.cart-item-lock-icon {
    font-size: 0.75rem;
    color: var(--warning);
    opacity: 0.6;
    flex-shrink: 0;
    width: 24px;
    text-align: center;
}

.cart-footer {
    padding: var(--gap-md);
    border-top: 1px solid var(--border);
}

.cart-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--gap-md);
    font-size: 1.1rem;
    font-weight: 700;
}

.cart-total-value {
    color: var(--accent);
    font-size: 1.3rem;
}

.cart-actions {
    display: flex;
    flex-direction: column;
    gap: var(--gap-sm);
}

/* ========== Kitchen View ========== */
.kitchen-view {
    padding: var(--gap-md);
    overflow-y: auto;
    height: 100%;
}

.kitchen-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--gap-md);
}

.kitchen-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--gap-md);
    align-items: start;
}

.kitchen-ticket {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

.kitchen-ticket-header {
    padding: var(--gap-sm) var(--gap-md);
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.kitchen-ticket-table {
    font-weight: 700;
    font-size: 1rem;
}

.kitchen-ticket-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.kitchen-ticket-items {
    padding: var(--gap-sm) var(--gap-md);
}

.kitchen-item {
    padding: 6px 0;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
}
.kitchen-item:last-child { border-bottom: none; }

.kitchen-item-qty {
    font-weight: 700;
    color: var(--accent);
    margin-right: var(--gap-sm);
    min-width: 24px;
}

/* ========== Toast ========== */
#toast-container {
    position: fixed;
    bottom: var(--gap-md);
    left: var(--gap-md);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: 280px;
}

.toast {
    padding: 9px 16px;
    background: rgba(15, 23, 42, 0.92);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    pointer-events: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.toast.success { border-left: 3px solid var(--success); color: var(--success); }
.toast.error   { border-left: 3px solid var(--danger);  color: var(--danger);  }
.toast.info    { border-left: 3px solid var(--accent);  color: var(--text-secondary); }

/* Bouton mode rapide (1 seul bouton, plus grand) */
.btn-rapide {
    background: linear-gradient(135deg, #ea580c, #f97316) !important;
    font-size: 1rem !important;
    font-weight: 700 !important;
    padding: 18px !important;
    letter-spacing: 0.03em;
    box-shadow: 0 4px 16px rgba(249,115,22,0.35);
}
.btn-rapide:hover {
    background: linear-gradient(135deg, #c2410c, #ea580c) !important;
    box-shadow: 0 6px 20px rgba(249,115,22,0.5);
}

/* ========== Animations ========== */
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.fade-in { animation: fadeIn 0.3s ease; }

/* ========== Loading ========== */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--gap-xl);
    color: var(--text-muted);
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ========== Modal ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.modal-overlay.show {
    opacity: 1;
}

.modal-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--gap-lg);
    min-width: 340px;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    transform: scale(0.9);
    transition: transform 0.2s ease;
}
.modal-overlay.show .modal-box {
    transform: scale(1);
}

.modal-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: var(--gap-md);
}

.modal-message {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: var(--gap-lg);
}

.modal-actions {
    display: flex;
    gap: var(--gap-sm);
    justify-content: flex-end;
}

/* ========== Utilities ========== */
.hidden { display: none !important; }

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .order-view {
        flex-direction: column;
    }
    .order-cart {
        width: 100%;
        max-height: 45vh;
        border-right: none;
        border-top: 1px solid var(--border);
        transition: max-height 0.2s ease;
    }
    .cart-header { cursor: pointer; padding: var(--gap-sm) var(--gap-md); }
    .cart-header-right { display: flex; }
    /* Deplie : le panier prend tout l'ecran, les articles restent accessibles
       en repliant (fleche ou appui sur l'en-tete) */
    .order-cart.cart-open { max-height: calc(100vh - 56px); }
    .order-view.cart-open .order-menu { display: none; }
    /* Boutons de ligne assez grands pour le pouce, sur leur propre rangee */
    .cart-item { padding: var(--gap-sm) var(--gap-sm) var(--gap-xs); }
    .cart-item-info { flex: 1 1 100%; }
    .cart-item-tools { flex: 1 1 100%; margin-left: 0; justify-content: flex-end; gap: 10px; }
    .cart-item-com .cart-item-tools { flex: 0 0 auto; }
    .cart-item-com .cart-item-info { flex: 1 1 auto; }
    .qty-btn { width: 40px; height: 36px; font-size: 1.15rem; }
    .qty-value { font-size: 1rem; min-width: 28px; }
    .cart-item-note-btn, .cart-item-extra-btn { font-size: 1.05rem; padding: 6px 10px; opacity: 0.9; min-height: 36px; }
    .cart-item-remove { width: 36px; height: 36px; font-size: 1.3rem; }
    .cart-item-name { font-size: 0.95rem; }
    .cart-item-note { font-size: 0.85rem; }
    .cart-item-price { font-size: 0.85rem; }
    .cart-footer { padding: var(--gap-sm) var(--gap-md); }
    .cart-total { margin-bottom: var(--gap-sm); }
    .cart-actions { flex-direction: row; flex-wrap: wrap; }
    .cart-actions .btn { flex: 1 1 45%; min-height: 48px; padding: 10px 12px; }
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
    /* Catégories : cibles tactiles plus larges, moins de place perdue autour */
    .category-bar {
        padding: 6px var(--gap-sm);
    }
    .cat-chip {
        padding: 10px 14px;
        font-size: 0.85rem;
        min-height: 40px;
    }
    .subcategory-bar {
        padding: 5px var(--gap-sm);
    }
    .subcat-chip {
        padding: 8px 12px;
        font-size: 0.8rem;
        min-height: 34px;
    }
    /* Déplié : chaque puce prend une demi-largeur → grille lisible au pouce */
    .category-bar.expanded .cat-chip {
        flex: 1 1 calc(50% - var(--gap-xs));
        justify-content: center;
        text-align: center;
        white-space: normal;
    }
    .subcategory-bar.expanded .subcat-chip {
        flex: 1 1 calc(33.333% - var(--gap-xs));
        text-align: center;
        white-space: normal;
    }
    .tables-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    }
    .pin-pad {
        grid-template-columns: repeat(3, 72px);
    }
    .pin-key {
        width: 72px;
        height: 58px;
    }
    .kitchen-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .tables-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: var(--gap-sm);
    }
    .products-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }
    .product-card {
        padding: var(--gap-sm);
        min-height: 80px;
    }
    .product-name { font-size: 0.7rem; }
    .product-price { font-size: 0.75rem; }
}

/* ========== Extras Modal ========== */
.extras-modal-box {
    max-width: 520px;
    width: 92vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.extras-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: var(--gap-sm);
    padding: var(--gap-sm) 0;
    overflow-y: auto;
    flex: 1;
    max-height: 55vh;
}

.extra-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--gap-sm);
    background: var(--bg-primary);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: center;
    position: relative;
    min-height: 100px;
}
.extra-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.extra-card:active { transform: scale(0.95); }

.extra-card.extra-applied {
    border-color: var(--success);
    background: rgba(34, 197, 94, 0.08);
    box-shadow: 0 0 12px rgba(34, 197, 94, 0.15);
}

/* Composition fast-food : etape a nombre de choix limite (CATEGORIES.MAXCHOICES).
   Une fois le maximum atteint, les cartes non retenues passent en grise. */
.extra-card.extra-disabled {
    opacity: 0.4;
    pointer-events: none;
    filter: grayscale(0.8);
}

/* Composition d'un article, affichee AU-DESSUS de son nom dans la carte panier.
   Les complements n'ont plus de ligne propre : ils sont replies ici. */
.cart-item-compo {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--accent);
    line-height: 1.25;
    margin-bottom: 2px;
    word-break: break-word;
}
body.compact .cart-item-compo { font-size: 0.68rem; }

.compo-counter {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--gap-sm);
}
.compo-counter.compo-counter-full { color: var(--success); }
/* Choix obligatoire : Valider reste grise tant que rien n'est choisi */
#composition-modal #compo-ok:disabled { opacity: .4; cursor: not-allowed; }

.extra-img {
    width: 50px;
    height: 50px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    margin-bottom: var(--gap-xs);
}

.extra-img-placeholder {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    margin-bottom: var(--gap-xs);
}

.extra-name {
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.3;
    word-break: break-word;
    color: var(--text-primary);
}

.extra-price {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--accent);
    margin-top: 2px;
}

.extra-check {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    background: var(--success);
    color: white;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 800;
    box-shadow: 0 2px 6px rgba(34, 197, 94, 0.3);
}

/* ========== Mode compact (petit ecran) ==========
   Active par la case "Interface compacte" de l'onglet Bridge/Tablette du POS
   (propriete bridge.ui.compact) : le JS pose la classe "compact" sur <body>.
   Densifie toute l'interface pour les telephones, quelle que soit la
   resolution detectee par les media queries. */
body.compact .products-grid {
    grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
    gap: 5px;
    padding: var(--gap-sm);
}
body.compact .product-card { min-height: 64px; padding: 6px 4px; }
body.compact .product-img { height: 42px; }
body.compact .product-name { font-size: 0.68rem; margin-bottom: 2px; }
body.compact .product-price { font-size: 0.7rem; }

body.compact .cat-chip { padding: 6px 10px; font-size: 0.75rem; min-height: 32px; }
body.compact .subcat-chip { padding: 5px 8px; font-size: 0.72rem; min-height: 28px; }
body.compact .category-bar { padding: 4px var(--gap-xs); }
body.compact .subcategory-bar { padding: 3px var(--gap-xs); }

body.compact .order-cart { width: 240px; }
@media (max-width: 768px) {
    body.compact .order-cart { width: 100%; max-height: 38vh; }
}
body.compact .cart-item { padding: 4px 6px; }
body.compact .cart-item-name { font-size: 0.72rem; }
body.compact .cart-item-price { font-size: 0.7rem; }
body.compact .cart-footer { padding: 6px; }
body.compact .cart-footer .btn { padding: 8px 6px; font-size: 0.75rem; }

body.compact .tables-grid {
    grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
    gap: 6px;
}

body.compact .extras-grid,
body.compact #composition-modal .extras-grid {
    grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
    gap: 5px;
}
body.compact .extra-card { padding: 5px; }
body.compact .extra-name { font-size: 0.68rem; }
body.compact .extra-price { font-size: 0.66rem; }
body.compact .modal-title { font-size: 0.9rem; }

/* Lignes complement (choix de composition) : indentees sous l'article principal */
.cart-item-com { padding-top: 0; padding-bottom: 2px; }
.cart-item-com .cart-item-name {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-secondary, #888);
    padding-left: 14px;
}

/* ========== Notes predefinies (jeu d'attributs de la caisse) ========== */
.notes-modal-box {
    width: 94vw;
    max-width: 560px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    padding: var(--gap-md);
}
.notes-resume {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: var(--gap-sm);
    min-height: 1.3em;
}
.notes-resume-on { color: var(--success); font-weight: 700; }
.notes-filtre {
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 1rem;
    margin-bottom: var(--gap-sm);
}
.notes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
    gap: 6px;
    overflow-y: auto;
    flex: 1;
    min-height: 120px;
    max-height: 48vh;
    padding-bottom: 2px;
    align-content: start;
    grid-auto-rows: min-content;
}
.notes-val {
    min-height: 44px;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    word-break: break-word;
}
.notes-val:active { transform: scale(0.96); }
.notes-val.notes-val-on {
    border-color: var(--success);
    background: var(--success-bg);
    color: var(--success);
}
.notes-libre-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: var(--gap-sm) 0 4px;
}
.notes-libre {
    width: 100%;
    padding: 11px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 1rem;
}
.notes-actions { margin-top: var(--gap-md); }
.notes-actions .btn { min-height: 46px; }
.notes-effacer { color: var(--danger); }
@media (max-width: 480px) {
    .notes-grid { grid-template-columns: repeat(3, 1fr); }
    .notes-actions .btn { flex: 1; padding-left: 6px; padding-right: 6px; }
}

.login-version { margin-top: 18px; font-size: 0.75rem; color: var(--text-muted); text-align: center; }
