/* --- Owner Dashboard Styles (Rewritten) --- */
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap");

:root {
  --primary-color: #ff5722;
  --dark-bg: #121212;
  --card-bg: #1e1e1e;
  --text-color: #e0e0e0;
  --border-color: #333;
  --success-color: #2ecc71;
  --error-color: #ff5252;
  --body-font: "Poppins", sans-serif;
}

/* --- Base & Body --- */
body {
  font-family: var(--body-font);
  background-color: var(--dark-bg);
  color: var(--text-color);
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* --- LOGIN SECTION --- */
.view-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 1em;
  box-sizing: border-box;
}

.login-box {
  background-color: var(--card-bg);
  padding: 2.5em;
  border-radius: 8px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  border-top: 4px solid var(--primary-color);
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
}

.login-box h2 {
  margin-bottom: 1.5em;
  font-weight: 700;
}
.login-box input {
  width: 100%;
  padding: 1em;
  margin-bottom: 1em;
  background-color: #333;
  border: 1px solid var(--border-color);
  color: var(--text-color);
  border-radius: 4px;
  font-size: 1em;
  box-sizing: border-box;
}
.login-box button {
  width: 100%;
  padding: 1em;
  background-color: var(--primary-color);
  border: none;
  color: white;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1em;
  text-transform: uppercase;
  transition: background-color 0.3s;
}
.login-box button:hover {
  background-color: #e64a19;
}

.error-message {
  color: var(--error-color);
  margin-top: 1em;
  min-height: 1.2em;
  font-size: 0.9em;
  font-weight: 600;
}

.site-link {
  margin-top: 1.5em;
}
.site-link a {
  color: #aaa;
  text-decoration: none;
  font-size: 0.9em;
  transition: color 0.3s;
}
.site-link a:hover {
  color: var(--primary-color);
}

.shake {
  animation: shake 0.5s;
}
@keyframes shake {
  10%,
  90% {
    transform: translateX(-8px);
  }
  20%,
  80% {
    transform: translateX(8px);
  }
  30%,
  50%,
  70% {
    transform: translateX(-4px);
  }
  40%,
  60% {
    transform: translateX(4px);
  }
}

/* --- DASHBOARD SECTION --- */
#dashboardSection {
  display: none;
} /* Hidden until login */

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1em 2em;
  background-color: #1a1a1a;
  border-bottom: 1px solid var(--border-color);
}

.header-left a {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s;
}
.header-left a:hover {
  color: #e64a19;
}
.header-center h1 {
  color: var(--primary-color);
  font-size: 1.5em;
  margin: 0;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 1em;
}

.nav-tabs button {
  background: transparent;
  border: 2px solid var(--border-color);
  color: var(--text-color);
  padding: 0.6em 1.2em;
  border-radius: 50px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}
.nav-tabs button.active,
.nav-tabs button:hover {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: white;
}
#logoutBtn {
  background: transparent;
  border: 2px solid var(--error-color);
  color: var(--error-color);
  padding: 0.6em 1.2em;
  border-radius: 50px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}
#logoutBtn:hover {
  background: var(--error-color);
  color: white;
}

main.dashboard-content {
  padding: 2em;
}
.view {
  display: none;
}
.view.active {
  display: block;
}

/* --- Order Management --- */
.order-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2em;
}
.order-column {
  background-color: var(--card-bg);
  border-radius: 8px;
  padding: 1.5em;
  display: flex;
  flex-direction: column;
}
.order-column h2 {
  display: flex;
  align-items: center;
  gap: 0.5em;
  margin-top: 0;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.8em;
  margin-bottom: 1em;
}
.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}
.status-dot.new {
  background-color: var(--primary-color);
}
.status-dot.completed {
  background-color: var(--success-color);
}
.order-list {
  flex-grow: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1em;
  max-height: 65vh; /* Set a max height to enable scrolling */
}
.order-card {
  background-color: #2a2a2a;
  border-radius: 6px;
  padding: 1em;
  border-left: 4px solid var(--primary-color);
}
.order-card.completed {
  border-left-color: var(--success-color);
}
.order-card h3 {
  margin: 0 0 0.5em 0;
  font-size: 1.1em;
}
.order-card p {
  margin: 0.3em 0;
  font-size: 0.9em;
  color: #ccc;
}
.order-card .items-list {
  list-style: none;
  padding-left: 1em;
  margin: 0.8em 0;
  border-left: 2px solid var(--border-color);
}
.order-card .total {
  font-weight: bold;
  color: var(--primary-color);
  margin-top: 1em;
  font-size: 1.1em;
}
.btn-success {
  background: var(--success-color);
  color: white;
  border: none;
  padding: 0.8em 1.2em;
  border-radius: 4px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 1em;
  width: 100%;
  transition: background-color 0.3s;
}
.btn-success:hover {
  background: #27ae60;
}

