/* Brand color palette for Ghithak Market (غذائك ماركت)
 * The palette follows the user’s instruction: green, yellow, black, white and grey.
 * Variables make it easy to tweak colours centrally.
 */
:root {
  --color-primary: #01844b;    /* deep brand green */
  --color-primary-dark: #01673a; /* darker shade for hover */
  --color-accent:  #fecb2d;    /* warm yellow accent */
  --color-dark:    #222222;    /* near black for text */
  --color-light:   #ffffff;    /* pure white for backgrounds */
  --color-muted:   #f5f5f5;    /* light grey for subtle areas */
  --color-warning: #fff3cd;    /* soft yellow for bot bubbles */
  --color-success: #d4edda;    /* pale green for user bubbles */
  --border-radius: 12px;
  --padding-small: 0.5rem;
  --padding-medium: 0.75rem;
  --padding-large: 1rem;
  --font-family: 'Tajawal', sans-serif;
}

/* General body styling: mobile-first layout and a neutral background. */
body {
  font-family: var(--font-family);
  color: var(--color-dark);
  background-color: var(--color-muted);
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

/* Branding header at the top. Hidden on small screens to save space? */
h1 {
  margin: var(--padding-medium) 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--color-primary);
  text-align: center;
}

/* Container for the chat messages and UI. Constrained width for better
 * readability on desktop but fills the screen on mobile. */
#chat-container {
  width: 100%;
  max-width: 480px;
  background-color: var(--color-light);
  border-radius: var(--border-radius);
  box-shadow: 0 4px 8px rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
  /* Leave space for the fixed input bar and header on mobile */
  height: calc(100vh - 200px);
  overflow: hidden;
}

/* Messages area: scrollable column of chat bubbles. Extra bottom padding
 * ensures the last message isn’t hidden by the input bar. */
#messages {
  flex: 1;
  padding: var(--padding-medium);
  padding-bottom: 5rem; /* reserve space for fixed input */
  overflow-y: auto;
  background-color: var(--color-muted);
}

/* Generic message bubble. Extra classes differentiate sender. */
.msg {
  margin: 0.4rem 0;
  padding: var(--padding-small) var(--padding-medium);
  border-radius: var(--border-radius);
  max-width: 85%;
  word-wrap: break-word;
  font-size: 0.9rem;
  line-height: 1.4;
}

/* User messages aligned to the right with green tint. */
.msg.user {
  align-self: flex-end;
  background-color: var(--color-success);
}

/* Bot messages aligned to the left with yellow tint. */
.msg.bot {
  align-self: flex-start;
  background-color: var(--color-warning);
}

/* Suggestions bar: displays quick reply buttons. It scrolls horizontally
 * if the options overflow, preserving vertical space on mobile. */
#suggestions {
  padding: var(--padding-small);
  border-top: 1px solid #ddd;
  background-color: var(--color-light);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

/* Buttons for suggestions and branch selection. Colours emphasise action.
 * Buttons stretch to fill available width on small screens. */
.suggestion-btn {
  flex: 1 1 auto;
  padding: 0.5rem 0.75rem;
  background-color: var(--color-primary);
  color: var(--color-light);
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-size: 0.85rem;
  text-align: center;
  transition: background-color 0.2s ease;
}
.suggestion-btn:hover {
  background-color: var(--color-primary-dark);
}

/* Fixed input bar pinned to bottom of viewport. It sits outside
 * the chat container to remain visible even when the chat scrolls. */
#message-form {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  padding: 0.5rem;
  background-color: var(--color-light);
  border-top: 1px solid #ddd;
  z-index: 100;
}

#message-form input[type="text"] {
  flex: 1;
  padding: 0.6rem;
  border: 1px solid #ccc;
  border-radius: var(--border-radius);
  font-size: 1rem;
  direction: rtl;
}

#message-form button {
  margin-left: 0.5rem;
  padding: 0 1.2rem;
  background-color: var(--color-primary);
  color: var(--color-light);
  border: none;
  border-radius: var(--border-radius);
  font-size: 1rem;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

#message-form button:disabled {
  background-color: #a5d6a7;
  cursor: not-allowed;
}

/* Order confirmation section: show a call-to-action button centrally. */
#confirm-form {
  padding: var(--padding-medium);
  text-align: center;
  background-color: var(--color-light);
}

#confirm-form button {
  padding: 0.6rem 1.5rem;
  background-color: var(--color-primary);
  color: var(--color-light);
  border: none;
  border-radius: var(--border-radius);
  font-size: 1rem;
  cursor: pointer;
}

/* Utility classes for responsive design. */
@media (max-width: 320px) {
  h1 {
    font-size: 1.2rem;
  }
  #message-form input[type="text"] {
    font-size: 0.9rem;
  }
  #message-form button {
    font-size: 0.9rem;
  }
}