/* =============================================================================
   MigrateMate — Premium SaaS Portal Stylesheet
   ============================================================================= */

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

:root {
  --bg-dark: #0d1117;
  --bg-card: #161b22;
  --bg-hover: #1c2333;
  --border: #30363d;
  --primary: #2563eb;
  --primary-h: #1d4ed8;
  --primary-glow: rgba(37, 99, 235, .25);
  --accent: #06b6d4;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --text-1: #f0f6fc;
  --text-2: #8b949e;
  --text-3: #656d76;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 4px 24px rgba(0, 0, 0, .4);
  --transition: .18s ease;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-dark);
  color: var(--text-1);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* ── Typography ── */
h1 {
  font-size: 2rem;
  font-weight: 800;
}

h2 {
  font-size: 1.5rem;
  font-weight: 700;
}

h3 {
  font-size: 1.125rem;
  font-weight: 600;
}

small {
  font-size: .8125rem;
  color: var(--text-2);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .55rem 1.25rem;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 0 0 0 var(--primary-glow);
}

.btn-primary:hover {
  background: var(--primary-h);
  box-shadow: 0 0 0 4px var(--primary-glow);
}

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border-color: var(--border);
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-1);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-sm {
  padding: .35rem .9rem;
  font-size: .8125rem;
}

.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn .spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, .3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* ── Inputs ── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: .4rem;
}

.form-group label {
  font-size: .8125rem;
  font-weight: 500;
  color: var(--text-2);
}

.input {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  color: var(--text-1);
  border-radius: var(--radius);
  padding: .6rem .9rem;
  font-size: .9375rem;
  width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  font-family: inherit;
}

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

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

select.input {
  appearance: none;
  cursor: pointer;
}

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

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

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .65rem;
  border-radius: 99px;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-active {
  color: var(--success);
  background: rgba(16, 185, 129, .12);
}

.badge-draft {
  color: var(--text-2);
  background: rgba(139, 148, 158, .12);
}

.badge-paused {
  color: var(--warning);
  background: rgba(245, 158, 11, .12);
}

.badge-failed {
  color: var(--danger);
  background: rgba(239, 68, 68, .12);
}

.badge-completed {
  color: var(--accent);
  background: rgba(6, 182, 212, .12);
}

.badge-ok {
  color: var(--success);
  background: rgba(16, 185, 129, .12);
}

.badge-error {
  color: var(--danger);
  background: rgba(239, 68, 68, .12);
}

/* ── Tables ── */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

thead tr {
  border-bottom: 1px solid var(--border);
}

th {
  padding: .65rem 1rem;
  text-align: left;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .05em;
}

td {
  padding: .75rem 1rem;
  border-bottom: 1px solid rgba(48, 54, 61, .5);
}

tbody tr {
  transition: background var(--transition);
}

tbody tr:hover {
  background: var(--bg-hover);
}

tbody tr:last-child td {
  border-bottom: none;
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  backdrop-filter: blur(4px);
  animation: fadeIn .15s ease;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 100%;
  max-width: 520px;
  animation: slideUp .2s ease;
  box-shadow: var(--shadow);
}

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

.modal-close {
  background: none;
  border: none;
  color: var(--text-2);
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-1);
}

.modal-footer {
  display: flex;
  gap: .75rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
}

/* ── Toast ── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: .6rem;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: .8rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .85rem 1.2rem;
  font-size: .875rem;
  font-weight: 500;
  min-width: 260px;
  box-shadow: var(--shadow);
  animation: slideLeft .25s ease;
  pointer-events: auto;
}

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

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

.toast-info {
  border-left: 3px solid var(--accent);
}

.toast-icon {
  font-size: 1.1rem;
}

/* ── Sidebar Layout ── */
#shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: 1.5rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
}

.logo-icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.logo-text {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -.01em;
}

.logo-text span {
  color: var(--accent);
}

.sidebar-nav {
  padding: .75rem .75rem;
  flex: 1;
}

.nav-section {
  margin-bottom: 1.5rem;
}