/* --- Menu Management --- */
.menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5em;
}
.menu-header h2 {
  margin: 0;
}
#addDishBtn {
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 0.8em 1.5em;
  border-radius: 50px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.3s;
}
#addDishBtn:hover {
  background: #e64a19;
}
.table-container {
  width: 100%;
  background-color: var(--card-bg);
  border-radius: 8px;
  overflow-x: auto;
}
#menuTable {
  width: 100%;
  border-collapse: collapse;
}
#menuTable th,
#menuTable td {
  padding: 1em;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}
#menuTable th {
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.9em;
}
#menuTable tbody tr:hover {
  background-color: #2a2a2a;
}
#menuTable .dish-image {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 4px;
}
#menuTable .actions {
  display: flex;
  gap: 0.5em;
}
#menuTable .actions button {
  padding: 0.5em 1em;
  border-radius: 4px;
  border: none;
  color: white;
  cursor: pointer;
  font-weight: 600;
}
.edit-btn {
  background: #3498db;
}
.delete-btn {
  background: var(--error-color);
}

/* --- MODAL STYLES (REWRITTEN) --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: none; /* Hidden by default */
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(5px);
}
.modal-box {
  background: var(--card-bg);
  border-radius: 8px;
  width: 100%;
  max-width: 550px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
}
.modal-header {
  padding: 1em 1.5em;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h2 {
  margin: 0;
}
.modal-close-btn {
  background: none;
  border: none;
  color: #aaa;
  font-size: 2em;
  cursor: pointer;
}
.modal-content {
  padding: 1.5em;
  overflow-y: auto;
}
.modal-footer {
  padding: 1em 1.5em;
  border-top: 1px solid var(--border-color);
}
.form-group {
  margin-bottom: 1.2em;
  text-align: left;
}
.form-group label {
  display: block;
  margin-bottom: 0.5em;
  font-weight: 600;
}
#menuForm input[type="text"],
#menuForm input[type="number"],
#menuForm select {
  width: 100%;
  padding: 0.8em;
  background-color: #333;
  border: 1px solid var(--border-color);
  color: var(--text-color);
  border-radius: 4px;
  font-size: 1em;
  box-sizing: border-box;
}
#menuForm input[type="file"] {
  padding: 0.5em;
}
.price-toggle div {
  display: flex;
  gap: 1.5em;
  align-items: center;
}
#imagePreview {
  max-width: 100px;
  margin-top: 10px;
  border-radius: 4px;
  display: none;
}
.form-hint {
  font-size: 0.8em;
  color: #aaa;
  margin-top: 5px;
}
.upload-progress {
  margin-top: 1em;
  display: none;
}
.progress-bar {
  width: 100%;
  height: 10px;
  background: #333;
  border-radius: 5px;
  overflow: hidden;
}
#progressBarFill {
  height: 100%;
  width: 0%;
  background: var(--success-color);
}
.modal-footer button {
  width: 100%;
  padding: 1em;
  background: var(--primary-color);
  border: none;
  color: white;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
  cursor: pointer;
}

/* --- NEW: ANALYTICS VIEW STYLES --- */
.analytics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5em;
}

.stat-card {
  background-color: var(--card-bg);
  padding: 1.5em;
  border-radius: 8px;
  border-left: 4px solid var(--primary-color);
}

.stat-card h3 {
  margin-top: 0;
  font-size: 1.1em;
  color: #ccc;
}

.stat-card p {
  font-size: 2em;
  font-weight: 700;
  margin: 0.5em 0 0 0;
}

.stat-card.full-width {
  grid-column: 1 / -1; /* Span across both columns */
}

#topDishesList {
  list-style: none;
  padding: 0;
  margin: 0.5em 0 0 0;
}

#topDishesList li {
  padding: 0.5em 0;
  border-bottom: 1px solid var(--border-color);
  font-size: 1em;
}
#topDishesList li:last-child {
  border-bottom: none;
}

/* --- RESPONSIVE ADJUSTMENTS --- */
@media (max-width: 1024px) {
  .dashboard-header {
    flex-direction: column;
    align-items: stretch;
    gap: 1em;
  }
  .header-center {
    text-align: center;
    order: -1; /* Move title to the top on smaller screens */
  }
  .header-left,
  .header-right {
    justify-content: center;
  }
}

@media (max-width: 768px) {
  .order-columns,
  .analytics-grid {
    grid-template-columns: 1fr;
  }
  .order-list {
    min-height: auto;
    max-height: 45vh;
  }
  .header-right {
    flex-direction: column;
    gap: 1em;
    width: 100%;
  }
  .nav-tabs {
    width: 100%;
    display: flex;
    justify-content: center;
  }
  #logoutBtn {
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
  }
}
