/* ========================================
GLOBAL
======================================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary-color: #111827;
  --secondary-color: #6b7280;
  --background-color: #f8fafc;
  --surface-color: #ffffff;
  --border-color: #e5e7eb;
  --text-color: #1f2937;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;

  display: flex;
  flex-direction: column;

  font-family: Arial, sans-serif;
  background-color: var(--background-color);
  color: var(--text-color);
  line-height: 1.5;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

/* ========================================
HEADER
======================================== */

header {
  background-color: var(--surface-color);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

header nav {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 1.5rem;

  display: flex;
  align-items: center;
  gap: 2rem;
}

header nav > a {
  order: 1;

  color: var(--primary-color);
  font-size: 1.25rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

header nav > a:hover {
  color: #374151;
}

/* ========================================
DESKTOP MENU STRUCTURE
======================================== */

#mobile-menu {
  display: contents;
}

/* ========================================
SEARCH
======================================== */

#product-search {
  order: 2;

  flex: 1;

  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#product-search label {
  position: absolute;

  width: 1px;
  height: 1px;

  padding: 0;
  margin: -1px;

  overflow: hidden;

  clip: rect(0, 0, 0, 0);

  white-space: nowrap;

  border: 0;
}

#product-search input {
  width: 100%;
  max-width: 500px;

  padding: 0.7rem 0.9rem;

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

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

  outline: none;
}

#product-search input:focus {
  border-color: var(--primary-color);
}

#product-search button {
  padding: 0.7rem 1rem;

  border: none;
  border-radius: 6px;

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

  font-weight: 600;

  transition: background-color 0.2s ease;
}

#product-search button:hover {
  background-color: #374151;
}

/* ========================================
HEADER ACTIONS
======================================== */

#header-actions {
  order: 3;

  display: flex;
  align-items: center;
  gap: 0.75rem;
}

#cart-link {
  color: var(--text-color);
  text-decoration: none;

  font-size: 0.95rem;
  font-weight: 600;

  transition: color 0.2s ease;
}

#cart-link:hover {
  color: #6b7280;
}

/* ========================================
AUTH NAVIGATION
======================================== */

#auth-navigation {
  order: 4;

  display: flex;
  align-items: center;
  gap: 1.25rem;
}

#auth-navigation a,
#auth-navigation button {
  color: var(--text-color);

  text-decoration: none;

  font-size: 0.95rem;
  font-weight: 600;
}

#auth-navigation a {
  transition: color 0.2s ease;
}

#auth-navigation a:hover,
#auth-navigation button:hover {
  color: #6b7280;
}

#auth-navigation button {
  padding: 0;

  border: none;
  background: none;
}

/* ========================================
MENU BUTTON
======================================== */

#menu-toggle {
  display: none;

  min-width: 42px;
  min-height: 42px;

  padding: 0.5rem;

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

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

  font-size: 1.25rem;
  line-height: 1;

  transition:
    background-color 0.2s ease,
    border-color 0.2s ease;
}

#menu-toggle:hover {
  background-color: #f3f4f6;
  border-color: #9ca3af;
}

/* ========================================
MAIN / CHECKOUT
======================================== */

main {
  max-width: 700px;
  width: 100%;

  margin: 0 auto;
  padding: 3rem 1.5rem;

  flex: 1;
}

main section {
  width: 100%;

  padding: 1.5rem;

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

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

main section h1 {
  margin-bottom: 2rem;

  color: var(--primary-color);
  font-size: 2rem;
  line-height: 1.2;
}

/* ========================================
CHECKOUT FORM
======================================== */

#checkout-form {
  display: flex;
  flex-direction: column;

  gap: 1.5rem;
}

#checkout-form > div {
  display: flex;
  flex-direction: column;

  gap: 0.4rem;
}

#checkout-form label {
  color: var(--text-color);

  font-size: 0.85rem;
  font-weight: 600;
}

#checkout-form input,
#checkout-form textarea {
  width: 100%;
  min-height: 42px;

  padding: 0.65rem 0.75rem;

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

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

  outline: none;
}

#checkout-form textarea {
  min-height: 120px;
  resize: vertical;
}

#checkout-form input:focus,
#checkout-form textarea:focus {
  border-color: var(--primary-color);
}

/* ========================================
VALIDATION ERRORS
======================================== */

#checkout-form p[role="alert"] {
  min-height: 1.25rem;

  color: #dc2626;

  font-size: 0.85rem;
  font-weight: 500;
}

/* ========================================
PLACE ORDER BUTTON
======================================== */

#checkout-form button[type="submit"] {
  width: 100%;
  min-height: 42px;

  padding: 0.65rem 1rem;

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

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

  font-size: 0.9rem;
  font-weight: 600;

  transition:
    background-color 0.2s ease,
    border-color 0.2s ease;
}

#checkout-form button[type="submit"]:hover {
  background-color: #374151;
  border-color: #374151;
}

/* ========================================
CHECKOUT MESSAGE
======================================== */

#checkout-message {
  min-height: 1.25rem;

  margin-top: 1rem;

  color: #dc2626;

  font-size: 0.85rem;
  font-weight: 500;
}