.nav-section-title {
  font-size: .65rem;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .1em;
  padding: 0 .6rem;
  margin-bottom: .4rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .55rem .7rem;
  border-radius: 8px;
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-1);
}

.nav-item.active {
  background: rgba(37, 99, 235, .18);
  color: var(--primary);
}

.nav-item .nav-icon {
  font-size: 1rem;
  width: 18px;
  text-align: center;
}

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

.user-chip {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .6rem .7rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--transition);
}

.user-chip:hover {
  background: var(--bg-hover);
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .85rem;
  font-weight: 700;
  flex-shrink: 0;
}

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

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

.user-role {
  font-size: .7rem;
  color: var(--text-2);
}

/* ── Main content ── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-title {
  font-size: 1.125rem;
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  gap: .75rem;
  align-items: center;
}

.page {
  padding: 2rem;
  flex: 1;
  animation: fadeIn .2s ease;
}

/* ── Stats grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition), transform var(--transition);
}

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

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

.stat-label {
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: .5rem;
}

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -.03em;
}

.stat-sub {
  font-size: .75rem;
  color: var(--text-2);
  margin-top: .25rem;
}

.stat-icon {
  position: absolute;
  right: 1.25rem;
  top: 1.25rem;
  font-size: 1.75rem;
  opacity: .15;
}

/* ── Auth pages ── */
#auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-dark);
  background-image: radial-gradient(ellipse 70% 50% at 50% -20%, rgba(37, 99, 235, .15), transparent);
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}

.auth-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-logo .logo-icon {
  width: 48px;
  height: 48px;
  font-size: 1.5rem;
  margin: 0 auto .75rem;
}

.auth-logo h2 {
  margin-bottom: .25rem;
}

.auth-logo p {
  color: var(--text-2);
  font-size: .875rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.auth-divider {
  text-align: center;
  color: var(--text-3);
  font-size: .8125rem;
  position: relative;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 42%;
  height: 1px;
  background: var(--border);
}

.auth-divider::before {
  left: 0;
}

.auth-divider::after {
  right: 0;
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-2);
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: .4;
}

.empty-state h3 {
  color: var(--text-1);
  margin-bottom: .5rem;
}

.empty-state p {
  font-size: .875rem;
  margin-bottom: 1.5rem;
}

/* ── Progress bar ── */
.progress-bar {
  background: var(--border);
  border-radius: 99px;
  height: 6px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 99px;
  transition: width .5s ease;
}

/* ── Alerts ── */
.alert {
  padding: .875rem 1rem;
  border-radius: var(--radius);
  font-size: .875rem;
  display: flex;
  gap: .75rem;
  align-items: flex-start;
}

.alert-danger {
  background: rgba(239, 68, 68, .1);
  border: 1px solid rgba(239, 68, 68, .3);
  color: #fca5a5;
}

.alert-info {
  background: rgba(6, 182, 212, .1);
  border: 1px solid rgba(6, 182, 212, .3);
  color: #67e8f9;
}

/* ── Pill tabs ── */
.tabs {
  display: flex;
  gap: .25rem;
  background: var(--bg-dark);
  border-radius: var(--radius);
  padding: .25rem;
  border: 1px solid var(--border);
}

.tab {
  padding: .45rem 1rem;
  border-radius: 8px;
  font-size: .8125rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-2);
  transition: all var(--transition);
  border: none;
  background: none;
}

.tab.active {
  background: var(--primary);
  color: #fff;
}

.tab:hover:not(.active) {
  color: var(--text-1);
  background: var(--bg-hover);
}

/* ── Chip ── */
.chip {
  display: inline-flex;
  align-items: center;
  padding: .25rem .75rem;
  background: var(--bg-hover);
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-2);
  border: 1px solid var(--border);
}

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

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideLeft {
  from {
    transform: translateX(30px);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ── Loading state ── */
.loading-state {
  color: var(--text-2);
  padding: 2.5rem;
  text-align: center;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar {
    display: none;
  }

  .page {
    padding: 1rem;
  }

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