@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;500;600;700;800;900&display=swap');

/* ─── Design Tokens ─────────────────────────────────────────────────────────── */
:root {
  --cream: #FFF8F0;
  --warm-white: #FFFDF9;
  --honey: #F5A623;
  --honey-dark: #D4891A;
  --honey-light: #FFD580;
  --brown: #3E2723;
  --brown-medium: #6D4C41;
  --brown-light: #A1887F;
  --green: #4CAF50;
  --green-dark: #388E3C;
  --red: #E53935;
  --red-dark: #C62828;
  --blue: #1E88E5;
  --blue-dark: #1565C0;
  --glass-bg: rgba(255, 255, 255, 0.65);
  --glass-border: rgba(255, 255, 255, 0.85);
  --shadow-soft: 0 8px 32px rgba(62, 39, 35, 0.12);
  --shadow-card: 0 4px 20px rgba(62, 39, 35, 0.10);
  --shadow-hover: 0 12px 40px rgba(62, 39, 35, 0.20);
  --radius: 18px;
  --radius-sm: 10px;
  --radius-lg: 24px;
  --transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  --transition-fast: all 0.15s ease;
}

/* ─── Reset & Base ───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: 'Nunito', system-ui, sans-serif;
  background: var(--cream);
  color: var(--brown);
  line-height: 1.6;
}

body {
  background:
    radial-gradient(ellipse at 20% 0%, #FFE0B2 0%, transparent 50%),
    radial-gradient(ellipse at 80% 10%, #FFF9C4 0%, transparent 40%),
    radial-gradient(ellipse at 50% 100%, #FFCCBC 0%, transparent 50%),
    var(--cream);
  min-height: 100vh;
}

/* ─── Scrollbar ──────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--brown-light); border-radius: 10px; }

/* ─── Typography ─────────────────────────────────────────────────────────────── */
h1 { font-size: 2rem; font-weight: 900; }
h2 { font-size: 1.5rem; font-weight: 800; }
h3 { font-size: 1.15rem; font-weight: 700; }

/* ─── Layout ─────────────────────────────────────────────────────────────────── */
.page { display: none; }
.page.active { display: block; }

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ─── Glass Card ─────────────────────────────────────────────────────────────── */
.card {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1.5px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 28px;
  transition: var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

/* ─── Buttons ─────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn:active { transform: scale(0.96); }

.btn-primary {
  background: linear-gradient(135deg, var(--honey), var(--honey-dark));
  color: white;
  box-shadow: 0 4px 15px rgba(245, 166, 35, 0.40);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #FFB74D, var(--honey));
  box-shadow: 0 6px 20px rgba(245, 166, 35, 0.55);
  transform: translateY(-2px);
}

.btn-danger {
  background: linear-gradient(135deg, #EF5350, var(--red-dark));
  color: white;
  box-shadow: 0 4px 15px rgba(229, 57, 53, 0.35);
}
.btn-danger:hover {
  box-shadow: 0 6px 20px rgba(229, 57, 53, 0.50);
  transform: translateY(-2px);
}

.btn-success {
  background: linear-gradient(135deg, #66BB6A, var(--green-dark));
  color: white;
  box-shadow: 0 4px 15px rgba(76, 175, 80, 0.35);
}
.btn-success:hover {
  box-shadow: 0 6px 20px rgba(76, 175, 80, 0.50);
  transform: translateY(-2px);
}

.btn-ghost {
  background: rgba(62, 39, 35, 0.08);
  color: var(--brown-medium);
  border: 1.5px solid rgba(62, 39, 35, 0.15);
}
.btn-ghost:hover {
  background: rgba(62, 39, 35, 0.14);
  transform: translateY(-1px);
}

.btn-sm {
  padding: 7px 14px;
  font-size: 0.82rem;
  border-radius: 8px;
}

.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 10px;
  justify-content: center;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* ─── Form Elements ──────────────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--brown-medium);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

input[type="text"],
input[type="password"],
input[type="number"],
textarea,
select {
  width: 100%;
  padding: 13px 16px;
  border: 2px solid rgba(62, 39, 35, 0.15);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: var(--brown);
  background: rgba(255, 255, 255, 0.8);
  transition: var(--transition-fast);
  outline: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--honey);
  background: white;
  box-shadow: 0 0 0 4px rgba(245, 166, 35, 0.15);
}

input::placeholder,
textarea::placeholder { color: var(--brown-light); font-weight: 500; }

textarea { resize: vertical; min-height: 90px; }

/* ─── Login Page ─────────────────────────────────────────────────────────────── */
#page-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-container {
  width: 100%;
  max-width: 420px;
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo .logo-icon {
  font-size: 4rem;
  display: block;
  margin-bottom: 10px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.login-logo h1 {
  color: var(--brown);
  font-size: 2.5rem;
  letter-spacing: -0.02em;
}

.login-logo p {
  color: var(--brown-light);
  font-size: 0.95rem;
  font-weight: 600;
  margin-top: 4px;
}

.login-card {
  padding: 36px;
}

.login-form { display: flex; flex-direction: column; gap: 20px; }

.error-msg {
  background: rgba(229, 57, 53, 0.12);
  border: 1.5px solid rgba(229, 57, 53, 0.30);
  color: var(--red-dark);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  display: none;
}
.error-msg.show { display: block; animation: shake 0.3s ease; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.btn-login {
  padding: 15px;
  font-size: 1rem;
  letter-spacing: 0.03em;
}

/* ─── App Header ─────────────────────────────────────────────────────────────── */
.app-header {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1.5px solid var(--glass-border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 16px rgba(62, 39, 35, 0.08);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  max-width: 900px;
  margin: 0 auto;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--brown);
}

.header-brand span { font-size: 1.6rem; }

.header-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--honey), var(--honey-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.95rem;
  color: white;
  box-shadow: 0 2px 8px rgba(245, 166, 35, 0.40);
  flex-shrink: 0;
}

.user-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--brown);
}

