/* Global Styles */
body {
  font-family: 'Arial', sans-serif;
  background-color: #f4f4f4;
  margin: 0;
  padding: 0;
  color: #333;
}

header {
  background-color: #ff6347; /* Tomato */
  color: white;
  padding: 15px 20px;
  position: relative; /* For positioning context */
  display: flex;
  flex-wrap: wrap; /* Allow items to wrap */
  justify-content: space-between; /* Default for desktop */
  align-items: center;
}

header h1 {
  margin: 0;
  font-size: 2.2rem;
  /* On desktop, this will be on the left due to #header-actions margin-left: auto */
}

/* --- START: Header Actions (Cart & Auth) --- */
#header-actions {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-left: auto; /* Pushes this block to the right on desktop */
}

/* Cart Info styling */
#cart-info {
    display: flex;
    align-items: center;
    gap: 8px; /* Space between text and button */
    white-space: nowrap; /* Prevent cart text from wrapping too early */
}

#cart-info button#view-cart-btn { /* Specific styling for view cart button */
    background-color: #fff;
    color: #ff6347;
    padding: 8px 12px;
    border: 1px solid #ff6347;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.3s, color 0.3s;
}

#cart-info button#view-cart-btn:hover {
    background-color: #ff6347;
    color: white;
}

/* Authentication Section in Header */
#auth-section {
    position: relative; /* Crucial for positioning the dropdown */
    display: flex;
    align-items: center;
}

.auth-action-button { /* Style for Login Toggle / Logout buttons */
    background-color: #fff;
    color: #ff6347;
    padding: 8px 15px;
    border: 1px solid #ff6347;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: background-color 0.3s, color 0.3s;
    white-space: nowrap;
}

.auth-action-button:hover {
    background-color: #ff6347;
    color: white;
}

#user-greeting {
    background-color: transparent;
    padding: 0;
    color: white;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95em;
}

#user-greeting #logout-btn { /* Logout button specific adjustments if any */
    margin-left: 0; /* Reset any previous margin */
}
#user-greeting span#user-email-display {
  font-weight: bold;
}

/* Login Dropdown (Pop-down form) */
.auth-dropdown {
    display: none; /* Hidden by default */
    position: absolute;
    top: calc(100% + 5px); /* Position below the toggle button with a small gap */
    right: 0;
    background-color: white;
    color: #333;
    border: 1px solid #ddd;
    border-radius: 8px; /* Rounded all corners for a floating panel look */
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
    z-index: 1000; /* High z-index */
    min-width: 300px; /* Slightly wider for more prominent buttons */
    padding: 25px; /* Slightly more padding */ 
}

#login-dropdown #login-form { /* Form specific styling inside dropdown */
    background-color: transparent;
    padding: 0;
    border-radius: 0;
    margin-bottom: 0;
    width: 100%;
    max-width: none;
}

#login-dropdown #login-form h3 {
    color: #333;
    font-size: 1.3rem;
    margin-top: 0;
    margin-bottom: 20px;
    text-align: center;
}

#login-dropdown .form-group label {
    color: #555;
    display: block;
    margin-bottom: 5px;
    font-size: 0.9em;
}

#login-dropdown #login-form input[type="email"],
#login-dropdown #login-form input[type="password"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-sizing: border-box;
    font-size: 0.95rem;
    margin-bottom: 15px; /* More space before buttons */
}
/* Remove bottom margin from last input in a group */
#login-dropdown .form-group:last-of-type input {
    margin-bottom: 0;
}


#login-dropdown .auth-button { /* Primary "Login" button */
    background-color: #ff6347; /* Match main action button color (Tomato) */
    color: white;
    padding: 12px 20px; /* Match other prominent buttons */
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1.1rem; /* Match other prominent buttons */
    transition: background-color 0.3s;
    width: 100%;
    box-sizing: border-box;
    margin-top: 10px; /* Reduced from 15px as inputs have more margin-bottom */
    font-weight: bold; /* Make it feel more primary */
}
#login-dropdown .auth-button:hover {
    background-color: #ff4500; /* Darker Tomato on hover */
}


