/* ==========================================================================
   Vyben Cloud Portal - Design System
   Light Theme - Matching vyben.app Landing Page
   ========================================================================== */

:root {
  /* === BACKGROUNDS - Warm Light Foundation === */
  --bg-root: #f8f7f4; /* Warm off-white (Cursor-like) */
  --bg-default: #ffffff; /* White cards */
  --bg-secondary: #efede8; /* Soft beige/gray */
  --bg-tertiary: #e8e6e0; /* Slightly darker beige */
  --bg-glass: rgba(255, 255, 255, 0.7);
  --bg-overlay: rgba(0, 0, 0, 0.4);

  /* === TEXT - Dark on Light === */
  --text-primary: #1a1a1a; /* Charcoal, not pure black */
  --text-secondary: #6b6b6b; /* Medium gray */
  --text-tertiary: #9ca3af; /* Light gray / muted */
  --text-inverse: #ffffff; /* White text on dark backgrounds */

  /* === ACCENTS === */
  --accent-primary: #10b981; /* Green - primary actions */
  --accent-primary-hover: #059669;
  --accent-primary-muted: rgba(16, 185, 129, 0.1);
  --accent-secondary: #3b82f6; /* Blue - links */
  --accent-secondary-hover: #2563eb;
  --accent-secondary-muted: rgba(59, 130, 246, 0.1);

  /* === SEMANTIC COLORS === */
  --color-success: #10b981;
  --color-success-muted: rgba(16, 185, 129, 0.1);
  --color-warning: #f59e0b;
  --color-warning-muted: rgba(245, 158, 11, 0.1);
  --color-error: #ef4444;
  --color-error-muted: rgba(239, 68, 68, 0.1);
  --color-info: #3b82f6;
  --color-info-muted: rgba(59, 130, 246, 0.1);

  /* === BORDERS === */
  --border-default: rgba(0, 0, 0, 0.08);
  --border-hover: rgba(0, 0, 0, 0.12);
  --border-focus: #10b981;
  --border-divider: rgba(0, 0, 0, 0.06);

  /* === TYPOGRAPHY === */
  --font-sans:
    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono:
    "JetBrains Mono", "SF Mono", "Fira Code", SFMono-Regular, Menlo, Monaco,
    Consolas, monospace;

  /* === SPACING (8px base grid) === */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;

  /* === BORDER RADIUS === */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* === SHADOWS === */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md:
    0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-lg:
    0 10px 15px -3px rgba(0, 0, 0, 0.06), 0 4px 6px -2px rgba(0, 0, 0, 0.03);
  --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.04);
  --shadow-modal:
    0 20px 50px -10px rgba(0, 0, 0, 0.15), 0 0 1px rgba(0, 0, 0, 0.1);
  --glow-focus: 0 0 0 2px var(--bg-root), 0 0 0 4px var(--accent-primary);

  /* === TRANSITIONS === */
  --duration-fast: 100ms;
  --duration-normal: 200ms;
  --duration-slow: 300ms;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ==========================================================================
   Base Styles
   ========================================================================== */

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

body {
  font-family: var(--font-sans);
  background: var(--bg-root);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   Typography
   ========================================================================== */

h1,
h2,
h3,
h4 {
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--text-primary);
  margin-bottom: var(--space-3);
}

h1 {
  font-size: 2.25rem;
}

h2 {
  font-size: 1.5rem;
}

h3 {
  font-size: 1.25rem;
}

h4 {
  font-size: 1.125rem;
}

p {
  color: var(--text-primary);
}

.text-secondary {
  color: var(--text-secondary);
}

.text-tertiary {
  color: var(--text-tertiary);
}

a {
  color: var(--accent-primary);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-out);
}

a:hover {
  color: var(--accent-primary-hover);
}

/* ==========================================================================
   Layout
   ========================================================================== */

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 var(--space-6);
}

/* ==========================================================================
   Header
   ========================================================================== */

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4) 0;
  margin-bottom: var(--space-6);
  border-bottom: 1px solid var(--border-divider);
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent-primary);
  letter-spacing: -0.02em;
}

.logo-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.user-info {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* ==========================================================================
   Cards
   ========================================================================== */

.card {
  background: var(--bg-default);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow-card);
  transition: all var(--duration-normal) var(--ease-out);
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  min-height: 40px;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-out);
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--glow-focus);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent-primary);
  color: var(--text-inverse);
  border-color: var(--accent-primary);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-primary-hover);
  border-color: var(--accent-primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--bg-default);
  color: var(--text-primary);
  border-color: var(--border-default);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-secondary);
  border-color: var(--border-hover);
}

.btn-danger {
  background: var(--color-error-muted);
  color: var(--color-error);
  border-color: rgba(239, 68, 68, 0.2);
}

