/* ========== CSS Variables & Reset ========== */
:root {
  --navy-dark: #0a0e1a;
  --navy: #0f1629;
  --navy-light: #161d35;
  --navy-lighter: #1e2746;
  --cyan: #00d4ff;
  --cyan-glow: rgba(0, 212, 255, 0.3);
  --orange: #ff6b35;
  --orange-glow: rgba(255, 107, 53, 0.3);
  --purple: #a855f7;
  --purple-glow: rgba(168, 85, 247, 0.3);
  --green: #22c55e;
  --green-glow: rgba(34, 197, 94, 0.3);
  --red: #ef4444;
  --red-glow: rgba(239, 68, 68, 0.3);
  --pink: #ec4899;
  --yellow: #facc15;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: rgba(255, 255, 255, 0.08);
  --border-light: rgba(255, 255, 255, 0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --sidebar-width: 260px;
  --header-height: 64px;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--navy-dark);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }

/* ========== Auth Pages (Login/Signup) ========== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.auth-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.gradient-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.4;
  animation: float 8s ease-in-out infinite;
}

.orb-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, var(--cyan-glow), transparent 70%);
  top: -150px;
  right: -100px;
}

.orb-2 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, var(--orange-glow), transparent 70%);
  bottom: -100px;
  left: -100px;
  animation-delay: -3s;
}

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-20px) rotate(3deg); }
}

.auth-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  background: var(--navy);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo a {
  font-size: 1.6rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.logo-icon { color: var(--cyan); font-size: 1.3rem; }
.logo-accent { color: var(--cyan); }

.auth-title {
  font-size: 1.3rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 8px;
}

.auth-subtitle {
  color: var(--text-secondary);
  text-align: center;
  font-size: 0.9rem;
  margin-bottom: 28px;
}

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

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

.form-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

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

.form-input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px var(--cyan-glow);
}

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

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 12px 28px;
  border-radius: 50px;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--cyan), #0090ff);
  color: var(--navy-dark);
  box-shadow: 0 4px 20px var(--cyan-glow);
}

.btn-primary:hover {
  box-shadow: 0 6px 30px rgba(0, 212, 255, 0.5);
  transform: translateY(-2px);
}

.btn-block { width: 100%; }

.btn-lg { padding: 14px 36px; font-size: 1rem; }

.btn-secondary {
  background: var(--navy-lighter);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--cyan);
  color: var(--cyan);
}

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

.btn-sm {
  padding: 8px 16px;
  font-size: 0.85rem;
}

.auth-footer {
  text-align: center;
  margin-top: 24px;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.auth-footer a {
  color: var(--cyan);
  font-weight: 500;
}

.auth-footer a:hover { text-decoration: underline; }

.auth-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  color: var(--red);
  font-size: 0.85rem;
  display: none;
}

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

.auth-success {
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  color: var(--green);
  font-size: 0.85rem;
  display: none;
}

.auth-success.visible { display: block; }

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

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--navy);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-logo {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo a {
  font-size: 1.3rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}

.sidebar-section {
  margin-bottom: 24px;
}

.sidebar-section-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0 12px;
  margin-bottom: 8px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
}

.sidebar-link:hover {
  background: var(--navy-light);
  color: var(--text-primary);
}

.sidebar-link.active {
  background: rgba(0, 212, 255, 0.08);
  color: var(--cyan);
}

.sidebar-link svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s;
}

.sidebar-user:hover { background: var(--navy-light); }

.sidebar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: white;
  flex-shrink: 0;
}

.sidebar-user-info { flex: 1; min-width: 0; }

.sidebar-user-name {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-email {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Main Content Area */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

.main-header {
  height: var(--header-height);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  background: var(--navy-dark);
  position: sticky;
  top: 0;
  z-index: 50;
}

.main-header-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.main-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.main-body {
  padding: 32px;
}

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

.stat-card {
  background: var(--navy);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: all 0.3s;
}

.stat-card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
}

.stat-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 8px;
}

.stat-value.cyan { color: var(--cyan); }
.stat-value.orange { color: var(--orange); }
.stat-value.green { color: var(--green); }
.stat-value.purple { color: var(--purple); }

