/* ============================================================
   Box Stock — Glassmorphism Styles
   ============================================================ */

/* --- CSS Variables --- */
:root {
  --glass-bg: rgba(255, 255, 255, 0.08);
  --glass-bg-strong: rgba(255, 255, 255, 0.12);
  --glass-border: rgba(255, 255, 255, 0.15);
  --glass-blur: 16px;
  --glass-blur-strong: 24px;
  --bg-gradient: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
  --text-primary: #f0f0f0;
  --text-secondary: rgba(255, 255, 255, 0.65);
  --text-dim: rgba(255, 255, 255, 0.4);
  --accent: #7c3aed;
  --accent-light: #a78bfa;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-2xl: 32px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.2);
}

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

/* Ensure hidden attribute always works */
[hidden] {
  display: none !important;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-gradient);
  background-attachment: fixed;
}

/* --- Views --- */
.view {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  position: absolute;
  top: 0;
  left: 0;
}

.hidden { display: none !important; }

/* --- Login View --- */
.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: var(--space-xl);
  text-align: center;
}

.app-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

.app-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: var(--space-2xl);
}

/* --- Access Denied View --- */
.access-denied-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: var(--space-xl);
  text-align: center;
}

.pixel-lock {
  font-size: 48px;
  margin-bottom: var(--space-lg);
  opacity: 0.6;
}

.access-denied-container h2 {
  font-size: 20px;
  color: var(--danger);
  margin-bottom: var(--space-md);
}

.access-denied-container p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

.access-denied-hint {
  color: var(--text-dim);
  margin-bottom: var(--space-xl) !important;
}

/* --- Header --- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-bottom: 1px solid var(--glass-border);
  min-height: 56px;
  flex-shrink: 0;
}

.header-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* --- Buttons --- */
.btn {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--text-primary);
  padding: var(--space-sm) var(--space-lg);
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.btn:hover { background: var(--glass-bg-strong); }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent-light);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-light); }

.btn-secondary {
  background: var(--glass-bg);
  border-color: var(--glass-border);
}

.btn-danger {
  background: rgba(248, 113, 113, 0.2);
  border-color: var(--danger);
  color: var(--danger);
}

.btn-text {
  background: transparent;
  border: none;
  color: var(--accent-light);
  padding: var(--space-xs) var(--space-sm);
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  padding: var(--space-xs);
  min-width: 44px;
  min-height: 44px;
}

.btn-sm { font-size: 12px; padding: var(--space-xs) var(--space-md); min-height: 36px; }
.btn-full { width: 100%; }

/* --- Form Fields --- */
.field-group { margin-bottom: var(--space-md); }

.field-group label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.field-group input[type="text"],
.field-group input[type="email"],
.field-group input[type="password"],
.field-group input[type="number"] {
  width: 100%;
  font-family: var(--font);
  font-size: 14px;
  padding: var(--space-sm) var(--space-md);
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  min-height: 44px;
  outline: none;
  transition: border-color 0.2s;
}

.field-group input:focus {
  border-color: var(--accent-light);
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.2);
}

.field-error {
  display: block;
  font-size: 12px;
  color: var(--danger);
  margin-top: var(--space-xs);
}

.field-group--row {
  display: flex;
  align-items: flex-end;
  gap: var(--space-sm);
}

.field-group__item { flex: 1; }
.field-group__item input { width: 100%; }

.dimension-sep {
  font-size: 16px;
  color: var(--text-dim);
  padding-bottom: var(--space-sm);
}

.cost-input-wrapper {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}
.cost-input-wrapper .currency-symbol {
  font-size: 14px;
  color: var(--accent-light);
}
.cost-input-wrapper input { flex: 1; }

.field-group--toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* --- Token Input Row --- */
.token-input-row {
  display: flex;
  gap: var(--space-sm);
}
.token-input-row input {
  flex: 1;
  font-family: var(--font);
  font-size: 14px;
  padding: var(--space-sm);
  background: var(--glass-bg);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  min-height: 44px;
}

.token-status {
  font-size: 12px;
  margin-top: var(--space-xs);
}

/* --- Loading State --- */
.loading-state {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: var(--space-lg);
}
.loading-state[hidden] { display: none !important; }
.loading-state:not([hidden]) { display: flex; }

.loading-state p {
  font-size: 14px;
  color: var(--text-secondary);
}

.pixel-progress-bar {
  width: 200px;
  height: 4px;
  border-radius: 2px;
  background: var(--glass-bg-strong);
  overflow: hidden;
}

.pixel-progress-bar__fill {
  height: 100%;
  width: 30%;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  border-radius: 2px;
  animation: glass-load 1.5s ease-in-out infinite;
}

@keyframes glass-load {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}

/* --- Error State --- */
.error-state {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: var(--space-md);
  text-align: center;
}
.error-state[hidden] { display: none !important; }
.error-state:not([hidden]) { display: flex; }
.error-state p { font-size: 14px; color: var(--danger); }

/* --- Empty State --- */
.empty-state {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: var(--space-md);
  text-align: center;
  padding: var(--space-xl);
}
.empty-state[hidden] { display: none !important; }
.empty-state:not([hidden]) { display: flex; }
.empty-state p { font-size: 14px; color: var(--text-secondary); }
.empty-hint { font-size: 13px; color: var(--accent-light); }

.pixel-box-icon { width: 56px; height: 56px; position: relative; }
.pixel-box-icon__top {
  width: 56px; height: 20px;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  opacity: 0.6;
}
.pixel-box-icon__body {
  width: 56px; height: 36px;
  background: var(--glass-bg-strong);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  border: 1px solid var(--glass-border);
  border-top: none;
}

