/* ============================================================
   ALP Components CSS — components.css
   Vercel & Firebase Dashboard UI Component Styles
   ============================================================ */

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-card);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(212, 175, 55, 0.3), transparent);
  opacity: 0;
  transition: opacity var(--transition-base);
}

.card:hover {
  border-color: rgba(212, 175, 55, 0.25);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  background: var(--bg-hover);
}

.card:hover::before {
  opacity: 1;
}

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

.card-header h3 {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin: 0;
}

.card-title {
  font-size: var(--text-md);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.card-subtitle {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: var(--space-4);
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 40px;
  padding: 0 var(--space-5);
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-base);
  -webkit-user-select: none;
  user-select: none;
  background: none;
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(255,255,255,0.1), transparent 70%);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.btn:hover::before {
  opacity: 1;
}

.btn-primary {
  background: var(--gradient-primary);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  filter: brightness(1.15);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--border-primary);
  color: var(--text-primary);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(99, 102, 241, 0.4);
  color: var(--text-primary);
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.1);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(239, 68, 68, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  filter: brightness(1.15);
}

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

.btn-ghost:hover {
  background: rgba(99, 102, 241, 0.08);
  color: var(--text-primary);
  border-color: rgba(99, 102, 241, 0.2);
}

.btn-sm {
  height: 32px;
  padding: 0 var(--space-3);
  font-size: 13px;
}

.btn-lg {
  height: 48px;
  padding: 0 var(--space-6);
  font-size: var(--text-md);
}

.btn-icon {
  width: 40px;
  padding: 0;
}

.btn-icon.btn-sm {
  width: 32px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
  filter: none !important;
}

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: 11px;
  font-weight: var(--font-semibold);
  line-height: 1;
  padding: 5px var(--space-2.5);
  border-radius: var(--radius-pill);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.badge-success {
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.2);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.08);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.2);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.08);
}

.badge-danger {
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.2);
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.08);
}

.badge-info {
  background: rgba(59, 130, 246, 0.12);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.2);
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.08);
}

.badge-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  border: 1px solid var(--border-primary);
}

/* ── Forms and Inputs ─────────────────────────────────────── */
.form-group {
  margin-bottom: var(--space-5);
}

.form-group label {
  display: block;
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
  letter-spacing: 0.01em;
}

.input, .select, .form-select, .textarea {
  width: 100%;
  height: 40px;
  padding: 0 var(--space-4);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-family: inherit;
  transition: all var(--transition-base);
  outline: none;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

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

.input:hover, .select:hover, .form-select:hover, .textarea:hover {
  border-color: var(--border-hover);
  background: rgba(255, 255, 255, 0.03);
}

.input:focus, .select:focus, .form-select:focus, .textarea:focus {
  border-color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.04);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1), inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

.input:disabled, .select:disabled, .form-select:disabled, .textarea:disabled {
  opacity: 0.5;
  background: rgba(255, 255, 255, 0.01);
  cursor: not-allowed;
}

select, .select, .form-select {
  color-scheme: dark;
}

[data-theme='light'] select,
[data-theme='light'] .select,
[data-theme='light'] .form-select {
  color-scheme: light;
}

.select, .form-select {
  appearance: none;
  cursor: pointer;
  padding-right: var(--space-8) !important;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2394a3b8' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  transition: all var(--transition-base);
}

.select:focus, .form-select:focus,
.select:hover, .form-select:hover {
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23818cf8' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
}

select option, .select option, .form-select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.textarea {
  height: auto;
  min-height: 100px;
  padding: var(--space-3);
  resize: vertical;
  line-height: var(--leading-relaxed);
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--border-primary);
  border-radius: var(--radius-pill);
  transition: .2s;
  border: 1px solid var(--border-primary);
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 2px;
  bottom: 2px;
  background-color: var(--text-secondary);
  border-radius: 50%;
  transition: .2s;
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--accent-primary);
  border-color: var(--accent-primary);
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(16px);
  background-color: #ffffff;
}

/* ── Data Tables ──────────────────────────────────────────── */
.table-container {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  background: rgba(22, 22, 42, 0.40);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: var(--text-sm);
}

