/* ====== Top Bar ====== */
.topbar {
  background: var(--color-bg-secondary);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--color-accent);
  letter-spacing: -0.02em;
}

.topbar-brand svg {
  width: 24px;
  height: 24px;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  color: var(--color-text-secondary);
}

/* ====== Buttons ====== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  line-height: 1.4;
}

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

.btn-primary {
  background: var(--color-accent);
  color: white;
}
.btn-primary:hover { background: var(--color-accent-hover); }

.btn-danger {
  background: var(--color-danger);
  color: white;
}
.btn-danger:hover { background: var(--color-danger-hover); }

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}
.btn-ghost:hover {
  background: var(--color-bg-card);
  color: var(--color-text-primary);
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  border-radius: var(--radius-sm);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon svg {
  width: 18px;
  height: 18px;
}

.btn-logout {
  background: transparent;
  color: var(--color-text-secondary);
  border: none;
  cursor: pointer;
  font-size: 0.8125rem;
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius-sm);
}
.btn-logout:hover {
  color: var(--color-danger);
  background: rgba(239, 68, 68, 0.1);
}

/* FAB */
.fab {
  position: fixed;
  bottom: 2.5rem;
  right: 1.5rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--color-accent);
  color: white;
  border: none;
  font-size: 1.75rem;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  z-index: 50;
}
.fab:hover {
  background: var(--color-accent-hover);
  transform: scale(1.05);
}

/* ====== Cards ====== */
.card {
  background: var(--color-bg-card);
  border-radius: var(--radius-md);
  padding: 1rem;
  box-shadow: var(--shadow-card);
  transition: all var(--transition-fast);
}

.flight-card {
  position: relative;
  background: var(--color-bg-secondary);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 0.75rem;
  border-left: 4px solid var(--color-border);
  transition: all var(--transition-fast);
}

.flight-card.status-keyed { border-left-color: var(--color-keyed); }
.flight-card.status-activated { border-left-color: var(--color-activated); }
.flight-card.status-overdue {
  border-left-color: var(--color-overdue);
  background: var(--color-overdue-bg);
  animation: pulse-red 2s infinite;
}
.flight-card.status-closed {
  border-left-color: var(--color-closed);
  opacity: 0.65;
}
.flight-card.status-not_flown {
  border-left-color: var(--color-not-flown);
  opacity: 0.65;
}

@keyframes pulse-red {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.3); }
  50% { box-shadow: 0 0 12px 4px rgba(239, 68, 68, 0.15); }
}

.flight-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.5rem;
}

.flight-card-time {
  font-family: var(--font-mono);
  font-size: 1.125rem;
  font-weight: 600;
}

.flight-card-route {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  margin-bottom: 0.25rem;
}

.flight-card-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem 1rem;
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  margin-bottom: 0.75rem;
}

.flight-card-details dt {
  color: var(--color-text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.flight-card-details dd {
  color: var(--color-text-primary);
  font-size: 0.875rem;
}

.flight-card-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ====== Status Badge ====== */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-badge.keyed {
  background: var(--color-keyed-bg);
  color: var(--color-keyed);
}
.status-badge.activated {
  background: var(--color-activated-bg);
  color: var(--color-activated);
}
.status-badge.overdue {
  background: var(--color-overdue-bg);
  color: var(--color-overdue);
  animation: blink 1s infinite;
}
.status-badge.closed {
  background: var(--color-closed-bg);
  color: var(--color-closed);
}
.status-badge.not_flown {
  background: var(--color-not-flown-bg);
  color: var(--color-not-flown);
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ====== Forms ====== */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  margin-bottom: 0.375rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.625rem 0.875rem;
  background: var(--color-bg-input);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-primary);
  font-size: 1rem;
  transition: border-color var(--transition-fast);
}

.modal input[type="text"].form-input {
  text-transform: uppercase;
}
.modal input[type="text"].form-input::placeholder {
  text-transform: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.5rem;
}

.form-textarea {
  min-height: 80px;
  resize: vertical;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  align-items: end;
}

.form-row > .form-group {
  margin-bottom: 0;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.form-actions .btn {
  flex: 1;
}

.other-input {
  margin-top: 0.5rem;
  display: none;
}

.other-input.visible {
  display: block;
}

/* ====== Modal ====== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--color-bg-modal);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--color-bg-secondary);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.5rem;
  transform: translateY(100%);
  transition: transform var(--transition-normal);
}

.modal-overlay.active .modal {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  cursor: pointer;
  font-size: 1.5rem;
  line-height: 1;
  padding: 0.25rem;
}
.modal-close:hover {
  color: var(--color-text-primary);
}

/* ====== Empty State ====== */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--color-text-muted);
}

.empty-state svg {
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  opacity: 0.4;
}

.empty-state h3 {
  font-size: 1.125rem;
  color: var(--color-text-secondary);
  margin-bottom: 0.5rem;
}

