/* ==========================================================================
   Lynx - Component Styles
   Buttons, Cards, Badges, Nav, Modals, Filters, Forms
   ========================================================================== */

/* --------------------------------------------------------------------------
   Top Navigation
   -------------------------------------------------------------------------- */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--color-surface);
  border-bottom: 2px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 var(--space-5);
  z-index: 1000;
  box-shadow: var(--shadow-sm);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--color-text);
  text-decoration: none;
  flex-shrink: 0;
}

.nav-brand img {
  height: 32px;
  width: auto;
}

.nav-search {
  flex: 1;
  max-width: 480px;
  margin: 0 var(--space-6);
}

.nav-search input {
  width: 100%;
  padding: var(--space-2) var(--space-4);
  padding-left: var(--space-10);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: var(--font-primary);
  font-size: var(--text-sm);
  color: var(--color-text);
  background: var(--color-bg);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.nav-search input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(0, 128, 128, 0.15);
  outline: none;
}

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

.nav-search-wrapper {
  position: relative;
}

.nav-search-icon {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  pointer-events: none;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text);
}

.nav-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-accent);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--weight-semibold);
  font-size: var(--text-xs);
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-primary);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  transition: all var(--transition-base);
  box-shadow: var(--shadow-md);
  text-decoration: none;
  line-height: var(--leading-tight);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.btn:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.btn-primary {
  background: var(--amethyst-700);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--amethyst-900);
}

.btn-accent {
  background: var(--emerald-500);
  color: #ffffff;
}

.btn-accent:hover {
  background: var(--emerald-700);
}

.btn-cta {
  background: var(--rainbow-orange);
  color: #ffffff;
  padding: 12px 28px;
  font-size: var(--text-base);
}

.btn-cta:hover {
  background: #d67a03;
}

.btn-danger {
  background: var(--rainbow-red);
  color: #ffffff;
}

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

.btn-ghost {
  background: transparent;
  color: var(--color-text);
  box-shadow: none;
  border: 1px solid var(--color-border);
}

.btn-ghost:hover {
  background: var(--color-bg-alt);
  box-shadow: none;
}

.btn-icon {
  padding: var(--space-2);
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  color: var(--color-text);
  background: var(--color-bg-alt);
  box-shadow: none;
  transform: none;
}

.btn-sm {
  padding: 6px 12px;
  font-size: var(--text-xs);
}

/* --------------------------------------------------------------------------
   Filter Bar
   -------------------------------------------------------------------------- */
.filter-bar {
  background: var(--color-bg-alt);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-3) 0;
  position: sticky;
  top: var(--nav-height);
  z-index: 900;
}

.filter-bar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1);
}

.filter-group-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-right: var(--space-1);
}

.filter-divider {
  width: 1px;
  height: 24px;
  background: var(--color-border);
  margin: 0 var(--space-2);
}

/* --------------------------------------------------------------------------
   Pills / Chips (Filter Toggles)
   -------------------------------------------------------------------------- */
.pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-light);
  line-height: var(--leading-tight);
  user-select: none;
}

.pill:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.pill.active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #ffffff;
}

.pill-count {
  background: var(--color-accent);
  color: #ffffff;
  border-radius: 50%;
  min-width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: var(--weight-bold);
  margin-left: var(--space-1);
}

/* --------------------------------------------------------------------------
   View Toggle
   -------------------------------------------------------------------------- */
.view-toggle {
  display: inline-flex;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.view-toggle-btn {
  padding: var(--space-2) var(--space-3);
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
}

.view-toggle-btn:hover {
  color: var(--color-text);
  background: var(--color-bg-alt);
}

.view-toggle-btn.active {
  background: var(--color-accent);
  color: #ffffff;
}

/* --------------------------------------------------------------------------
   Card Grid
   -------------------------------------------------------------------------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-4);
  padding: var(--space-4) 0;
}

/* --------------------------------------------------------------------------
   Stack Item Card
   -------------------------------------------------------------------------- */
.card {
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  transition: all var(--transition-base);
  position: relative;
  display: flex;
  flex-direction: column;
}

.card:hover {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-lg);
}

.card.is-favorited {
  border-left: 4px solid var(--rainbow-orange);
}

