/* =========================================================
   Stocktake UI Theme: Aurora Pro (v7)
   - Modern, high-contrast, glass panels
   - No workflow/markup changes (CSS only)
   ========================================================= */

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

:root {
  --aurora-green: #00f2ea;
  --aurora-cyan:  #00c2f2;
  --aurora-purple:#865dff;

  --polar-night:  #0f1220;
  --midnight-blue:#161a2a;
  --panel:        rgba(22, 26, 42, 0.72);
  --panel-2:      rgba(22, 26, 42, 0.52);
  --glass-border: rgba(255,255,255,0.14);

  --text:         #f0f4f7;
  --muted:        #a0aec0;
  --muted-2:      #7f8aa6;

  --success:      #2dfa7c;
  --warning:      #ffa800;
  --danger:       #ff4757;
  --info:         #6aa9ff;

  --shadow-card:  0 14px 42px rgba(0,0,0,0.45);
  --shadow-glow:  0 0 22px rgba(0,194,242,0.18);
  --radius:       14px;
  --radius-sm:    10px;
  --t:            0.22s;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);
  background-color: var(--polar-night);
  background-image:
    radial-gradient(900px 600px at 15% 20%, rgba(134,93,255,0.20), transparent 60%),
    radial-gradient(900px 600px at 80% 10%, rgba(0,242,234,0.16), transparent 60%),
    radial-gradient(900px 700px at 75% 85%, rgba(0,194,242,0.14), transparent 60%),
    linear-gradient(180deg, var(--polar-night), var(--midnight-blue));
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Links */
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  margin: 16px auto 12px auto;
  width: min(1400px, calc(100% - 28px));
  background: rgba(15,18,32,0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}

.logo {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.2px;
  color: var(--text);
}

.user-info {
  color: var(--muted);
  font-size: 0.92rem;
  white-space: nowrap;
}

.user-info span { color: var(--text); font-weight: 600; }

.header .right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Buttons */
button, .button-link {
  font-family: inherit;
}

.button-link, button.primary, button.secondary, button.info, button.danger,
.primary, .secondary, .info, .danger {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 0.92rem;
  line-height: 1;
  cursor: pointer;
  transition: transform var(--t), box-shadow var(--t), background var(--t), border-color var(--t), color var(--t), opacity var(--t);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  user-select: none;
}

.small { padding: 8px 12px; font-size: 0.86rem; }

.primary {
  background: linear-gradient(90deg, rgba(0,242,234,0.22), rgba(0,194,242,0.18));
  border-color: rgba(0,242,234,0.35);
  color: var(--text);
  box-shadow: var(--shadow-glow);
}
.primary:hover { transform: translateY(-1px); }

.secondary {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.14);
  color: var(--text);
}
.secondary:hover { background: rgba(255,255,255,0.10); transform: translateY(-1px); }

.info {
  background: rgba(106,169,255,0.12);
  border-color: rgba(106,169,255,0.28);
  color: var(--text);
}

.danger {
  background: rgba(255,71,87,0.14);
  border-color: rgba(255,71,87,0.35);
  color: var(--text);
}

button:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

/* Summary */
.stocktake-summary {
  width: min(1400px, calc(100% - 28px));
  margin: 0 auto 14px auto;
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  background: var(--panel-2);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.summary-box {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  text-align: center;
  min-height: 82px;
  display: grid;
  align-content: center;
  gap: 6px;
}

.summary-box .label {
  color: var(--muted);
  font-size: 0.82rem;
}

.summary-box .count {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.count.green { color: var(--success); }
.count.red { color: var(--danger); }
.count.orange { color: var(--warning); }

/* Layout columns */
.stocktake-container {
  width: min(1400px, calc(100% - 28px));
  margin: 0 auto 30px auto;
  display: grid;
  grid-template-columns: 1fr 1.35fr 1.35fr;
  gap: 14px;
}

/* Cards */
.card {
  background: var(--panel);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  overflow: hidden;
  min-height: 0; /* allow internal scrolling */
}

.card-full-height { height: calc(100vh - 240px); }

.card-header {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.04);
}

.card-header h3 {
  margin: 0;
  font-size: 1.03rem;
  font-weight: 700;
  color: var(--text);
}

.card-body {
  padding: 14px 16px 16px 16px;
  color: var(--text);
  overflow: auto;
  height: 100%;
}

h4, h3.completed-header {
  margin: 14px 0 8px 0;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: 0.2px;
}

/* Inputs */
input[type="text"], input[type="number"], input[type="password"], textarea, .search-box {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(15,18,32,0.55);
  color: var(--text);
  outline: none;
  transition: border-color var(--t), box-shadow var(--t), background var(--t);
}

input::placeholder, textarea::placeholder { color: rgba(160,174,192,0.75); }

input:focus, textarea:focus {
  border-color: rgba(0,242,234,0.45);
  box-shadow: 0 0 0 4px rgba(0,242,234,0.10);
}

.search-box { margin-bottom: 10px; }

/* Left column forms */
#form_add_unexp_cons {
  display: grid;
  gap: 10px;
  padding: 10px 0 6px 0;
}

