/* ================================
   Loky Barista Orders – MOBILE FIRST (V4.4.x - Robust Quantity Input)
   ================================ */

:root {
  --primary-color: #0025ce; /* Nouveau Bleu: #0025ce */
  --primary-soft: #e5e8ff;  /* Couleur douce ajustée */
  --bg-page: #f5f5f5;      /* Light gray background */
  --bg-card: #ffffff;
  --border-soft: #dddddd;
  --text-main: #212529;    /* Dark text */
  --text-muted: #6c757d;    /* Muted gray */
  --danger: #dc3545;       /* Red for delete */
}

/* Base */

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

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}


body {
  margin: 0;
  padding: 0.75rem 0.75rem 4.5rem;
  background: var(--bg-page);
  color: var(--text-main);
  font-family: system-ui, -apple-system, sans-serif;
  width: 100%;
  max-width: 100%;
  margin-inline: 0;
  line-height: 1.5;
}

main,
.app-header {
  max-width: 768px;
  margin-inline: auto;
}

/* Header */

.app-header {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0 1rem;
}

.app-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--primary-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.app-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #0025ce;
}

.app-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Screens */

.screen {
  display: none;
}

.screen.active {
  display: block;
}

.screen-title {
  margin: 0 0 0.2rem;
  font-size: 1.1rem;
  font-weight: 700;
}

.screen-helper {
  margin: 0 0 0.6rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.back-btn {
  padding: 0.5rem 0.8rem;
  border-radius: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  color: var(--text-main);
}

.screen-header-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.8rem;
}

/* Supplier grid */

.supplier-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.8rem;
}

@media (max-width: 420px) {
  .supplier-grid {
    grid-template-columns: 1fr;
  }
}


.supplier-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 15px;
  padding: 1rem;
  cursor: pointer;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  transition: all 0.2s;
}

.supplier-card:hover {
  border-color: var(--primary-color);
  box-shadow: 0 4px 10px var(--primary-soft);
}

.supplier-name {
  font-weight: 700;
  margin-bottom: 0.15rem;
  color: var(--primary-color);
  font-size: 1rem;
}

.supplier-contact {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Product list */

.product-list {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  margin-top: 0.8rem;
}

.product-card {
  background: var(--bg-card);
  border-radius: 12px; 
  border: 1px solid var(--border-soft);
  padding: 1rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.product-main-row {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex-grow: 1; 
}

.product-name {
  font-size: 1rem;
  font-weight: 600;
}

.product-price {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--primary-color);
}

.product-add-btn {
  flex-shrink: 0;
  padding: 0.6rem 1.2rem;
  font-size: 0.9rem;
  max-width: 120px;
}


/* Floating cart BAR */

.cart-bar {
  position: fixed;
  bottom: 0.75rem;
  left: 0;
  right: 0;
  margin-inline: auto;
  width: calc(100% - 1.5rem); 
  max-width: 480px;      
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 12px; 
  padding: 0.5rem 0.6rem 0.5rem 1.2rem; 
  font-weight: 700;
  box-shadow: 0 6px 18px #0025ce50; 
  display: none; /* Controlled by JS */
  z-index: 50;
  
  /* Flex container */
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: default; 
}

.cart-bar-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
}

.cart-bar-count {
  background: white;
  color: var(--primary-color);
  padding: 0.1rem 0.6rem;
  border-radius: 10px;
  font-weight: 800;
  font-size: 0.8rem;
}

/* View Order button */
#viewCartButton {
    background: white;
    color: var(--primary-color);
    font-weight: 700;
    padding: 0.5rem 1rem;
    border-radius: 8px; 
    font-size: 0.9rem;
    flex-shrink: 0;
}


/* Cart list */

.cart-list {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  margin-top: 1rem;
}

