/* CredChainsUS - Main Stylesheet
   Warm neutrals with single accent - Linear/Notion inspired
   Supports light and dark mode via CSS variables
   ============================================================ */

/* ============================================
   CSS VARIABLES - THEME TOKENS
   ============================================ */

:root {
  /* Light mode - Warm neutrals */
  --surface-0: #ffffff;
  --surface-50: #fafaf9;
  --surface-100: #f5f5f4;
  --surface-200: #e7e5e4;
  --surface-300: #d6d3d1;
  --surface-400: #a8a29e;
  --surface-500: #78716c;

  /* Light mode text */
  --text-primary: #1c1917;
  --text-secondary: #44403c;
  --text-tertiary: #78716c;
  --text-muted: #a8a29e;
  --text-inverted: #ffffff;

  /* Accent gradient */
  --accent-gradient-from: #6366f1;
  --accent-gradient-to: #8b5cf6;
  --accent-ring: rgba(99, 102, 241, 0.2);

  /* Shadows */
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
  --shadow-card-hover: 0 4px 12px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.04);
}

.dark {
  /* Dark mode - Warm dark neutrals */
  --surface-0: #0c0a09;
  --surface-50: #1c1917;
  --surface-100: #292524;
  --surface-200: #44403c;
  --surface-300: #57534e;
  --surface-400: #78716c;
  --surface-500: #a8a29e;

  /* Dark mode text */
  --text-primary: #fafaf9;
  --text-secondary: #e7e5e4;
  --text-tertiary: #a8a29e;
  --text-muted: #78716c;
  --text-inverted: #1c1917;

  /* Accent gradient (slightly brighter for dark mode) */
  --accent-gradient-from: #818cf8;
  --accent-gradient-to: #a78bfa;
  --accent-ring: rgba(129, 140, 248, 0.3);

  /* Shadows for dark mode */
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-card-hover: 0 8px 24px rgba(0, 0, 0, 0.4), 0 4px 8px rgba(0, 0, 0, 0.3);
}

/* ============================================
   BASE STYLES
   ============================================ */

* {
  scrollbar-width: thin;
  scrollbar-color: var(--surface-300) var(--surface-100);
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-track {
  background: var(--surface-100);
}

*::-webkit-scrollbar-thumb {
  background: var(--surface-300);
  border-radius: 4px;
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--surface-400);
}

::selection {
  background: rgba(99, 102, 241, 0.2);
  color: var(--text-primary);
}

body {
  background-color: var(--surface-0);
  color: var(--text-primary);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* ============================================
   CARD COMPONENTS
   ============================================ */

.glass {
  background: var(--surface-100);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--surface-200);
}

.glass-card {
  background: var(--surface-100);
  border: 1px solid var(--surface-200);
  box-shadow: var(--shadow-card);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.glass-card:hover {
  box-shadow: var(--shadow-card-hover);
}

/* ============================================
   BUTTONS
   ============================================ */

.btn-primary {
  background: #6366f1;
  color: #ffffff;
  font-weight: 500;
  padding: 0.625rem 1.25rem;
  border-radius: 0.5rem;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 0.875rem;
}

.btn-primary:hover {
  background: #4f46e5;
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-primary:disabled {
  background: var(--surface-300);
  cursor: not-allowed;
}

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  font-weight: 500;
  padding: 0.625rem 1.25rem;
  border-radius: 0.5rem;
  border: 1px solid var(--surface-300);
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 0.875rem;
}

.btn-secondary:hover {
  background: var(--surface-100);
  border-color: var(--surface-400);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  font-weight: 500;
  padding: 0.625rem 1.25rem;
  border-radius: 0.5rem;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 0.875rem;
}

.btn-ghost:hover {
  color: var(--text-primary);
  background: var(--surface-100);
}

.btn-success {
  background: #22c55e;
  color: #ffffff;
  font-weight: 500;
  padding: 0.625rem 1.25rem;
  border-radius: 0.5rem;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 0.875rem;
}

.btn-success:hover {
  background: #16a34a;
}

.btn-success:disabled {
  background: var(--surface-300);
  cursor: not-allowed;
}

/* Wallet Connect Button */
.btn-wallet {
  background: var(--surface-100);
  color: var(--text-primary);
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  border: 1px solid var(--surface-300);
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.btn-wallet:hover {
  border-color: #6366f1;
  background: var(--surface-50);
}

.btn-wallet.connected {
  border-color: #22c55e;
  background: #f0fdf4;
}

.dark .btn-wallet.connected {
  background: rgba(34, 197, 94, 0.1);
}

/* ============================================
   NFT-STYLE CREDENTIAL CARDS
   ============================================ */

.nft-card {
  position: relative;
  background: var(--surface-100);
  border-radius: 1rem;
  overflow: hidden;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-card);
}

.nft-card::before {
  content: '';
  position: absolute;
  inset: 0;
  padding: 2px;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  border-radius: 1rem;
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  opacity: 0.6;
  transition: opacity 0.2s ease;
}

.nft-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-card-hover);
}

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