/* ─── Banner (30-Min Notification) ──────────────────────────────────────────── */
.session-banner {
  background: linear-gradient(135deg, #E8F5E9, #C8E6C9);
  border: 1.5px solid #A5D6A7;
  border-radius: var(--radius);
  padding: 18px 24px;
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 24px 0 0;
  animation: slideDown 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideDown {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.session-banner .banner-icon { font-size: 2rem; flex-shrink: 0; }

.session-banner .banner-text h3 {
  color: #2E7D32;
  font-size: 1rem;
  margin-bottom: 2px;
}

.session-banner .banner-text p {
  color: #388E3C;
  font-size: 0.9rem;
  font-weight: 600;
}

/* ─── Main Content Area ──────────────────────────────────────────────────────── */
.main-content {
  padding: 28px 24px 60px;
  max-width: 900px;
  margin: 0 auto;
}

/* ─── Order Card (User Dashboard) ───────────────────────────────────────────── */
.order-card { margin-top: 24px; }

.greeting {
  margin-bottom: 24px;
}

.greeting h2 {
  font-size: 1.8rem;
  color: var(--brown);
}

.greeting p {
  color: var(--brown-light);
  font-size: 0.95rem;
  font-weight: 600;
}

.order-form { display: flex; flex-direction: column; gap: 16px; }

.current-order {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 2px dashed rgba(62, 39, 35, 0.12);
}

.current-order h4 {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--brown-light);
  margin-bottom: 10px;
}

.order-bubble {
  background: linear-gradient(135deg, var(--honey-light), #FFE0B2);
  border: 1.5px solid rgba(245, 166, 35, 0.40);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  font-weight: 700;
  color: var(--brown);
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* ─── Admin Panel ─────────────────────────────────────────────────────────────── */
.admin-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 24px;
  background: rgba(62, 39, 35, 0.06);
  padding: 6px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
}

.tab-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  background: transparent;
  color: var(--brown-medium);
  transition: var(--transition-fast);
  white-space: nowrap;
  flex-shrink: 0;
}

.tab-btn:hover { background: rgba(255,255,255,0.6); }
.tab-btn.active {
  background: white;
  color: var(--brown);
  box-shadow: 0 2px 8px rgba(62, 39, 35, 0.12);
}

.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.2s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Orders Grid (Admin) ────────────────────────────────────────────────────── */
.orders-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.orders-count {
  background: linear-gradient(135deg, var(--honey), var(--honey-dark));
  color: white;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 800;
}

.orders-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.order-item-card {
  background: white;
  border-radius: var(--radius-sm);
  padding: 18px;
  border: 1.5px solid rgba(62, 39, 35, 0.08);
  box-shadow: var(--shadow-card);
  transition: var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.order-item-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--honey), var(--honey-dark));
}