.stat-change {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.stat-change.up { color: var(--green); }
.stat-change.down { color: var(--red); }

/* ========== Data Tables ========== */
.card {
  background: var(--navy);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

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

.card-title {
  font-size: 1rem;
  font-weight: 700;
}

.card-body { padding: 24px; }
.card-body.no-padding { padding: 0; }

.table-wrapper { overflow-x: auto; }

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

.data-table th {
  text-align: left;
  padding: 12px 24px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

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

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

.data-table tr:hover td { background: var(--navy-light); }

/* ========== Badges ========== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-cyan {
  background: rgba(0, 212, 255, 0.1);
  color: var(--cyan);
}

.badge-orange {
  background: rgba(255, 107, 53, 0.1);
  color: var(--orange);
}

.badge-green {
  background: rgba(34, 197, 94, 0.1);
  color: var(--green);
}

.badge-yellow {
  background: rgba(250, 204, 21, 0.1);
  color: var(--yellow);
}

.badge-red {
  background: rgba(239, 68, 68, 0.1);
  color: var(--red);
}

.badge-purple {
  background: rgba(168, 85, 247, 0.1);
  color: var(--purple);
}

/* ========== Score Circle ========== */
.score-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.9rem;
}

.score-high {
  background: rgba(34, 197, 94, 0.15);
  color: var(--green);
  border: 2px solid var(--green);
}

.score-mid {
  background: rgba(250, 204, 21, 0.15);
  color: var(--yellow);
  border: 2px solid var(--yellow);
}

.score-low {
  background: rgba(239, 68, 68, 0.15);
  color: var(--red);
  border: 2px solid var(--red);
}

/* ========== Upload Area ========== */
.upload-tabs {
  display: flex;
  gap: 4px;
  background: var(--navy-dark);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 24px;
}

.upload-tab {
  flex: 1;
  padding: 10px 16px;
  border-radius: var(--radius-xs);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.2s;
}

.upload-tab:hover { color: var(--text-primary); }

.upload-tab.active {
  background: var(--navy-lighter);
  color: var(--cyan);
}

.upload-panel { display: none; }
.upload-panel.active { display: block; }

.upload-dropzone {
  border: 2px dashed var(--border-light);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
}

.upload-dropzone:hover {
  border-color: var(--cyan);
  background: rgba(0, 212, 255, 0.03);
}

.upload-dropzone.dragover {
  border-color: var(--cyan);
  background: rgba(0, 212, 255, 0.05);
}

.upload-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  color: var(--text-muted);
}

.upload-text {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.upload-text span { color: var(--cyan); font-weight: 600; }

.upload-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.upload-form-fields {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 24px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

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

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

.progress-bar {
  height: 6px;
  background: var(--navy-dark);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--purple));
  border-radius: 3px;
  width: 0%;
  transition: width 0.3s;
}

.progress-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}

/* Plaud Setup */
.plaud-setup {
  text-align: center;
  padding: 32px 0;
}

.plaud-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  background: rgba(0, 212, 255, 0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.plaud-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.plaud-description {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 24px;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

.webhook-url-box {
  background: var(--navy-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 600px;
  margin: 0 auto 16px;
}

.webhook-url-box code {
  flex: 1;
  font-size: 0.85rem;
  color: var(--cyan);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.webhook-url-box button {
  background: var(--navy-lighter);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 6px 14px;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.webhook-url-box button:hover {
  border-color: var(--cyan);
  color: var(--cyan);
}

.plaud-steps {
  text-align: left;
  max-width: 500px;
  margin: 24px auto 0;
}

.plaud-step {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.plaud-step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 212, 255, 0.1);
  color: var(--cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
}

.plaud-step-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
  padding-top: 3px;
}

/* Transcript textarea */
.transcript-textarea {
  background: var(--navy-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.9rem;
  width: 100%;
  min-height: 200px;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
}

.transcript-textarea:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px var(--cyan-glow);
}

/* ========== Empty State ========== */
.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--text-muted);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 0.85rem;
  margin-bottom: 20px;
}

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

.toast {
  background: var(--navy);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 20px;
  font-size: 0.9rem;
  color: var(--text-primary);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  animation: slideIn 0.3s ease;
  min-width: 280px;
}

.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.info { border-left: 3px solid var(--cyan); }

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

/* ========== Mobile Responsive ========== */
.mobile-sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 4px;
}

.mobile-sidebar-toggle svg { width: 24px; height: 24px; }

@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open { transform: translateX(0); }

  .main-content { margin-left: 0; }

  .mobile-sidebar-toggle { display: flex; }

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

  .form-row { grid-template-columns: 1fr; }

  .auth-card { padding: 28px 20px; }

  .main-body { padding: 20px; }

  .main-header { padding: 0 20px; }

  .upload-tabs { flex-direction: column; }
}

/* ========== Sidebar Overlay (Mobile) ========== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
}

.sidebar-overlay.visible { display: block; }

/* ========== Loading Spinner ========== */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.btn .spinner {
  width: 16px;
  height: 16px;
}

.btn.loading {
  pointer-events: none;
  opacity: 0.7;
}