.data-table th {
  padding: var(--space-4) var(--space-4);
  font-weight: var(--font-semibold);
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-primary);
  background: linear-gradient(180deg, rgba(99, 102, 241, 0.03), transparent);
  white-space: nowrap;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.05em;
}

.data-table td {
  padding: var(--space-4) var(--space-4);
  color: var(--text-primary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
  white-space: nowrap;
}

.data-table tbody tr {
  transition: all var(--transition-fast);
  position: relative;
}

.data-table tbody tr::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 3px;
  height: 100%;
  background: var(--accent-primary);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

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

.data-table tbody tr:hover {
  background: rgba(99, 102, 241, 0.04);
}

.data-table tbody tr:hover::before {
  opacity: 1;
}

/* ── Avatars ──────────────────────────────────────────────── */
.avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: #ffffff;
  flex-shrink: 0;
  -webkit-user-select: none;
  user-select: none;
}

/* ── Pulse Indicator ──────────────────────────────────────── */
.pulse-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--color-success);
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
  animation: pulse-animation 2s infinite;
}

@keyframes pulse-animation {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

/* ── Tabs ─────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--border-primary);
  margin-bottom: var(--space-5);
  overflow-x: auto;
}

.tab {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition-base);
  white-space: nowrap;
  -webkit-user-select: none;
  user-select: none;
}

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

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

/* ── Empty State ──────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-10) var(--space-6);
  text-align: center;
}

.empty-state-icon {
  font-size: 40px;
  margin-bottom: var(--space-4);
  opacity: 0.6;
}

.empty-state h3 {
  font-size: var(--text-md);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.empty-state p {
  font-size: var(--text-sm);
  color: var(--text-muted);
  max-width: 320px;
  margin: 0;
}

/* ── Loading Skeleton ─────────────────────────────────────── */
.skeleton {
  background: var(--border-primary);
  background-image: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0),
    rgba(255, 255, 255, 0.05),
    rgba(255, 255, 255, 0)
  );
  background-size: 200px 100%;
  background-repeat: no-repeat;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% {
    background-position: -200px 0;
  }
  100% {
    background-position: calc(200px + 100%) 0;
  }
}

/* ── Custom ALP Dropdown ──────────────────────────────────── */
.alp-dropdown {
  position: relative;
  display: inline-block;
  min-width: 180px;
  font-family: var(--font-sans);
  user-select: none;
}
.alp-dropdown.w-full {
  width: 100%;
  display: block;
}
.alp-dropdown-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px var(--space-4) 8px var(--space-3);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  cursor: pointer;
  transition: all var(--transition-base);
  height: 38px;
  width: 100%;
  box-sizing: border-box;
}
.alp-dropdown-trigger:hover {
  border-color: var(--border-hover);
  background: var(--bg-hover);
}
.alp-dropdown-trigger:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-primary-ring);
  outline: none;
}
.alp-dropdown-trigger-content {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}
.alp-dropdown-logo {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  object-fit: contain;
  flex-shrink: 0;
}
.alp-dropdown-avatar {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.alp-dropdown-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
  text-align: left;
}
.alp-dropdown-arrow {
  color: var(--text-secondary);
  transition: transform var(--transition-base);
  flex-shrink: 0;
}
.alp-dropdown.open .alp-dropdown-arrow {
  transform: rotate(180deg);
}
.alp-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-dropdown);
  display: none;
  max-height: 260px;
  overflow-y: auto;
  margin: 0;
  padding: var(--space-1) 0;
  list-style: none;
  animation: dropdownFadeIn 0.2s var(--ease-out) both;
}
.alp-dropdown.open .alp-dropdown-menu {
  display: block;
}
@keyframes dropdownFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.alp-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px var(--space-3);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  color: var(--text-secondary);
  font-size: var(--text-sm);
}
.alp-dropdown-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.alp-dropdown-item.selected {
  background: var(--accent-primary-muted);
  color: var(--accent-primary-hover);
  font-weight: var(--font-semibold);
}
.alp-dropdown-item-logo {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  object-fit: contain;
  flex-shrink: 0;
}
.alp-dropdown-item-avatar {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.alp-dropdown-item-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}
.alp-dropdown-item-name {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
}
.alp-dropdown-item-domain {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
  text-align: left;
}
