/* ═══════════════════════════════════════════════════
   Mothership Dashboard — TCG Kiosk Control
   Dark theme, responsive, mobile-first.
   ═══════════════════════════════════════════════════ */

/* ── Variables ─────────────────────────────────────── */
:root {
  --bg:          #000000;
  --bg-surface:  #0a0a0a;
  --bg-card:     #111111;
  --bg-elevated: #1a1a1a;
  --bg-input:    #141414;
  --bg-hover:    #1f1f1f;

  --accent-blue:        #40c4ff;
  --accent-blue-dim:    #0288d1;
  --accent-blue-glow:   rgba(64, 196, 255, 0.2);
  --accent-green:       #00e676;
  --accent-green-dim:   #00c853;
  --accent-amber:       #ffab40;
  --accent-red:         #ff5252;
  --accent-red-dim:     #c62828;
  --accent-purple:      #ce93d8;

  --text-primary:   #ffffff;
  --text-secondary: rgba(255,255,255,0.6);
  --text-muted:     rgba(255,255,255,0.35);
  --text-disabled:  rgba(255,255,255,0.2);

  --border:        rgba(255,255,255,0.08);
  --border-focus:  rgba(64, 196, 255, 0.5);

  --status-online:  #00e676;
  --status-offline: #ff5252;
  --status-idle:    rgba(255,255,255,0.3);

  --radius-sm:  6px;
  --radius-md:  12px;
  --radius-lg:  18px;
  --radius-xl:  24px;

  --shadow-card: 0 2px 16px rgba(0,0,0,0.5);
  --shadow-elevated: 0 8px 32px rgba(0,0,0,0.7);

  --font-ui:   -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', 'Cascadia Code', 'Fira Code', 'Courier New', monospace;

  --header-h: 64px;
  --bulk-h: auto;
}

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

html {
  height: 100%;
  overflow-x: hidden;
}

body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

/* ── Screen transitions ─────────────────────────────── */
.screen {
  display: none;
  min-height: 100vh;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

/* ══════════════════════════════════════════════════════
   LOGIN SCREEN
   ══════════════════════════════════════════════════════ */

#screen-login.active {
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(ellipse at 50% 30%, rgba(64,196,255,0.06) 0%, transparent 60%), var(--bg);
}

.login-wrap {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.login-logo {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.logo-icon {
  font-size: 56px;
  line-height: 1;
  margin-bottom: 8px;
  filter: drop-shadow(0 0 20px rgba(64,196,255,0.4));
}

.logo-title {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #40c4ff 0%, #ce93d8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-sub {
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.field-input {
  height: 52px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 16px;
  padding: 0 16px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
  appearance: none;
}

.field-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-blue-glow);
}

.login-error {
  background: rgba(255, 82, 82, 0.12);
  border: 1px solid rgba(255, 82, 82, 0.35);
  color: var(--accent-red);
  font-size: 13px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  text-align: center;
}

/* ── Buttons ────────────────────────────────────────── */
.btn-primary {
  background: var(--accent-blue);
  color: #000;
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  padding: 0 20px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
  white-space: nowrap;
}

.btn-primary:hover  { background: #29b6f6; }
.btn-primary:active { transform: scale(0.97); background: var(--accent-blue-dim); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 0 16px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
}

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

.btn-danger {
  background: rgba(255, 82, 82, 0.1);
  color: var(--accent-red);
  border: 1px solid rgba(255, 82, 82, 0.3);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 0 16px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
}

.btn-danger:hover  { background: rgba(255, 82, 82, 0.18); }
.btn-danger:active { transform: scale(0.97); }

.btn-small {
  height: 34px;
  font-size: 12px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
}

.btn-icon-only {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.btn-icon-only:hover { background: var(--bg-hover); }

.btn-login {
  height: 52px;
  font-size: 16px;
  border-radius: var(--radius-md);
  width: 100%;
}

/* ── Spinner ────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(0,0,0,0.3);
  border-top-color: #000;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

/* ══════════════════════════════════════════════════════
   DASHBOARD HEADER
   ══════════════════════════════════════════════════════ */

.dash-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
}

.dash-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dash-logo {
  font-size: 28px;
  filter: drop-shadow(0 0 8px rgba(64,196,255,0.4));
}

.dash-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
  background: linear-gradient(135deg, #40c4ff 0%, #ce93d8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.dash-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
}

.dash-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Poll indicator ─────────────────────────────────── */
.poll-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 230, 118, 0.08);
  border: 1px solid rgba(0, 230, 118, 0.25);
  border-radius: 20px;
  padding: 6px 12px;
}

.poll-dot {
  width: 7px;
  height: 7px;
  background: var(--accent-green);
  border-radius: 50%;
  animation: pollPulse 2s ease-in-out infinite;
}

@keyframes pollPulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(0,230,118,0.5); }
  50%       { opacity: 0.7; box-shadow: 0 0 0 4px rgba(0,230,118,0); }
}

.poll-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--accent-green);
}

/* ══════════════════════════════════════════════════════
   BULK CONTROLS BAR
   ══════════════════════════════════════════════════════ */

.bulk-bar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.bulk-bar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 20px;
}

.bulk-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 12px;
}

.bulk-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.bulk-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.bulk-group-row {
  flex-direction: row;
  align-items: flex-end;
  gap: 8px;
}

.bulk-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.bulk-select,
.bulk-input {
  height: 40px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 13px;
  padding: 0 12px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  min-width: 160px;
  appearance: none;
}

