/* ===========================================
   WalkEEG - Data Portal (App) Styles
   =========================================== */

/* ===== Auth Pages ===== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px;
}

.auth-card .navbar-brand {
  justify-content: center;
  margin-bottom: 32px;
  font-size: 1.5rem;
}

.auth-card h1 {
  font-size: 1.5rem;
  font-weight: 800;
  text-align: center;
  margin-bottom: 8px;
}

.auth-card p.subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9375rem;
  margin-bottom: 32px;
}

/* ===== Form Elements ===== */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-dark);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.9375rem;
  font-family: var(--font-sans);
  transition: border-color 0.2s;
  outline: none;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-input::placeholder { color: var(--text-muted); }

.form-hint {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-error {
  font-size: 0.8125rem;
  color: var(--danger);
  margin-top: 4px;
  display: none;
}

.form-error.visible { display: block; }

.form-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 28px;
}

.form-footer {
  text-align: center;
  margin-top: 24px;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.form-footer a { color: var(--primary-light); }

.btn-full { width: 100%; justify-content: center; }

/* ===== App Layout ===== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.app-sidebar {
  width: 260px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.app-sidebar-brand {
  padding: 0 20px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.app-sidebar-brand a {
  font-size: 1.125rem;
  font-weight: 800;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-nav {
  flex: 1;
  padding: 0 12px;
}

.app-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  margin-bottom: 2px;
}

.app-nav-item:hover {
  background: rgba(99, 102, 241, 0.08);
  color: var(--text-primary);
}

.app-nav-item.active {
  background: rgba(99, 102, 241, 0.15);
  color: var(--primary-light);
}

.app-nav-item .nav-icon { font-size: 1.125rem; }

.app-sidebar-footer {
  padding: 16px 20px 0;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.app-sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
}

.user-avatar {
  width: 36px;
  height: 36px;
  background: var(--gradient-1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.875rem;
  color: white;
}

.user-info h4 { font-size: 0.875rem; font-weight: 600; }
.user-info p { font-size: 0.75rem; color: var(--text-muted); }

/* ===== App Main ===== */
.app-main {
  flex: 1;
  padding: 32px;
  overflow-y: auto;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}

.app-header h1 {
  font-size: 1.75rem;
  font-weight: 800;
}

.app-header p {
  color: var(--text-secondary);
  font-size: 0.9375rem;
}

/* ===== Stats Cards ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.stat-card h3 {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
}

.stat-card .stat-change {
  font-size: 0.8125rem;
  margin-top: 4px;
}

.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ===== Data Table ===== */
.data-table-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.data-table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.data-table-header h2 {
  font-size: 1.125rem;
  font-weight: 700;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  padding: 12px 24px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: rgba(15, 23, 42, 0.5);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 14px 24px;
  font-size: 0.9375rem;
  border-bottom: 1px solid var(--border);
}

.data-table tr:last-child td { border-bottom: none; }

.data-table tr:hover td { background: rgba(99, 102, 241, 0.04); }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-badge.processed { background: rgba(34, 197, 94, 0.1); color: var(--success); }
.status-badge.pending { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.status-badge.uploading { background: rgba(99, 102, 241, 0.1); color: var(--primary-light); }

/* ===== Upload Area ===== */
.upload-area {
  border: 2px dashed var(--border-light);
  border-radius: var(--radius-lg);
  padding: 60px 32px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  margin-bottom: 24px;
}

.upload-area:hover,
.upload-area.dragover {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.05);
}

.upload-area .upload-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.6;
}

.upload-area h3 {
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.upload-area p {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 4px;
}

.upload-progress {
  margin-top: 20px;
  display: none;
}

.upload-progress.active { display: block; }

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 100px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-bar-fill {
  height: 100%;
  background: var(--gradient-1);
  border-radius: 100px;
  transition: width 0.3s;
  width: 0;
}

.upload-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* ===== Signal Viewer ===== */
.signal-viewer {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 24px;
}

.signal-viewer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}

.signal-viewer-header h2 {
  font-size: 1.0625rem;
  font-weight: 700;
}

.signal-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.signal-canvas-wrapper {
  padding: 24px;
  height: 400px;
  position: relative;
}

.signal-canvas-wrapper canvas {
  width: 100% !important;
  height: 100% !important;
}

.signal-info-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  padding: 20px 24px;
  border-top: 1px solid var(--border);
}

.signal-info-item label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.signal-info-item span {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 60px 24px;
}

.empty-state .empty-icon {
  font-size: 4rem;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state h3 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--text-muted);
  margin-bottom: 24px;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 32px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.modal p {
  color: var(--text-secondary);
  font-size: 0.9375rem;
  margin-bottom: 24px;
}

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 14px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.9375rem;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toast-in 0.3s ease;
  max-width: 400px;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--primary); }

@keyframes toast-in {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast-removing {
  animation: toast-out 0.3s ease forwards;
}

@keyframes toast-out {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(100%); opacity: 0; }
}

/* ===== Page Sections ===== */
.app-page { display: none; }
.app-page.active { display: block; }

/* ===== Loading Spinner ===== */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto;
}

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

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .signal-info-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .app-layout { flex-direction: column; }
  .app-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 16px 0;
  }
  .app-sidebar-brand { padding-bottom: 16px; }
  .app-nav { display: flex; overflow-x: auto; padding: 0 16px; gap: 4px; }
  .app-nav-item { white-space: nowrap; }
  .app-main { padding: 24px 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .data-table-wrapper { overflow-x: auto; }
}

/* ===== Confirm Dialog ===== */
.confirm-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* ===== Hidden ===== */
.hidden { display: none !important; }