.order-item-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }

.order-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.order-user .user-avatar {
  width: 34px;
  height: 34px;
  font-size: 0.82rem;
}

.order-user-name { font-weight: 800; font-size: 0.9rem; }

.order-item-text {
  font-size: 1rem;
  font-weight: 600;
  color: var(--brown);
  line-height: 1.4;
}

.order-time {
  font-size: 0.78rem;
  color: var(--brown-light);
  font-weight: 600;
  margin-top: 8px;
}

.empty-orders {
  text-align: center;
  padding: 48px 24px;
  color: var(--brown-light);
}
.empty-orders .empty-icon { font-size: 3rem; display: block; margin-bottom: 12px; }
.empty-orders p { font-weight: 700; font-size: 1rem; }

/* ─── Clear Modal ─────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(62, 39, 35, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.show {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: white;
  border-radius: var(--radius-lg);
  padding: 36px;
  max-width: 440px;
  width: 100%;
  box-shadow: 0 24px 80px rgba(62, 39, 35, 0.30);
  transform: scale(0.9) translateY(20px);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.show .modal {
  transform: scale(1) translateY(0);
}

.modal h3 {
  font-size: 1.4rem;
  margin-bottom: 8px;
  color: var(--brown);
}

.modal p {
  color: var(--brown-medium);
  margin-bottom: 24px;
  font-weight: 600;
  font-size: 0.93rem;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
  justify-content: flex-end;
}

.chf-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.chf-prefix {
  position: absolute;
  left: 14px;
  font-weight: 800;
  color: var(--brown-medium);
  font-size: 1rem;
  pointer-events: none;
}

.chf-input-wrap input {
  padding-left: 52px;
}

/* ─── User Management ─────────────────────────────────────────────────────────── */
.users-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.users-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1.5px solid rgba(62, 39, 35, 0.10);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  font-size: 0.93rem;
}

thead th {
  background: var(--brown);
  color: white;
  padding: 13px 18px;
  text-align: left;
  font-weight: 800;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

thead th:first-child { border-radius: calc(var(--radius) - 2px) 0 0 0; }
thead th:last-child { border-radius: 0 calc(var(--radius) - 2px) 0 0; }

tbody tr {
  border-bottom: 1px solid rgba(62, 39, 35, 0.07);
  transition: background 0.1s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(245, 166, 35, 0.06); }

tbody td {
  padding: 13px 18px;
  vertical-align: middle;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 800;
}

.badge-admin {
  background: linear-gradient(135deg, var(--honey), var(--honey-dark));
  color: white;
}

.badge-user {
  background: rgba(62, 39, 35, 0.08);
  color: var(--brown-medium);
}

/* ─── Cost History ────────────────────────────────────────────────────────────── */
.costs-total {
  background: linear-gradient(135deg, var(--brown), var(--brown-medium));
  color: white;
  border-radius: var(--radius);
  padding: 24px 28px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.costs-total .total-label {
  font-size: 0.85rem;
  font-weight: 700;
  opacity: 0.8;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.costs-total .total-amount {
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: -0.02em;
}

/* ─── User Edit Modal ────────────────────────────────────────────────────────── */
.user-modal-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
}

.checkbox-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  accent-color: var(--honey);
  cursor: pointer;
}

.checkbox-row label {
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}

/* ─── Toast Notification ─────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: var(--brown);
  color: white;
  padding: 14px 22px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.93rem;
  box-shadow: 0 8px 30px rgba(62, 39, 35, 0.35);
  z-index: 2000;
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 340px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.toast-success { background: #2E7D32; }
.toast.toast-error { background: var(--red-dark); }

/* ─── Loading Spinner ─────────────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255,255,255,0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .header-inner { padding: 12px 16px; }
  .main-content { padding: 20px 16px 50px; }
  .login-card { padding: 26px 22px; }
  .orders-grid { grid-template-columns: 1fr; }
  .admin-tabs { gap: 4px; }
  .tab-btn { padding: 9px 14px; font-size: 0.82rem; }
  .modal { padding: 26px 20px; }
  .costs-total { flex-direction: column; align-items: flex-start; gap: 4px; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { width: 100%; justify-content: center; }
}

/* ─── Utility ─────────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.w-full { width: 100%; }