#login-dropdown .auth-button.secondary { /* "Create Account" button */
    background-color: #6c757d; /* A neutral secondary button color (e.g., grey) */
    color: white;
    /* Keep padding, border-radius, font-size, etc., same as primary for consistency in shape */
    padding: 12px 20px;
    border: none;
    border-radius: 5px;
    font-size: 1.1rem;
    transition: background-color 0.3s;
    width: 100%;
    box-sizing: border-box;
    margin-top: 12px; /* Space above this secondary button */
    font-weight: normal; /* Differentiate from primary */
}

#login-dropdown .auth-button.secondary:hover {
    background-color: #5a6268; /* Darker grey on hover */
}

#login-dropdown .auth-message {
    font-size: 0.9em; /* Slightly larger for better readability */
    margin-top: 15px; /* More space above message if it appears */
    min-height: 1.1em;
    color: #d9534f; /* Error color */
    text-align: center;
}
#login-dropdown .auth-message:not(:empty) { /* Add padding if message exists */
    padding: 8px;
    background-color: rgba(217, 83, 79, 0.1);
    border-radius: 4px;
}
#login-dropdown .auth-message:not(:empty):not([style*="color: green"]) { /* If it's an error */
    color: #d9534f;
    background-color: rgba(217, 83, 79, 0.1);
}
/* You can add a class for success messages if needed */
/* #login-dropdown .auth-message.success { color: green; background-color: rgba(92, 184, 92, 0.1); } */


.auth-divider {
    border: 0;
    height: 1px;
    background-color: #eee;
    margin: 20px 0;
}
.auth-switch-prompt {
    text-align: center;
    font-size: 0.9em;
    color: #666;
    margin-bottom: 8px;
}
/* --- END: Authentication Section Styles --- */


/* Filters Section */
.filters {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 15px;
  margin-top: 20px; /* Will be adjusted for desktop */
  width: 100%; /* Default for mobile, to span header width */
}

.filters select, .filters button#find-near-me-btn {
  padding: 10px;
  font-size: 1rem;
  border-radius: 5px;
  border: 1px solid #ddd;
  background-color: #fff;
  color: #333;
  cursor: pointer;
}

.filters button#find-near-me-btn {
    background-color: #5cb85c;
    color: white;
    border: none;
}
.filters button#find-near-me-btn:hover {
    background-color: #4cae4c;
}


/* Pizza Cards Layout */
.pizza-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 20px;
  padding: 20px;
  max-width: 1200px;
  margin: 20px auto;
}

.pizza-card {
  background-color: #fff;
  padding: 15px;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  text-align: center;
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden; /* Helps if content within card is too big and causing issues */
}

.pizza-card:hover {
  transform: translateY(-5px);
}

.pizza-card img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin-bottom: 10px;
}

.pizza-card h2 {
  font-size: 1.6rem;
  margin: 10px 0;
  color: #333;
}

.pizza-card p {
  color: #555;
  font-size: 0.95rem;
  margin-bottom: 10px;
  flex-grow: 1;
}

.price {
  font-size: 1.4rem;
  color: #ff6347;
  margin-bottom: 15px;
}

button.order-button { /* "Add to Cart" button on pizza cards */
  background-color: #ff6347;
  color: white;
  padding: 10px 20px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 1.1rem;
  transition: background-color 0.3s;
  width: 100%;
  box-sizing: border-box;
}

button.order-button:hover {
  background-color: #ff4500;
}

#main-pizza-list-container-wrapper {
    text-align: center; /* Center the H2 */
    padding-top: 20px; /* Space above the title */
    /* background-color: #some-color; /* Optional background for this whole section */
}

#main-pizza-list-container-wrapper h2 {
    color: #333; /* Or your preferred heading color */
    margin-bottom: 20px; /* Space between title and pizza grid */
    font-size: 2rem; /* Adjust size as needed */
}