.nft-card-inner {
  padding: 1.25rem;
  position: relative;
  z-index: 1;
}

/* Credential type-specific frames */
.nft-card.education::before {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
}

.nft-card.healthcare::before {
  background: linear-gradient(135deg, #10b981 0%, #14b8a6 100%);
}

.nft-card.finance::before {
  background: linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
}

.nft-card.construction::before {
  background: linear-gradient(135deg, #f97316 0%, #ef4444 100%);
}

.nft-card.it::before {
  background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
}

.nft-card.professional::before {
  background: linear-gradient(135deg, #8b5cf6 0%, #a855f7 100%);
}

/* NFT Card Image */
.nft-card-image {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 0.5rem;
  background: var(--surface-200);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-bottom: 1rem;
}

.nft-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.nft-card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.nft-card-subtitle {
  font-size: 0.875rem;
  color: var(--text-tertiary);
  margin-bottom: 0.75rem;
}

.nft-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 0.75rem;
  border-top: 1px solid var(--surface-200);
}

.nft-card-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.625rem;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 1rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #16a34a;
}

.dark .nft-card-badge {
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.3);
}

.nft-card-badge.pending {
  background: #fffbeb;
  border-color: #fde68a;
  color: #d97706;
}

.dark .nft-card-badge.pending {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.3);
}

.nft-card-badge.expired {
  background: #fef2f2;
  border-color: #fecaca;
  color: #dc2626;
}

.dark .nft-card-badge.expired {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
}

/* ============================================
   INSTITUTION CARDS
   ============================================ */

.institution-card {
  background: var(--surface-100);
  border: 1px solid var(--surface-200);
  border-radius: 0.75rem;
  padding: 1.25rem;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-card);
}

.institution-card:hover {
  border-color: #6366f1;
  box-shadow: var(--shadow-card-hover);
}

.institution-logo {
  width: 3rem;
  height: 3rem;
  border-radius: 0.5rem;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 600;
  color: #ffffff;
  margin-bottom: 0.75rem;
}

/* ============================================
   FORMS
   ============================================ */

.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.375rem;
}

.form-input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  background: var(--surface-0);
  border: 1px solid var(--surface-300);
  border-radius: 0.5rem;
  color: var(--text-primary);
  font-size: 0.875rem;
  transition: all 0.15s ease;
}

.form-input:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

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

.form-select {
  width: 100%;
  padding: 0.625rem 0.875rem;
  background: var(--surface-0);
  border: 1px solid var(--surface-300);
  border-radius: 0.5rem;
  color: var(--text-primary);
  font-size: 0.875rem;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2378716c'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
}

.form-select:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* ============================================
   NAVIGATION
   ============================================ */