.bulk-select:focus,
.bulk-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px var(--accent-blue-glow);
}

.bulk-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='rgba(255,255,255,0.4)' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* ══════════════════════════════════════════════════════
   PHONE GRID
   ══════════════════════════════════════════════════════ */

.phone-grid-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.phone-grid {
  max-width: 1400px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  align-items: start;
}

.phones-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 24px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.phones-empty-icon {
  font-size: 48px;
  opacity: 0.4;
  margin-bottom: 8px;
}

.phones-empty-sub {
  font-size: 13px;
  opacity: 0.6;
}

/* ── Phone Card ─────────────────────────────────────── */
.phone-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
  position: relative;
}

.phone-card:hover {
  border-color: rgba(255,255,255,0.14);
  box-shadow: var(--shadow-card);
}

.phone-card.status-online {
  border-color: rgba(0, 230, 118, 0.2);
}

.phone-card.status-offline {
  opacity: 0.65;
}

/* Card header */
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}

.card-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--status-idle);
  flex-shrink: 0;
  transition: background 0.3s;
}

.status-dot.online  { background: var(--status-online);  box-shadow: 0 0 0 3px rgba(0,230,118,0.2); }
.status-dot.offline { background: var(--status-offline); }

.card-identity {}

.card-phone-id {
  font-size: 15px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
  line-height: 1.2;
}

.card-screen-label {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.card-header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.card-game-badge {
  font-size: 18px;
  line-height: 1;
}

.card-table-badge {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--accent-blue);
  padding: 2px 8px;
  min-width: 28px;
  text-align: center;
}

/* Card body */
.card-body {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* Settings grid */
.card-settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.card-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.card-field-wide {
  grid-column: 1 / -1;
}

.card-field-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.card-input,
.card-select {
  height: 38px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  padding: 0 10px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
  appearance: none;
}

.card-input:focus,
.card-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px var(--accent-blue-glow);
}

.card-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='rgba(255,255,255,0.4)' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

/* Card footer */
.card-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px 14px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.btn-reset-phone {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-reset-phone:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-launch-life {
  background: rgba(0, 230, 118, 0.1);
  color: var(--accent-green);
  border: 1px solid rgba(0, 230, 118, 0.3);
}

.btn-launch-life:hover {
  background: rgba(0, 230, 118, 0.18);
}

.btn-save-phone {
  margin-left: auto;
}

/* Card status bar */
.card-status-bar {
  min-height: 2px;
  background: transparent;
  transition: background 0.3s, min-height 0.2s;
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  letter-spacing: 0.04em;
  overflow: hidden;
}

.card-status-bar.success {
  min-height: 28px;
  background: rgba(0, 230, 118, 0.08);
  color: var(--accent-green);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 16px;
}

.card-status-bar.error {
  min-height: 28px;
  background: rgba(255, 82, 82, 0.08);
  color: var(--accent-red);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 16px;
}

/* ── Barcode drop zone ──────────────────────────────── */
.barcode-drop-zone {
  background: var(--bg-input);
  border: 1.5px dashed rgba(255,255,255,0.15);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
  min-height: 80px;
}

.barcode-drop-zone:hover,
.barcode-drop-zone.drag-over {
  border-color: var(--accent-blue);
  background: rgba(64, 196, 255, 0.05);
}

.barcode-drop-zone:focus {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

.drop-zone-idle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  pointer-events: none;
}

.drop-icon {
  font-size: 28px;
  opacity: 0.5;
  line-height: 1;
}

.drop-text {
  font-size: 12px;
  letter-spacing: 0.03em;
  text-align: center;
}

.drop-zone-preview {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  position: relative;
}

.barcode-preview-img {
  max-width: 100%;
  max-height: 100px;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

.barcode-clear-btn {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  background: var(--accent-red);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  z-index: 10;
}

.barcode-clear-btn:hover { background: #ef5350; }

.file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.btn-barcode-upload {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
  align-self: flex-start;
}

.btn-barcode-upload:not(:disabled):hover {
  background: var(--bg-hover);
  border-color: var(--accent-blue);
  color: var(--accent-blue);
}

.btn-barcode-upload:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ══════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ══════════════════════════════════════════════════════ */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
  pointer-events: none;
  max-width: 320px;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-primary);
  box-shadow: var(--shadow-elevated);
  pointer-events: auto;
  animation: toastIn 0.3s cubic-bezier(0.34, 1.3, 0.64, 1);
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast.success { border-color: rgba(0, 230, 118, 0.4); }
.toast.error   { border-color: rgba(255, 82, 82, 0.4); color: var(--accent-red); }
.toast.info    { border-color: rgba(64, 196, 255, 0.4); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px) scale(0.95); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0) scale(1); }
  to   { opacity: 0; transform: translateX(20px) scale(0.95); }
}

.toast.removing {
  animation: toastOut 0.25s ease forwards;
}

/* ── Utility ────────────────────────────────────────── */
.hidden { display: none !important; }

/* ══════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════ */

@media (max-width: 640px) {
  .bulk-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .bulk-select,
  .bulk-input {
    min-width: 0;
    width: 100%;
  }

  .bulk-group-row {
    flex-direction: row;
  }

  .phone-grid {
    grid-template-columns: 1fr;
  }

  .dash-header {
    padding: 0 14px;
  }

  .phone-grid-wrap {
    padding: 14px;
  }

  .toast-container {
    bottom: 16px;
    right: 16px;
    left: 16px;
    max-width: none;
  }
}

@media (min-width: 1200px) {
  .phone-grid {
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  }
}
