/* ================================================================
   SurgeAI Portal — Shared Stylesheet
   Uses the same design tokens as the marketing site.
   ================================================================ */

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

:root {
  --navy:       #0A1628;
  --navy-light: #0e1b30;
  --navy-mid:   #132240;
  --navy-soft:  #1a2d4a;
  --white:      #FFFFFF;
  --accent:     #F27024;
  --accent-dim: #D9631E;
  --accent-deep:#C05518;
  --accent-glow:rgba(242,112,36,0.15);
  --cream:      #f5f5f0;
  --warm-gray:  #eae8e2;
  --gray-100:   #e0dfd9;
  --gray-200:   #cbc9c2;
  --gray-400:   #7d7b74;
  --gray-500:   #5c5a54;
  --gray-600:   #45433e;
  --text-dark:  #111111;
  --font-display: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  --font-body:    'DM Sans', system-ui, -apple-system, sans-serif;
  --sidebar-w:  260px;
  --header-h:   64px;
  --ease:       cubic-bezier(0.16,1,0.3,1);
  --radius:     12px;
  --radius-sm:  8px;
  --shadow:     0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.08);
}

html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  color: var(--text-dark);
  background: #f0f0ec;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

#app {
  display: flex;
  min-height: 100vh;
}

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

.sidebar-top {
  padding: 24px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.sidebar-logo-mark {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.sidebar-logo-mark::after {
  content: '\2713';
  color: var(--navy);
  font-size: 16px;
  font-weight: 700;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.sidebar-logo-text {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--white);
  letter-spacing: -0.5px;
}

.sidebar-role-badge {
  display: inline-block;
  margin-top: 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--accent);
  background: rgba(242,112,36,0.1);
  padding: 4px 10px;
  border-radius: 20px;
}

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

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.55);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
  margin-bottom: 2px;
  border: none;
  background: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  font-family: var(--font-body);
}

.sidebar-link:hover {
  color: rgba(255,255,255,0.9);
  background: rgba(255,255,255,0.06);
}

.sidebar-link.active {
  color: var(--white);
  background: rgba(242,112,36,0.15);
}
.sidebar-link.active .sidebar-icon {
  color: var(--accent);
}

.sidebar-icon {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

/* ── Sidebar bottom ───────────────────────────────── */
.sidebar-bottom {
  padding: 16px 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  margin-bottom: 8px;
}

.sidebar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--navy-soft);
  color: var(--accent);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 2px solid rgba(242,112,36,0.3);
}

.sidebar-user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.85);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-email {
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-signout {
  color: rgba(255,255,255,0.4) !important;
}
.sidebar-signout:hover {
  color: #ff6b6b !important;
  background: rgba(255,107,107,0.08) !important;
}

/* ── Main area ────────────────────────────────────── */
.portal-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ───────────────────────────────────────── */
.portal-header {
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 50;
}

.portal-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.3px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-greeting {
  font-size: 14px;
  color: var(--gray-500);
  font-weight: 500;
}

.header-howto-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  background: rgba(242, 112, 36, 0.08);
  padding: 6px 14px;
  border-radius: 6px;
  text-decoration: none;
  transition: background 0.2s;
}
.header-howto-btn:hover {
  background: rgba(242, 112, 36, 0.15);
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--navy);
  padding: 4px;
}

/* ── Content ──────────────────────────────────────── */
.portal-content {
  flex: 1;
  padding: 32px;
  min-width: 0;
  overflow-x: hidden;
}

/* ── Cards ────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  border: 1px solid rgba(0,0,0,0.04);
}

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

.card-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--navy);
}

/* ── Stat cards ───────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(0,0,0,0.04);
}

.stat-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--gray-400);
  margin-bottom: 8px;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.5px;
}

.stat-sub {
  font-size: 13px;
  color: var(--gray-400);
  margin-top: 4px;
}

/* ── Tables ───────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

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

.portal-table thead th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--gray-400);
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--gray-100);
  white-space: nowrap;
}

.portal-table tbody td {
  padding: 14px 16px;
  font-size: 14px;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  color: var(--text-dark);
}

.portal-table tbody tr:hover {
  background: rgba(0,0,0,0.015);
}

/* ── Badges / Status ──────────────────────────────── */
.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 0.2px;
}
.badge-active, .badge-succeeded {
  color: #15803d;
  background: #dcfce7;
}
.badge-pending, .badge-scheduled {
  color: #a16207;
  background: #fef9c3;
}
.badge-cancelled, .badge-failed {
  color: #b91c1c;
  background: #fee2e2;
}
.badge-completed {
  color: #1d4ed8;
  background: #dbeafe;
}