#form_add_unexp_cons .primary { justify-self: start; }

#unexp_cons_status {
  min-height: 18px;
  color: var(--muted);
  font-size: 0.88rem;
}

/* Lists */
.item-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 0 0;
  display: grid;
  gap: 10px;
}

.item-list li,
.consumable-item {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-sm);
  padding: 12px 12px;
  color: var(--text);
}

.item-list li strong,
.consumable-item strong { font-weight: 700; color: var(--text); }

.item-list li small,
.consumable-item small { color: rgba(160,174,192,0.9); }

.item-list li.pending { border-left: 4px solid rgba(106,169,255,0.75); }
.item-list li.found { border-left: 4px solid rgba(45,250,124,0.75); background: rgba(45,250,124,0.08); }
.item-list li.unexpected { border-left: 4px solid rgba(255,168,0,0.75); background: rgba(255,168,0,0.08); }
.item-list li.accounted-for { border-left: 4px solid rgba(45,250,124,0.55); opacity: 0.88; }

/* Consumables states (make mismatch readable!) */
.consumable-item.pending { border-left: 4px solid rgba(106,169,255,0.75); }
.consumable-item.found { border-left: 4px solid rgba(45,250,124,0.75); background: rgba(45,250,124,0.08); }
.consumable-item.mismatch {
  border-left: 4px solid rgba(255,71,87,0.85);
  background: rgba(255,71,87,0.10);
}
.consumable-item.unexpected {
  border-left: 4px solid rgba(255,168,0,0.85);
  background: rgba(255,168,0,0.08);
}

.controls, .item-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.controls input.consumable-count {
  max-width: 110px;
}

.save-status { color: var(--muted); font-size: 0.9rem; }

/* Notes block */
.notes {
  margin-top: 10px;
  padding: 10px 10px;
  background: rgba(15,18,32,0.45);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 12px;
  color: rgba(240,244,247,0.95);
  min-height: 20px;
  word-break: break-word;
}

.notes-user {
  color: var(--aurora-cyan);
  font-weight: 700;
  margin-right: 6px;
}

.found-timestamp { color: rgba(160,174,192,0.95); }

/* Toast */
#toast-container {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 999;
  width: min(720px, calc(100% - 24px));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(15,18,32,0.78);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 999px;
  padding: 12px 14px;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.toast-text { color: var(--text); font-weight: 600; }
.toast-actions { display: inline-flex; gap: 8px; align-items: center; }
.toast-close { background: rgba(255,255,255,0.10); border: 1px solid rgba(255,255,255,0.14); border-radius: 999px; width: 34px; height: 34px; padding: 0; font-size: 20px; line-height: 1; color: var(--text); }
.toast-close:hover { background: rgba(255,255,255,0.14); }

/* Modal */
body.modal-open { overflow: hidden; }

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.55);
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal-overlay.hidden { display: none; }

.modal {
  width: min(620px, 100%);
  background: rgba(15,18,32,0.88);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 18px;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
}

.modal-header h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.2px;
}

.modal-close {
  border-radius: 999px;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.08);
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
}

.modal-body { padding: 16px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.04);
}

.modal-message { margin: 0; color: var(--text); line-height: 1.5; }

.modal-label { display: block; margin-bottom: 8px; color: var(--muted); font-weight: 700; }
.modal-textarea { width: 100%; resize: vertical; min-height: 140px; }
.modal-hint { margin-top: 8px; color: var(--muted-2); font-size: 0.9rem; }

/* Login/Dashboard pages */
.login-container,
.dashboard-container,
.container {
  width: min(980px, calc(100% - 28px));
  margin: 28px auto;
}

.login-box {
  max-width: 420px;
  margin: 16vh auto 0 auto;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.login-box h1 { margin: 0 0 14px 0; font-size: 1.4rem; }
.login-box label { display: block; margin: 10px 0 6px 0; color: var(--muted); font-weight: 700; }
.login-box .error { margin-top: 10px; color: var(--danger); font-weight: 700; }

/* Tables in report */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.12);
}

th, td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
  color: var(--text);
  vertical-align: top;
}

th {
  background: rgba(255,255,255,0.05);
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.78rem;
  letter-spacing: 0.6px;
}

tr:nth-child(even) td { background: rgba(255,255,255,0.03); }

/* Responsive */
@media (max-width: 1200px) {
  .stocktake-container { grid-template-columns: 1fr; }
  .card-full-height { height: auto; }
  .stocktake-summary { grid-template-columns: 1fr 1fr; }
  .header { position: relative; top: auto; }
}

@media (max-width: 520px) {
  .summary-box .count { font-size: 1.15rem; }
  .header { padding: 12px 14px; }
  .user-info { display: none; }
}