.navbar {
  background: var(--surface-0);
  border-bottom: 1px solid var(--surface-200);
  position: sticky;
  top: 0;
  z-index: 100;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.navbar-brand {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.nav-link {
  color: var(--text-tertiary);
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0.375rem 0.75rem;
  border-radius: 0.375rem;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--surface-100);
}

.nav-link.active {
  color: #6366f1;
}

/* ============================================
   MODALS
   ============================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
}

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

.modal-content {
  background: var(--surface-0);
  border: 1px solid var(--surface-200);
  border-radius: 1rem;
  padding: 1.5rem;
  max-width: 24rem;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  transform: scale(0.95);
  transition: transform 0.2s ease;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.dark .modal-content {
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.modal-overlay.active .modal-content {
  transform: scale(1);
}

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

.modal-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  width: 2rem;
  height: 2rem;
  border-radius: 0.375rem;
  background: var(--surface-100);
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

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

/* Wallet Selection Modal */
.wallet-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem;
  background: var(--surface-50);
  border: 1px solid var(--surface-200);
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.15s ease;
  margin-bottom: 0.5rem;
}

.wallet-option:hover {
  border-color: #6366f1;
  background: var(--surface-100);
}

.wallet-option img {
  width: 2rem;
  height: 2rem;
  border-radius: 0.375rem;
}

.wallet-option-name {
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.wallet-option-desc {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

/* ============================================
   ALERTS & NOTIFICATIONS
   ============================================ */

.alert {
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.alert-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #15803d;
}

.dark .alert-success {
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.3);
  color: #4ade80;
}

.alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
}

.dark .alert-error {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: #f87171;
}

.alert-warning {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #d97706;
}

.dark .alert-warning {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.3);
  color: #fbbf24;
}

.alert-info {
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  color: #4f46e5;
}

.dark .alert-info {
  background: rgba(99, 102, 241, 0.1);
  border-color: rgba(99, 102, 241, 0.3);
  color: #818cf8;
}

/* ============================================
   LOADING STATES
   ============================================ */

.spinner {
  width: 1.5rem;
  height: 1.5rem;
  border: 2px solid var(--surface-200);
  border-top-color: #6366f1;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.skeleton {
  background: linear-gradient(90deg, var(--surface-100) 25%, var(--surface-200) 50%, var(--surface-100) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 0.375rem;
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.gradient-text {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.truncate-address {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.875rem;
}

.divider {
  height: 1px;
  background: var(--surface-200);
  margin: 1.5rem 0;
}

/* ============================================
   THEME TOGGLE
   ============================================ */

.theme-toggle {
  width: 2rem;
  height: 2rem;
  border-radius: 0.375rem;
  background: var(--surface-100);
  border: 1px solid var(--surface-200);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  transition: all 0.15s ease;
}

.theme-toggle:hover {
  color: var(--text-primary);
  border-color: var(--surface-300);
}

/* ============================================
   DASHBOARD COMPONENTS
   ============================================ */

.stat-card {
  background: var(--surface-100);
  border: 1px solid var(--surface-200);
  border-radius: 0.75rem;
  padding: 1.25rem;
  transition: all 0.2s ease;
}

.stat-card:hover {
  box-shadow: var(--shadow-card-hover);
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.stat-label {
  font-size: 0.875rem;
  color: var(--text-tertiary);
}

.quick-action {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--surface-50);
  border: 1px solid var(--surface-200);
  border-radius: 0.5rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s ease;
  cursor: pointer;
  text-decoration: none;
}

.quick-action:hover {
  background: var(--surface-100);
  border-color: #6366f1;
  color: var(--text-primary);
}

.quick-action svg {
  color: var(--text-muted);
  transition: color 0.15s ease;
}

.quick-action:hover svg {
  color: #6366f1;
}

/* Activity list */
.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--surface-200);
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-icon {
  width: 2rem;
  height: 2rem;
  border-radius: 0.375rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.activity-icon.success {
  background: #f0fdf4;
  color: #22c55e;
}

.dark .activity-icon.success {
  background: rgba(34, 197, 94, 0.1);
}

.activity-icon.pending {
  background: #fffbeb;
  color: #f59e0b;
}

.dark .activity-icon.pending {
  background: rgba(245, 158, 11, 0.1);
}

.activity-content {
  flex: 1;
  min-width: 0;
}

.activity-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0.125rem;
}

.activity-desc {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.activity-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
  .nft-card:hover {
    transform: translateY(-2px);
  }

  .modal-content {
    padding: 1.25rem;
    border-radius: 0.75rem;
  }

  .stat-value {
    font-size: 1.25rem;
  }
}