/* ── Buttons ──────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  border: none;
  line-height: 1;
}

.btn-primary {
  background: var(--accent);
  color: var(--white);
}
.btn-primary:hover {
  background: var(--accent-dim);
}
.btn-primary:active {
  background: var(--accent-deep);
}
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--white);
  color: var(--navy);
  border: 1px solid var(--gray-200);
}
.btn-secondary:hover {
  background: var(--cream);
  border-color: var(--gray-400);
}

.btn-ghost {
  background: transparent;
  color: var(--gray-500);
}
.btn-ghost:hover {
  background: rgba(0,0,0,0.04);
  color: var(--text-dark);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
}

/* ── Forms ────────────────────────────────────────── */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 6px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text-dark);
  background: var(--white);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  outline: none;
}

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

.form-input::placeholder {
  color: var(--gray-400);
}

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

.form-error {
  font-size: 13px;
  color: #dc2626;
  margin-top: 4px;
}

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

/* ── Empty state ──────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}
.empty-state-icon {
  width: 56px;
  height: 56px;
  background: var(--accent-glow);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  color: var(--accent);
}
.empty-state-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 8px;
}
.empty-state-text {
  font-size: 14px;
  color: var(--gray-400);
  max-width: 360px;
  margin: 0 auto;
}

/* ── Toasts ───────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  transform: translateX(110%);
  transition: transform 0.3s var(--ease);
  max-width: 380px;
}

.toast-show {
  transform: translateX(0);
}

.toast-info {
  background: var(--navy);
  color: var(--white);
}
.toast-success {
  background: #15803d;
  color: var(--white);
}
.toast-error {
  background: #dc2626;
  color: var(--white);
}
.toast-warning {
  background: #a16207;
  color: var(--white);
}

.toast-close {
  background: none;
  border: none;
  color: inherit;
  opacity: 0.6;
  cursor: pointer;
  font-size: 18px;
  padding: 0 2px;
  line-height: 1;
}
.toast-close:hover { opacity: 1; }

/* ── Loading spinner ──────────────────────────────── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}
.spinner-dark {
  border-color: var(--gray-200);
  border-top-color: var(--accent);
}

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

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

/* ── Login page specific ──────────────────────────── */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--white);
  border-radius: 16px;
  padding: 40px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  margin-bottom: 8px;
}

.login-logo-mark {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.login-logo-mark::after {
  content: '\2713';
  color: var(--navy);
  font-size: 18px;
  font-weight: 700;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.login-logo-text {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.5px;
}

.login-subtitle {
  text-align: center;
  font-size: 14px;
  color: var(--gray-500);
  margin-bottom: 32px;
}

.login-footer {
  text-align: center;
  margin-top: 24px;
}

.login-footer a {
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}
.login-footer a:hover {
  text-decoration: underline;
}

.login-alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 20px;
  display: none;
}
.login-alert-error {
  background: #fee2e2;
  color: #b91c1c;
}
.login-alert-success {
  background: #dcfce7;
  color: #15803d;
}
.login-alert.show {
  display: block;
}

/* ── Dashboard coming-soon placeholder ────────────── */
.placeholder-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
  text-align: center;
}
.placeholder-icon {
  width: 80px;
  height: 80px;
  background: var(--accent-glow);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}
.placeholder-icon svg {
  width: 36px;
  height: 36px;
  color: var(--accent);
}
.placeholder-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 8px;
}
.placeholder-text {
  font-size: 15px;
  color: var(--gray-400);
  max-width: 400px;
}

/* ── Responsive ───────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay.open {
    display: block;
  }

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

  .portal-header {
    padding: 0 16px;
  }

  .mobile-menu-btn {
    display: flex;
  }

  .portal-content {
    padding: 20px 16px;
  }

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

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

  .login-card {
    padding: 32px 24px;
  }

  .header-greeting {
    display: none;
  }
}

@media (max-width: 480px) {
  .portal-content {
    padding: 16px 12px;
  }
  .card {
    padding: 16px;
  }
}