.cart-item {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  padding: 1rem;
  border-radius: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Bloc d'information (nom, prix unitaire, note, total) */
.cart-item-info {
    flex-grow: 1;
    margin-right: 1rem;
}

.cart-item-name {
  font-weight: 700;
  font-size: 1rem;
}

.cart-item-price {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.cart-item-note {
  font-size: 0.8rem;
  color: var(--text-main);
  margin-top: 0.5rem;
  padding-left: 0.5rem;
  border-left: 3px solid var(--primary-soft);
}

.cart-item-total {
  font-weight: 700;
  color: var(--primary-color);
  margin-top: 0.5rem;
  font-size: 1.1rem;
}

/* Bloc actions (quantité + delete) */
.cart-item-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
}

.delete-btn {
  padding: 0.4rem 0.55rem;
  border-radius: 10px; 
  border: none;
  background: var(--danger);
  color: white;
  margin-left: 0; 
  width: 100%; 
  height: auto; 
  font-size: 0.9rem;
  font-weight: 600;
}

/* Supplier summary in cart */

.cart-supplier-summary {
  margin-top: 0.5rem;
  padding: 1rem;
  border-radius: 12px;
  background: var(--primary-soft);
  border: 1px solid var(--border-soft);
  font-size: 1.0rem;
}

.cart-supplier-name {
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.cart-supplier-line,
.cart-supplier-comment {
  color: var(--text-main);
  font-size: 0.85rem;
}

/* Delivery Date Block */
.delivery-date-block {
    margin-top: 0.5rem;
    padding: 1rem;
    border-radius: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.delivery-date-block label {
    font-weight: 600;
    font-size: 0.9rem;
}

.date-input {
    padding: 0.6rem;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    font-size: 1rem;
    color: var(--primary-color);
    font-weight: 700;
    background: var(--bg-page);
    cursor: pointer;
}

/* Cart total */

.cart-total-row {
  margin-top: 1.5rem;
  display: flex;
  justify-content: space-between;
  font-size: 1.1rem;
  font-weight: 700;
  border-top: 2px solid var(--border-soft);
  padding-top: 0.8rem;
}

/* Order text */

.order-text-block h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.2rem;
    margin-top: 1.5rem;
}

.button-row {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.7rem;
}

textarea#orderText {
  width: 100%;
  resize: vertical;
  overflow-y: auto; 
  min-height: 200px;
  padding: 0.8rem;
  border-radius: 8px;
  font-size: 0.85rem;
  border: 1px solid var(--border-soft);
  font-family: monospace; 
  background: var(--bg-page);
  margin-top: 0.8rem;
}


/* Buttons */

button {
  font-size: 0.9rem;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.2s, opacity 0.2s;
}

button.primary {
  background: var(--primary-color);
  color: white;
}

button.secondary {
  background: var(--border-soft);
  color: var(--text-main);
}

button.fullwidth {
  flex-grow: 1; 
}

button[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Quantity Control (General Style) - Updated */

.qty-control {
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
  padding: 0;
  gap: 0.15rem;
  border: 1px solid var(--border-soft); /* Ajout d'une bordure sur le conteneur */
}

.qty-btn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: none;
  background: transparent;
  font-size: 1.1rem;
  font-weight: 600;
  padding: 0;
  color: var(--primary-color);
}

.qty-btn.secondary {
    background: transparent;
}

/* NOUVEAU: Style pour le champ de saisie de quantité */
.qty-input {
    width: 40px; 
    text-align: center;
    font-weight: 600;
    font-size: 1rem;
    padding: 0;
    margin: 0;
    border: none; 
    background: transparent;
    height: 32px;
    
    /* ESSENTIEL pour l'ergonomie mobile: empêcher le zoom */
    touch-action: manipulation;
}

/* Règle pour masquer les flèches incrémentation/décrémentation par défaut sur Chrome/Safari/Edge */
.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Règle pour masquer les flèches incrémentation/décrémentation par défaut sur Firefox */
.qty-input[type=number] {
    -moz-appearance: textfield;
}

/* Status */

.status {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.status.ok {
  color: #16a34a;
}

.status.error {
  color: var(--danger);
}


/* ================================
   MODAL STYLES (Updated for input)
   ================================ */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.4);
  display: none;
  align-items: flex-end; 
  z-index: 100;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: var(--bg-card);
  width: 100%;
  max-width: 450px; 
  margin-inline: auto;
  padding: 1rem;
  border-top-left-radius: 15px;
  border-top-right-radius: 15px;
  animation: slideInUp 0.3s ease-out;
}

@media (min-width: 600px) {
  .modal-overlay {
    align-items: center; 
    justify-content: center;
  }
  .modal-content {
    border-radius: 15px;
    animation: fadeIn 0.3s ease-out;
  }
}

@keyframes slideInUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}


.modal-content h3 {
    margin: 0 0 0.8rem;
    font-size: 1.1rem;
    font-weight: 700;
}

.modal-control-row {
    margin-bottom: 0.8rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-control-row label {
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.3rem;
    display: block;
    color: var(--text-main);
}

/* Mise à jour du style pour l'input dans la modale */
#qtyNoteModal .qty-input {
    width: 60px; 
    font-size: 1.1rem;
}


/* Specific adjustment for note field structure */
#modalNoteField {
    flex-direction: column;
    align-items: flex-start;
    display: flex; 
}
#modalNoteField textarea {
    width: 100%;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    padding: 0.6rem;
    font-size: 0.9rem;
    resize: vertical;
    min-height: 80px;
    background: var(--bg-page);
}


.modal-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-soft);
    padding-top: 0.8rem;
    margin-top: 1rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-color);
}

.modal-action-row {
    display: flex;
    gap: 0.6rem;
    margin-top: 1rem;
}