/* Popular Pizzas Section */
#popular-pizzas-section {
    text-align: center;
    padding: 20px;
    background-color: #fff8f0; /* A slightly different background */
    margin-bottom: 20px;
}

#popular-pizzas-section h2 {
    color: #ff6347; /* Tomato color */
    margin-bottom: 20px;
}

/* The #popular-pizzas-container will inherit .pizza-container styles for the grid */

/* Modal Styles (Order & Cart Modals) */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  overflow-y: auto;
  padding-top: 5vh;
  padding-bottom: 5vh;
}

.modal-content {
  background-color: #fff;
  margin: 5% auto;
  padding: 30px;
  width: 90%;
  max-width: 450px;
  border-radius: 8px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
  position: relative;
  color: #333;
}

.modal-content h2 {
    color: #333;
    text-align: center;
    margin-top: 0;
    margin-bottom: 20px;
}

.close-btn {
  color: #aaa;
  font-size: 28px;
  font-weight: bold;
  position: absolute;
  top: 10px;
  right: 15px;
  line-height: 1;
}

.close-btn:hover, .close-btn:focus {
  color: #333;
  text-decoration: none;
  cursor: pointer;
}

/* Order Form Styles (inside order modal) */
#order-form label {
  font-size: 1rem;
  margin-bottom: 6px;
  color: #555;
  display: block;
}

#order-form input {
  padding: 10px;
  margin-bottom: 15px;
  font-size: 1rem;
  border-radius: 5px;
  border: 1px solid #ddd;
  width: 100%;
  box-sizing: border-box;
}

#order-form button[type="submit"] {
  padding: 12px;
  background-color: #ff6347;
  color: white;
  font-size: 1.1rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.3s;
  width: 100%;
}

#order-form button[type="submit"]:hover {
  background-color: #ff4500;
}

/* General Form Focus Styling */
form input:focus {
  border-color: #ff6347;
  outline: none;
  box-shadow: 0 0 0 2px rgba(255, 99, 71, 0.2);
}

form button:focus { /* Includes .auth-button and modal submit buttons */
  outline: none;
  box-shadow: 0 0 0 2px rgba(255, 99, 71, 0.3);
}

/* Cart Modal Specifics */
#cart-items-container ul { list-style: none; padding: 0; margin: 0 0 15px 0; }
#cart-items-container li {
    padding: 10px 0;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}
#cart-items-container li:last-child { border-bottom: none; }
#cart-items-container .remove-item-btn {
    background-color: #f44336; color: white; border: none;
    padding: 5px 8px; border-radius: 4px; font-size: 0.8em;
    cursor: pointer; margin-left: 10px;
}
#cart-items-container .cart-item-qty-input {
    width: 50px; padding: 5px; text-align: center; margin: 0 5px;
}
#cart-items-container li > div { margin-top: 5px; }

.cart-total-display { font-size: 1.2em; font-weight: bold; text-align: right; margin-bottom: 15px; }

#checkout-btn {
    background-color: #4CAF50; color: white; padding: 12px;
    font-size: 1.1rem; border: none; border-radius: 6px;
    cursor: pointer; width: 100%; transition: background-color 0.3s;
}
#checkout-btn:disabled { background-color: #ccc; cursor: not-allowed; }
#checkout-btn:hover:not(:disabled) { background-color: #45a049; }