.empty-state p {
  font-size: 0.875rem;
}

/* ====== Delay Preview ====== */
.delay-preview {
  background: var(--color-bg-primary);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 1.25rem;
  border: 1px solid var(--color-border);
}

.delay-preview-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  justify-content: center;
}

.delay-preview-row + .delay-preview-row {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-border);
}

.delay-preview-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 80px;
}

.delay-preview-label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 0.25rem;
}

.delay-preview-time {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text-secondary);
}

.delay-preview-new {
  color: var(--color-accent);
}

.delay-preview-arrow {
  font-size: 1.25rem;
  color: var(--color-text-muted);
  margin-top: 0.75rem;
}

/* ====== Confirm Dialog ====== */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: var(--color-bg-modal);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-fast);
}

.confirm-overlay.active {
  opacity: 1;
  visibility: visible;
}

.confirm-dialog {
  background: var(--color-bg-secondary);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  max-width: 360px;
  width: 90%;
  text-align: center;
}

.confirm-dialog h3 {
  margin-bottom: 0.5rem;
}

.confirm-dialog p {
  color: var(--color-text-secondary);
  font-size: 0.875rem;
  margin-bottom: 1.25rem;
}

.confirm-actions {
  display: flex;
  gap: 0.75rem;
}

.confirm-actions .btn {
  flex: 1;
}

@media (min-width: 768px) {
  .modal {
    border-radius: var(--radius-xl);
    margin: auto;
    max-height: 85vh;
  }

  .modal-overlay {
    align-items: center;
  }
}

/* ====== App Footer ====== */
.app-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  text-align: center;
  padding: 0.4rem 1rem;
  font-size: 0.65rem;
  color: var(--color-text-muted);
  opacity: 0.5;
  pointer-events: none;
  z-index: 0;
}

/* ====== ETA Quick Add Buttons ====== */
.eta-quick-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 0.25rem;
  margin-bottom: 0.5rem;
}
.eta-quick-btns {
  display: flex;
  gap: 0.25rem;
}
.btn-eta-quick {
  flex: 1;
  padding: 0.2rem 0.4rem;
  font-size: 0.7rem;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}
.btn-eta-quick:hover {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

/* ====== Instrument Approach Rows ====== */
.ia-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}
.ia-row .dropdown-with-other {
  flex: 1;
}
#ia-section, #oia-section {
  margin-top: 0.5rem;
  padding: 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}

/* ====== Flight Detail Popup (styled) ====== */
.detail-modal {
  max-width: 520px;
  padding: 0;
  overflow: hidden;
}
.detail-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 10;
  background: rgba(0,0,0,0.3);
  border: none;
  color: #fff;
  font-size: 1.4rem;
  line-height: 1;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.detail-close:hover {
  background: rgba(0,0,0,0.5);
}

/* Gradient header — status-aware */
.detail-header {
  position: relative;
  padding: 1.5rem 1.25rem 1.25rem;
  text-align: center;
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
}
.detail-header .status-badge {
  margin-bottom: 0.5rem;
}
.detail-header-keyed {
  background: linear-gradient(135deg, #064e3b 0%, #0d9488 50%, #14b8a6 100%);
}
.detail-header-activated {
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 50%, #3b82f6 100%);
}
.detail-header-overdue {
  background: linear-gradient(135deg, #7f1d1d 0%, #dc2626 50%, #ef4444 100%);
}
.detail-header-closed {
  background: linear-gradient(135deg, #1f2937 0%, #4b5563 50%, #6b7280 100%);
}
.detail-header-not_flown {
  background: linear-gradient(135deg, #78350f 0%, #d97706 50%, #f59e0b 100%);
}
.detail-header-aircraft {
  font-size: 1.75rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.04em;
  margin-top: 0.35rem;
}
.detail-header-type {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.7);
  margin-top: 0.15rem;
}
.detail-header-time {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 600;
  color: #fff;
  margin-top: 0.75rem;
  background: rgba(0,0,0,0.2);
  display: inline-block;
  padding: 0.3rem 1rem;
  border-radius: 999px;
}
.detail-header-date {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.5);
  margin-top: 0.5rem;
}

/* Detail body & sections */
.detail-body {
  padding: 1rem 1.25rem 1.5rem;
}
.detail-section {
  background: var(--color-bg-primary);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  border-left: 3px solid var(--color-accent);
}
.detail-section:nth-child(2) {
  border-left-color: var(--color-success);
}
.detail-section:nth-child(3) {
  border-left-color: var(--color-warning);
}
.detail-section:nth-child(4) {
  border-left-color: var(--color-text-muted);
}
.detail-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}
.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.3rem 0;
}
.detail-row + .detail-row {
  border-top: 1px solid var(--color-border);
}
.detail-label {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
}
.detail-value {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text-primary);
}
.detail-approaches {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text-primary);
  letter-spacing: 0.02em;
}
.detail-notes {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  line-height: 1.5;
}