/* ========================================
FOOTER
======================================== */

footer {
  margin-top: 3rem;
  padding: 1.5rem;

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

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

  text-align: center;
}

footer p {
  color: var(--secondary-color);
  font-size: 0.85rem;
}

/* ========================================
RESPONSIVENESS
======================================== */

/* TABLET */

@media (max-width: 1024px) {
  header nav {
    gap: 1.25rem;
  }
}

/* PHONE */

@media (max-width: 768px) {
  header nav {
    flex-wrap: wrap;
    gap: 0;
  }

  /* STORE */

  header nav > a {
    order: 1;
    flex: 1;
  }

  /* MOBILE HEADER ACTIONS */

  #header-actions {
    order: 2;
    gap: 0.5rem;
  }

  #cart-link {
    display: flex;
    align-items: center;

    min-height: 42px;
    padding: 0.5rem 0.7rem;
  }

  /* MENU BUTTON */

  #menu-toggle {
    display: block;
  }

  /*
    IMPORTANT FIX:

    The mobile menu must ALWAYS appear
    BELOW the Store / Cart / Menu row.
  */

  #mobile-menu {
    order: 3;

    display: none;

    flex-basis: 100%;
    width: 100%;

    flex-direction: column;
    align-items: stretch;

    gap: 1rem;

    padding: 1rem 0 0;
  }

  #mobile-menu.menu-open {
    display: flex;
  }

  /* SEARCH */

  #product-search {
    order: initial;

    width: 100%;

    display: flex;
    flex-direction: column;
    align-items: stretch;

    gap: 0.5rem;
  }

  #product-search input {
    max-width: none;
  }

  #product-search button {
    width: 100%;
  }

  /* AUTH NAVIGATION */

  #auth-navigation {
    order: initial;

    display: flex;

    flex-direction: column;
    align-items: stretch;

    gap: 0;

    padding-top: 0.5rem;

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

  #auth-navigation a,
  #auth-navigation button {
    width: 100%;

    padding: 0.85rem 0.5rem;

    text-align: left;
  }

  #auth-navigation a:hover,
  #auth-navigation button:hover {
    background-color: #f3f4f6;
    color: var(--text-color);
  }

  /* CHECKOUT */

  main {
    padding: 2rem 1rem;
  }

  main section {
    padding: 1.5rem;
  }
}

/* SMALL PHONES */

@media (max-width: 600px) {
  main {
    padding: 2rem 1rem;
  }

  main section h1 {
    font-size: 1.7rem;
  }
}

/* ========================================
GLOBAL
======================================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary-color: #111827;
  --secondary-color: #6b7280;
  --background-color: #f8fafc;
  --surface-color: #ffffff;
  --border-color: #e5e7eb;
  --text-color: #1f2937;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;

  display: flex;
  flex-direction: column;

  font-family: Arial, sans-serif;
  background-color: var(--background-color);
  color: var(--text-color);
  line-height: 1.5;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

/* ========================================
HEADER
======================================== */

header {
  background-color: var(--surface-color);
  border-bottom: 1px solid var(--border-color);
}

header nav {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 1.5rem;

  display: flex;
  align-items: center;
  gap: 2rem;
}

header nav > a {
  order: 1;

  color: var(--primary-color);
  font-size: 1.25rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

header nav > a:hover {
  color: #374151;
}

/* ========================================
DESKTOP MENU STRUCTURE
======================================== */

#mobile-menu {
  display: contents;
}

/* ========================================
SEARCH
======================================== */

#product-search {
  order: 2;

  flex: 1;

  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#product-search label {
  position: absolute;

  width: 1px;
  height: 1px;

  padding: 0;
  margin: -1px;

  overflow: hidden;

  clip: rect(0, 0, 0, 0);

  white-space: nowrap;

  border: 0;
}

#product-search input {
  width: 100%;
  max-width: 500px;

  padding: 0.7rem 0.9rem;

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

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

  outline: none;
}

#product-search input:focus {
  border-color: var(--primary-color);
}

#product-search button {
  padding: 0.7rem 1rem;

  border: none;
  border-radius: 6px;

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

  font-weight: 600;

  transition: background-color 0.2s ease;
}

#product-search button:hover {
  background-color: #374151;
}

/* ========================================
HEADER ACTIONS
======================================== */

#header-actions {
  order: 3;

  display: flex;
  align-items: center;
  gap: 0.75rem;
}

#cart-link {
  color: var(--text-color);
  text-decoration: none;

  font-size: 0.95rem;
  font-weight: 600;

  transition: color 0.2s ease;
}

#cart-link:hover {
  color: #6b7280;
}

/* ========================================
AUTH NAVIGATION
======================================== */

#auth-navigation {
  order: 4;

  display: flex;
  align-items: center;
  gap: 1.25rem;
}

#auth-navigation a,
#auth-navigation button {
  color: var(--text-color);

  text-decoration: none;

  font-size: 0.95rem;
  font-weight: 600;
}

#auth-navigation a {
  transition: color 0.2s ease;
}

#auth-navigation a:hover,
#auth-navigation button:hover {
  color: #6b7280;
}