/* Responsive Adjustments for Header */
@media (max-width: 767px) { /* Mobile screens */
  header {
    flex-direction: column;
    align-items: center; /* Center all header items when stacked */
    padding-bottom: 10px; /* Add some bottom padding */
  }
  header h1 {
      margin-bottom: 15px; /* Space below H1 */
  }
  #header-actions {
    flex-direction: column;
    align-items: center;
    width: 100%;
    margin-left: 0;
    margin-top: 0; /* No extra top margin if stacked directly under h1 */
    gap: 15px; /* Space between cart and auth when stacked */
  }
  #cart-info {
    /* margin-bottom: 10px; Handled by gap in #header-actions */
    justify-content: center; /* Center cart items */
  }
  .auth-dropdown {
    left: 50%;
    transform: translateX(-50%); /* Center the dropdown */
    right: auto;
    width: 90vw;
    max-width: 340px; /* Slightly wider max for mobile dropdown */
    top: calc(100% + 10px); /* Ensure enough space below toggle button */
  }
  .filters {
    margin-top: 20px; /* Ensure space below auth/cart */
    justify-content: center;
  }
}

/* Desktop Styles (Refinements) */
@media (min-width: 768px) {
  header {
    /* Defaults are mostly fine from global header style */
    /* padding: 15px 40px; */ /* Optional: wider padding for desktop */
  }
  .filters {
    /* Filters take full width below main header items (H1, Cart, Auth) */
    width: 100%;
    justify-content: center; /* Or flex-start */
    margin-top: 15px;
    order: 3; /* Ensure filters are below H1 and header-actions */
  }
  #header-actions {
      order: 2; /* Place actions after H1 */
  }
}

/* --- Order History Section --- */
.order-history-container {
    max-width: 900px;
    margin: 30px auto;
    padding: 20px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.order-history-container h2 {
    text-align: center;
    color: #333;
    margin-bottom: 25px;
}

#orders-list-container .order-item-card {
    border: 1px solid #eee;
    border-radius: 8px;
    margin-bottom: 20px;
    padding: 15px;
    background-color: #f9f9f9;
}

#orders-list-container .order-item-card .reorder-btn {
    /* It already has .auth-button and .secondary */
    /* You can add more specific styling if needed */
    margin-top: 15px; /* Space above the button */
    display: block; /* Make it take full width within its padding context */
    width: auto; /* Or set a specific width/max-width */
    padding: 8px 15px; /* Adjust padding */
    font-size: 0.95rem;
    /* Example: Make it a bit distinct if it uses .secondary */
    /* background-color: #5bc0de; /* Info blue */
    /* border-color: #46b8da; */
}

/* #orders-list-container .order-item-card .reorder-btn:hover {
    background-color: #31b0d5;
} */

#orders-list-container .order-header {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    padding-bottom: 10px;
    margin-bottom: 10px;
    border-bottom: 1px solid #ddd;
}

#orders-list-container .order-header strong {
    color: #ff6347; /* Tomato color for emphasis */
}

#orders-list-container .order-header p,
#orders-list-container .order-details p {
    margin: 3px 0;
    font-size: 0.95em;
}
 #orders-list-container .order-details strong {
    color: #444;
}

#orders-list-container .order-pizzas-list {
    list-style: none;
    padding-left: 0; /* Remove default padding */
    margin-top: 10px;
}

#orders-list-container .order-pizzas-list li {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 0.9em;
    border-bottom: 1px dashed #eee;
}
#orders-list-container .order-pizzas-list li:last-child {
    border-bottom: none;
}

#orders-list-container .order-pizzas-list .item-name {
    flex-grow: 1;
}
#orders-list-container .order-pizzas-list .item-qty,
#orders-list-container .order-pizzas-list .item-price {
    margin-left: 15px;
    white-space: nowrap;
}

#close-order-history-btn {
    display: block;
    margin: 20px auto 0 auto;
    padding: 10px 20px;
    background-color: #6c757d; /* Secondary button color */
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
}
#close-order-history-btn:hover {
    background-color: #5a6268;
}
/* --- End Order History Section --- */

/* Adjust button styles to include secondary for "My Orders" */
.auth-action-button.secondary {
    background-color: #6c757d; /* Grey for secondary actions like My Orders, Register */
    border-color: #6c757d;
    color: white;
}

.auth-action-button.secondary:hover {
    background-color: #5a6268;
    border-color: #545b62;
}