/* --- Box List --- */
.box-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md);
  padding-bottom: 80px;
  flex-direction: column;
  gap: var(--space-md);
}
.box-list[hidden] { display: none !important; }
.box-list:not([hidden]) { display: flex; }

/* --- Box Card --- */
.box-card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.box-card--out {
  border-color: rgba(248, 113, 113, 0.4);
  box-shadow: 0 4px 16px rgba(248, 113, 113, 0.1);
}

.box-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-sm);
}

.box-card__status {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-right: var(--space-sm);
  flex-shrink: 0;
}
.box-card__status--in { background: var(--success); box-shadow: 0 0 8px rgba(52, 211, 153, 0.5); }
.box-card__status--low { background: var(--warning); box-shadow: 0 0 8px rgba(251, 191, 36, 0.5); }
.box-card__status--out { background: var(--danger); box-shadow: 0 0 8px rgba(248, 113, 113, 0.5); }

.box-card__name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.box-card__menu-btn {
  font-size: 18px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: var(--space-xs);
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}
.box-card__menu-btn:hover { background: var(--glass-bg-strong); }

.box-card__details {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
}

/* --- Flag Row --- */
.box-card__flag-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--glass-border);
}

.box-card__flag-checkbox {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
  cursor: pointer;
}

.box-card__flag-label {
  font-size: 13px;
  color: var(--text-secondary);
}

/* --- Purchase Quantity Row --- */
.box-card__purchase-qty-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: rgba(124, 58, 237, 0.08);
  border: 1px solid rgba(124, 58, 237, 0.2);
  border-radius: var(--radius-md);
}

.box-card__purchase-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-light);
  white-space: nowrap;
}

.box-card__qty-btn {
  font-size: 18px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s;
}
.box-card__qty-btn:hover { background: var(--accent); color: #fff; }
.box-card__qty-btn:active { transform: scale(0.9); }
.box-card__qty-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.box-card__purchase-input {
  width: 50px;
  font-family: var(--font);
  font-size: 16px;
  font-weight: 700;
  padding: var(--space-xs);
  background: transparent;
  color: var(--text-primary);
  border: none;
  text-align: center;
  outline: none;
}

.box-card__purchase-unit {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* --- Send Report Button --- */
.send-report-btn {
  margin: var(--space-md);
  width: calc(100% - var(--space-md) * 2);
  font-size: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  border: none;
  box-shadow: 0 4px 20px rgba(124, 58, 237, 0.4);
}
.send-report-btn:hover { box-shadow: 0 4px 24px rgba(124, 58, 237, 0.6); }
.send-report-btn[hidden] { display: none !important; }

/* --- Context Menu --- */
.box-card__context-menu {
  position: absolute;
  right: var(--space-md);
  top: 48px;
  background: rgba(30, 30, 50, 0.95);
  backdrop-filter: blur(var(--glass-blur-strong));
  -webkit-backdrop-filter: blur(var(--glass-blur-strong));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  z-index: 100;
  overflow: hidden;
}

.box-card__context-menu button {
  display: block;
  width: 100%;
  font-family: var(--font);
  font-size: 13px;
  padding: var(--space-sm) var(--space-lg);
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  min-height: 40px;
  transition: background 0.15s;
}
.box-card__context-menu button:hover { background: var(--glass-bg-strong); }

/* --- FAB --- */
.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  font-size: 28px;
  font-weight: 300;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  color: #fff;
  border: none;
  border-radius: 50%;
  box-shadow: 0 6px 24px rgba(124, 58, 237, 0.5);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  transition: all 0.2s;
}
.fab:hover { transform: scale(1.05); box-shadow: 0 8px 30px rgba(124, 58, 237, 0.6); }
.fab:active { transform: scale(0.95); }

/* --- Overlay & Bottom Sheet --- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: flex-end;
}

.bottom-sheet {
  width: 100%;
  max-height: 80vh;
  background: rgba(20, 20, 40, 0.92);
  backdrop-filter: blur(var(--glass-blur-strong));
  -webkit-backdrop-filter: blur(var(--glass-blur-strong));
  border: 1px solid var(--glass-border);
  border-bottom: none;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: var(--space-xl);
  overflow-y: auto;
}
.bottom-sheet--tall { max-height: 90vh; }

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-xl);
}

.sheet-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

/* --- Modal --- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: rgba(20, 20, 40, 0.95);
  backdrop-filter: blur(var(--glass-blur-strong));
  -webkit-backdrop-filter: blur(var(--glass-blur-strong));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  width: calc(100% - 48px);
  max-width: 360px;
  box-shadow: var(--shadow);
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-md);
}

.modal-message {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: var(--space-xl);
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
}

/* --- Settings --- */
.settings-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}

.settings-section {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
}

.settings-section__title {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-light);
  margin-bottom: var(--space-md);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.timezone-display {
  font-size: 12px;
  color: var(--text-dim);
}

/* --- Users List --- */
.users-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.user-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  font-size: 12px;
}

.user-item__email {
  color: var(--text-primary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-item__badge {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent-light);
  margin-left: var(--space-sm);
  padding: 2px 6px;
  background: rgba(124, 58, 237, 0.15);
  border-radius: var(--radius-sm);
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--glass-border);
  border-radius: 3px;
}

/* --- Error Message --- */
.error-message {
  font-size: 13px;
  color: var(--danger);
  margin-top: var(--space-sm);
  margin-bottom: var(--space-sm);
}

/* --- Pixel Toggle (kept for settings) --- */
.pixel-toggle {
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  padding: var(--space-xs) var(--space-md);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  min-height: 32px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}
.pixel-toggle[aria-pressed="false"] {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--glass-border);
}