#auth-navigation button {
  padding: 0;

  border: none;
  background: none;
}

/* ========================================
MENU BUTTON
======================================== */

#menu-toggle {
  display: none;

  min-width: 42px;
  min-height: 42px;

  padding: 0.5rem;

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

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

  font-size: 1.25rem;
  line-height: 1;

  transition:
    background-color 0.2s ease,
    border-color 0.2s ease;
}

#menu-toggle:hover {
  background-color: #f3f4f6;
  border-color: #9ca3af;
}

/* ========================================
MAIN / CHECKOUT
======================================== */

main {
  max-width: 700px;
  width: 100%;

  margin: 0 auto;
  padding: 3rem 1.5rem;

  flex: 1;
}

main section {
  width: 100%;

  padding: 1.5rem;

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

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

main section h1 {
  margin-bottom: 2rem;

  color: var(--primary-color);
  font-size: 2rem;
  line-height: 1.2;
}

/* ========================================
CHECKOUT FORM
======================================== */

#checkout-form {
  display: flex;
  flex-direction: column;

  gap: 1.5rem;
}

#checkout-form > div {
  display: flex;
  flex-direction: column;

  gap: 0.4rem;
}

#checkout-form label {
  color: var(--text-color);

  font-size: 0.85rem;
  font-weight: 600;
}

#checkout-form input,
#checkout-form textarea {
  width: 100%;
  min-height: 42px;

  padding: 0.65rem 0.75rem;

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

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

  outline: none;
}

#checkout-form textarea {
  min-height: 120px;
  resize: vertical;
}

#checkout-form input:focus,
#checkout-form textarea:focus {
  border-color: var(--primary-color);
}

/* ========================================
VALIDATION ERRORS
======================================== */

#checkout-form p[role="alert"] {
  min-height: 1.25rem;

  color: #dc2626;

  font-size: 0.85rem;
  font-weight: 500;
}

/* ========================================
PLACE ORDER BUTTON
======================================== */

#checkout-form button[type="submit"] {
  width: 100%;
  min-height: 42px;

  padding: 0.65rem 1rem;

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

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

  font-size: 0.9rem;
  font-weight: 600;

  transition:
    background-color 0.2s ease,
    border-color 0.2s ease;
}

#checkout-form button[type="submit"]:hover {
  background-color: #374151;
  border-color: #374151;
}

/* ========================================
CHECKOUT MESSAGE
======================================== */

#checkout-message {
  min-height: 1.25rem;

  margin-top: 1rem;

  color: #dc2626;

  font-size: 0.85rem;
  font-weight: 500;
}

/* ========================================
FOOTER
======================================== */

footer {
  margin-top: 3rem;
  padding: 1.5rem;

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

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

  text-align: center;
}

footer p {
  color: var(--secondary-color);
  font-size: 0.85rem;
}

/* ========================================
RESPONSIVENESS
======================================== */

/* TABLET */

@media (max-width: 1024px) {
  header nav {
    gap: 1.25rem;
  }
}

/* PHONE */

@media (max-width: 768px) {
  header nav {
    flex-wrap: wrap;
    gap: 0;
  }

  /* STORE */

  header nav > a {
    order: 1;
    flex: 1;
  }

  /* MOBILE HEADER ACTIONS */

  #header-actions {
    order: 2;
    gap: 0.5rem;
  }

  #cart-link {
    display: flex;
    align-items: center;

    min-height: 42px;
    padding: 0.5rem 0.7rem;
  }

  /* MENU BUTTON */

  #menu-toggle {
    display: block;
  }

  /*
    IMPORTANT FIX:

    The mobile menu must ALWAYS appear
    BELOW the Store / Cart / Menu row.
  */

  #mobile-menu {
    order: 3;

    display: none;

    flex-basis: 100%;
    width: 100%;

    flex-direction: column;
    align-items: stretch;

    gap: 1rem;

    padding: 1rem 0 0;
  }

  #mobile-menu.menu-open {
    display: flex;
  }

  /* SEARCH */

  #product-search {
    order: initial;

    width: 100%;

    display: flex;
    flex-direction: column;
    align-items: stretch;

    gap: 0.5rem;
  }

  #product-search input {
    max-width: none;
  }

  #product-search button {
    width: 100%;
  }

  /* AUTH NAVIGATION */

  #auth-navigation {
    order: initial;

    display: flex;

    flex-direction: column;
    align-items: stretch;

    gap: 0;

    padding-top: 0.5rem;

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

  #auth-navigation a,
  #auth-navigation button {
    width: 100%;

    padding: 0.85rem 0.5rem;

    text-align: left;
  }

  #auth-navigation a:hover,
  #auth-navigation button:hover {
    background-color: #f3f4f6;
    color: var(--text-color);
  }

  /* CHECKOUT */

  main {
    padding: 2rem 1rem;
  }

  main section {
    padding: 1.5rem;
  }
}

/* SMALL PHONES */

@media (max-width: 600px) {
  main {
    padding: 2rem 1rem;
  }

  main section h1 {
    font-size: 1.7rem;
  }
}