.card-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.card-logo {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  object-fit: contain;
  background: var(--color-bg-alt);
  padding: var(--space-1);
  flex-shrink: 0;
}

.card-logo-placeholder {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--color-primary-faint);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--color-primary);
  flex-shrink: 0;
}

.card-title-area {
  flex: 1;
  min-width: 0;
}

.card-title {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-subtitle {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: 2px;
}

.card-favorite {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  font-size: var(--text-lg);
  color: var(--color-text-muted);
  transition: color var(--transition-fast);
  padding: var(--space-1);
}

.card-favorite:hover,
.card-favorite.active {
  color: var(--rainbow-orange);
}

.card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-bottom: var(--space-3);
}

.card-description {
  font-size: var(--text-sm);
  color: var(--color-text-light);
  line-height: var(--leading-normal);
  flex: 1;
  margin-bottom: var(--space-3);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-plans {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-bottom: var(--space-3);
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-top: auto;
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
}

.card-launch {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 6px 16px;
  background: var(--emerald-500);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-primary);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  transition: all var(--transition-base);
  text-decoration: none;
}

.card-launch:hover {
  background: var(--emerald-700);
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.card-launch-desktop {
  background: var(--amethyst-500, #7c3aed);
}

.card-launch-desktop:hover {
  background: var(--amethyst-700, #5b21b6);
  color: #ffffff;
}

.card-detail-link {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  transition: color var(--transition-fast);
}

.card-detail-link:hover {
  color: var(--color-accent);
}

/* --------------------------------------------------------------------------
   Badges (Status, Audience, Department)
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: var(--leading-tight);
}

/* Status badges */
.badge-active      { background: var(--rainbow-green);  color: #ffffff; }
.badge-coming-soon { background: var(--emerald-500);    color: #ffffff; }
.badge-developing  { background: var(--rainbow-orange); color: #ffffff; }
.badge-deprecating { background: var(--rainbow-red);    color: #ffffff; }

/* Audience badges */
.badge-internal  { background: var(--amethyst-700); color: #ffffff; }
.badge-customer  { background: var(--emerald-500);  color: #ffffff; }
.badge-both {
  background: transparent;
  color: var(--amethyst-700);
  border: 1px solid var(--amethyst-700);
}

[data-theme="dark"] .badge-internal {
  background: var(--amethyst-500);
  color: #ffffff;
}

[data-theme="dark"] .badge-both {
  color: var(--amethyst-300);
  border-color: var(--amethyst-300);
}

/* Department badges */
.badge-dept {
  background: var(--color-bg-alt);
  color: var(--color-text-light);
  border: 1px solid var(--color-border);
}

/* --------------------------------------------------------------------------
   Plan Tags
   -------------------------------------------------------------------------- */
.plan-tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  font-size: 10px;
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: var(--leading-tight);
}

.plan-basic {
  background: var(--amethyst-100);
  color: var(--amethyst-700);
}

.plan-standard {
  background: var(--amethyst-300);
  color: var(--amethyst-700);
}

.plan-complete {
  background: var(--amethyst-700);
  color: #ffffff;
}

.plan-alacarte {
  background: transparent;
  color: var(--rainbow-orange);
  border: 2px dashed var(--rainbow-orange);
}

[data-theme="dark"] .plan-basic {
  background: var(--amethyst-900);
  color: var(--amethyst-300);
}

[data-theme="dark"] .plan-standard {
  background: var(--amethyst-700);
  color: var(--amethyst-100);
}

[data-theme="dark"] .plan-complete {
  background: var(--amethyst-300);
  color: var(--amethyst-900);
}

/* --------------------------------------------------------------------------
   List View
   -------------------------------------------------------------------------- */
.list-view {
  display: none;
}

.list-view.active {
  display: block;
}

.card-grid.active {
  display: grid;
}

.card-grid:not(.active) {
  display: none;
}

.list-table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-4) 0;
}

.list-table th {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  background: var(--color-bg-alt);
  border-bottom: 2px solid var(--color-border);
  cursor: pointer;
  user-select: none;
}

.list-table th:hover {
  color: var(--color-text);
}

.list-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  font-size: var(--text-sm);
  vertical-align: middle;
}

.list-table tr {
  transition: background var(--transition-fast);
}

.list-table tbody tr:hover {
  background: var(--color-bg-alt);
}

.list-row-logo {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  object-fit: contain;
  background: var(--color-bg-alt);
}

.list-row-name {
  font-weight: var(--weight-semibold);
  color: var(--color-text);
}

/* --------------------------------------------------------------------------
   Theme Toggle
   -------------------------------------------------------------------------- */
.theme-toggle {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--color-border);
  border: none;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background var(--transition-base);
  padding: 0;
}

.theme-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #ffffff;
  border-radius: 50%;
  transition: transform var(--transition-base);
  box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .theme-toggle {
  background: var(--color-accent);
}

[data-theme="dark"] .theme-toggle::after {
  transform: translateX(20px);
}

.theme-toggle-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* --------------------------------------------------------------------------
   Loading / Infinite Scroll
   -------------------------------------------------------------------------- */
.loading-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  gap: var(--space-2);
}

.loading-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.scroll-sentinel {
  height: 1px;
  width: 100%;
}

/* --------------------------------------------------------------------------
   Empty State
   -------------------------------------------------------------------------- */
.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-5);
  color: var(--color-text-muted);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: var(--space-4);
  opacity: 0.5;
}

.empty-state-title {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  margin-bottom: var(--space-2);
  color: var(--color-text-light);
}

.empty-state-text {
  font-size: var(--text-sm);
  max-width: 400px;
  margin: 0 auto;
}

/* --------------------------------------------------------------------------
   Modal
   -------------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-base), visibility var(--transition-base);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--color-surface);
  border: 3px solid var(--color-primary);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform var(--transition-base);
}

.modal-overlay.active .modal {
  transform: translateY(0);
}

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

.modal-title {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
}

.modal-close {
  background: none;
  border: none;
  font-size: var(--text-xl);
  cursor: pointer;
  color: var(--color-text-muted);
  padding: var(--space-1);
  transition: color var(--transition-fast);
}

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

/* --------------------------------------------------------------------------
   Form Elements
   -------------------------------------------------------------------------- */
.form-group {
  margin-bottom: var(--space-5);
}

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
  margin-bottom: var(--space-1);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-primary);
  font-size: var(--text-sm);
  color: var(--color-text);
  background: var(--color-bg);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(0, 128, 128, 0.15);
  outline: none;
}

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