.btn-danger:hover:not(:disabled) {
  background: var(--color-error);
  color: var(--text-inverse);
}

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

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

/* ==========================================================================
   Form Elements
   ========================================================================== */

.input {
  width: 100%;
  height: 44px;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-default);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: var(--text-primary);
  margin-bottom: var(--space-3);
  transition: all var(--duration-fast) var(--ease-out);
}

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

.input:hover:not(:disabled):not(:focus) {
  border-color: var(--border-hover);
}

.input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: var(--glow-focus);
}

.input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--bg-secondary);
}

textarea.input {
  height: auto;
  min-height: 100px;
  resize: vertical;
  line-height: 1.5;
}

select.input {
  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='%236B6B6B' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  padding-right: var(--space-10);
  cursor: pointer;
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

/* ==========================================================================
   Tabs
   ========================================================================== */

.tabs {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--border-divider);
  margin-bottom: var(--space-6);
}

.tab {
  position: relative;
  padding: var(--space-3) var(--space-4);
  background: transparent;
  border: none;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease-out);
}

.tab::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: transparent;
  transition: background var(--duration-fast) var(--ease-out);
}

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

.tab.active {
  color: var(--accent-primary);
}

.tab.active::after {
  background: var(--accent-primary);
}

/* ==========================================================================
   List Items
   ========================================================================== */

.key-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4);
  background: var(--bg-secondary);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2);
  transition: all var(--duration-normal) var(--ease-out);
}

.key-item:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-hover);
}

.key-info {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.key-label {
  font-weight: 500;
  color: var(--text-primary);
}

.key-provider {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.project-item {
  padding: var(--space-4);
  background: var(--bg-secondary);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2);
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-out);
}

.project-item:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.packet-item {
  padding: var(--space-4);
  background: var(--bg-secondary);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2);
  transition: all var(--duration-normal) var(--ease-out);
}

.packet-item:hover {
  background: var(--bg-tertiary);
}

.repo-item {
  transition: all var(--duration-normal) var(--ease-out);
}

.repo-item:hover {
  background: var(--bg-secondary);
}

/* ==========================================================================
   Status Badges
   ========================================================================== */

.packet-status {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.packet-status.staged {
  background: var(--color-warning-muted);
  color: var(--color-warning);
}

.packet-status.approved {
  background: var(--color-success-muted);
  color: var(--color-success);
}

.packet-status.rejected {
  background: var(--color-error-muted);
  color: var(--color-error);
}

/* ==========================================================================
   Auth Container
   ========================================================================== */

.auth-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--space-6);
  background: var(--bg-root);
}

.auth-card {
  background: var(--bg-default);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-card);
}

.auth-toggle {
  text-align: center;
  margin-top: var(--space-4);
  color: var(--text-secondary);
}

.auth-toggle a {
  color: var(--accent-primary);
  cursor: pointer;
  text-decoration: none;
  font-weight: 500;
}

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

/* ==========================================================================
   Messages
   ========================================================================== */

.error-message {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3);
  background: var(--color-error-muted);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-md);
  color: var(--color-error);
  font-size: 0.875rem;
  margin-bottom: var(--space-4);
}

.success-message {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3);
  background: var(--color-success-muted);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: var(--radius-md);
  color: var(--color-success);
  font-size: 0.875rem;
  margin-bottom: var(--space-4);
}

/* ==========================================================================
   Empty State
   ========================================================================== */

.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  color: var(--text-secondary);
}

/* ==========================================================================
   Modals
   ========================================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn var(--duration-normal) var(--ease-out);
}

.modal {
  background: var(--bg-default);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-modal);
  animation: slideUp var(--duration-slow) var(--ease-out);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-5);
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.25rem;
  transition: all var(--duration-fast) var(--ease-out);
}

.modal-close:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================================================
   Loading States
   ========================================================================== */

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-default);
  border-top-color: var(--accent-primary);
  border-radius: var(--radius-full);
  margin: var(--space-4) auto;
  animation: spin 0.8s linear infinite;
}

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

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12);
  color: var(--text-secondary);
}

/* ==========================================================================
   GitHub Section
   ========================================================================== */

.github-connected-info img {
  border: 2px solid var(--border-default);
  border-radius: var(--radius-full);
}

/* ==========================================================================
   Utilities
   ========================================================================== */

.hidden {
  display: none !important;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
  .container {
    padding: 0 var(--space-4);
  }

  .header {
    flex-direction: column;
    gap: var(--space-4);
    text-align: center;
  }

  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .tabs::-webkit-scrollbar {
    display: none;
  }

  .modal {
    margin: var(--space-4);
    max-height: calc(100vh - var(--space-8));
  }

  .auth-card {
    padding: var(--space-6);
  }
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

:focus-visible {
  outline: none;
  box-shadow: var(--glow-focus);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}