.form-checkbox {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
}

.form-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--color-accent);
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

.form-error {
  font-size: var(--text-xs);
  color: var(--color-error);
  margin-top: var(--space-1);
}

/* --------------------------------------------------------------------------
   Toast / Notification
   -------------------------------------------------------------------------- */
.toast-container {
  position: fixed;
  bottom: var(--space-5);
  right: var(--space-5);
  z-index: 11000;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.toast {
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.3s ease;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.toast-success {
  background: var(--rainbow-green);
  color: #ffffff;
}

.toast-error {
  background: var(--rainbow-red);
  color: #ffffff;
}

.toast-info {
  background: var(--emerald-500);
  color: #ffffff;
}

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

/* --------------------------------------------------------------------------
   Mobile Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 767px) {
  .nav {
    padding: 0 var(--space-3);
  }

  .nav-search {
    display: none;
  }

  .nav-search.mobile-active {
    display: block;
    position: fixed;
    top: var(--nav-height);
    left: 0;
    right: 0;
    padding: var(--space-3);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    max-width: 100%;
    margin: 0;
    z-index: 999;
  }

  .nav-user-name {
    display: none;
  }

  .filter-bar {
    padding: var(--space-2) 0;
  }

  .filter-bar-inner {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: var(--space-2);
    -webkit-overflow-scrolling: touch;
  }

  .filter-divider {
    display: none;
  }

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

  .list-table {
    font-size: var(--text-xs);
  }

  .list-table .col-category,
  .list-table .col-audience,
  .list-table .col-plans {
    display: none;
  }

  .modal {
    padding: var(--space-5);
    margin: var(--space-3);
    max-height: 85vh;
  }
}

@media (max-width: 1023px) and (min-width: 768px) {
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
