/* ═══════════════════════════════════════════════
   JaceHub — Design System & Styles
   Cozy, Flat, Nintendo-style UI
   ═══════════════════════════════════════════════ */

/* ── CSS Custom Properties ── */
:root {
  /* Colors */
  --c-bg:          #F3F6F2; /* Soft light greenish-gray background based on grass */
  --c-surface:     #FFFFFF; /* White cards */
  --c-surface-hover: #F8FAF7;
  --c-border:      #E2E8F0; /* Soft gray border */
  --c-border-hover: #CBD5E1;
  --c-text:        #334155; /* Slate dark text */
  --c-text-muted:  #64748B;
  --c-text-dim:    #94A3B8;

  /* Accents */
  --c-accent:      #FF4D4D; /* Friendly red */
  --c-accent-hover:#FF3333;
  --c-accent-2:    #4ADE80; /* Soft green */
  --g-accent:      linear-gradient(135deg, #FF7B54, #FF4B4B);

  /* Status */
  --c-success:     #10B981;
  --c-warning:     #F59E0B;
  --c-error:       #EF4444;

  /* Spacing - Reduced for cozier feel */
  --s-xs: 0.25rem;
  --s-sm: 0.5rem;
  --s-md: 0.75rem;
  --s-lg: 1rem;
  --s-xl: 1.5rem;
  --s-2xl: 2rem;

  /* Radius */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 20px; /* Highly rounded cards */
  --r-xl: 24px;
  --r-pill: 9999px;

  /* Typography */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Shadows - Nintendo style often has a slightly thick, flat drop shadow */
  --shadow-sm: 0 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 0 rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 6px 16px rgba(0, 0, 0, 0.08);
  --shadow-float: 0 8px 24px rgba(0, 0, 0, 0.08);

  /* Transitions */
  --t-fast: 150ms ease;
  --t-base: 250ms ease;
  --t-bounce: 400ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

body {
  font-family: var(--font);
  background: var(--c-bg);
  color: var(--c-text);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
}

/* ── Header (Floating Pill shape) ── */
.header {
  position: sticky;
  top: 1rem;
  z-index: 100;
  margin: 0 auto;
  max-width: 900px;
  padding: 0 var(--s-md);
}

.header__inner {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  padding: var(--s-sm) var(--s-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-float);
  border: 2px solid #FFFFFF;
}

.header__brand {
  display: flex;
  align-items: center;
  gap: var(--s-sm);
}

.header__logo svg {
  width: 32px;
  height: 32px;
  display: block;
}

.header__title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--c-text);
  letter-spacing: -0.02em;
}

.header__actions {
  display: flex;
  align-items: center;
  gap: var(--s-sm);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.4rem 1rem;
  border: none;
  border-radius: var(--r-pill);
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast);
  white-space: nowrap;
}

.btn--primary {
  background: var(--c-accent);
  color: white;
  box-shadow: 0 3px 0 #D32F2F; /* Thicker flat shadow */
}

.btn--primary:hover {
  background: var(--c-accent-hover);
  transform: translateY(1px);
  box-shadow: 0 2px 0 #D32F2F;
}

.btn--primary:active {
  transform: translateY(3px);
  box-shadow: 0 0 0 #D32F2F;
}

.btn--ghost {
  background: #F1F5F9;
  color: var(--c-text);
  box-shadow: 0 2px 0 #CBD5E1;
}

.btn--ghost:hover {
  background: #E2E8F0;
  transform: translateY(1px);
  box-shadow: 0 1px 0 #CBD5E1;
}

.btn--ghost:active {
  transform: translateY(2px);
  box-shadow: 0 0 0 #CBD5E1;
}

.btn--lg {
  padding: 0.6rem 1.5rem;
  font-size: 1rem;
}

/* ── Main ── */
.main {
  position: relative;
  z-index: 1;
  max-width: 900px;
  margin: 0 auto;
  padding: var(--s-xl) var(--s-md);
  display: flex;
  flex-direction: column;
  gap: var(--s-lg);
}

/* ── Stats Bar ── */
.stats {
  display: flex;
  justify-content: space-around;
  padding: var(--s-md) var(--s-xl);
  background: var(--c-surface);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--c-border);
  animation: popIn var(--t-bounce) both;
}

.stats__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.stats__value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--c-text);
  line-height: 1.2;
}

.stats__label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── State Screens ── */
.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 40vh;
  gap: var(--s-md);
  background: var(--c-surface);
  border-radius: var(--r-lg);
  padding: var(--s-2xl);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--c-border);
}

.state h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--c-text);
}

.state p {
  color: var(--c-text-muted);
  font-size: 0.95rem;
}

.state__icon {
  color: var(--c-accent-2); /* Soft green for icons like empty state */
  margin-bottom: var(--s-sm);
}

.state__icon--error {
  color: var(--c-error);
}

/* ── Spinner ── */
.spinner {
  width: 36px;
  height: 36px;
  border: 4px solid #E2E8F0;
  border-top-color: var(--c-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ── Project Grid ── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--s-lg);
}

/* ── Project Card ── */
.card {
  position: relative;
  background: var(--c-surface);
  border-radius: var(--r-lg);
  padding: var(--s-lg);
  cursor: pointer;
  transition: transform var(--t-bounce), box-shadow var(--t-base);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  display: block;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--c-border);
  animation: popIn var(--t-bounce) both;
}

.card:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: var(--shadow-float);
  border-color: #CBD5E1;
}

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card__name {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--c-text);
  line-height: 1.2;
}

.card__status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.card__status--success {
  background: #D1FAE5;
  color: #059669;
}

.card__status--failure {
  background: #FEE2E2;
  color: #DC2626;
}

.card__status--active {
  background: #FEF3C7;
  color: #D97706;
}

.card__status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.card__desc {
  margin-top: 6px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--c-text-muted);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card__footer {
  margin-top: var(--s-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card__url {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: #F1F5F9;
  border-radius: var(--r-pill);
  font-size: 0.8125rem;
  font-weight: 600;
  color: #0284C7;
  transition: all var(--t-fast);
}

.card:hover .card__url {
  background: #E0F2FE;
}

.card__url svg {
  color: #38BDF8;
}

.card__time {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--c-text-dim);
}

/* Card stagger animation */
.card:nth-child(1)  { animation-delay: 0.05s; }
.card:nth-child(2)  { animation-delay: 0.10s; }
.card:nth-child(3)  { animation-delay: 0.15s; }
.card:nth-child(4)  { animation-delay: 0.20s; }
.card:nth-child(5)  { animation-delay: 0.25s; }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-xl);
  opacity: 0;
  visibility: hidden;
  transition: all var(--t-fast);
}

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

.modal {
  width: 100%;
  max-width: 440px;
  background: var(--c-surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-float);
  transform: translateY(20px) scale(0.96);
  transition: transform var(--t-bounce);
  overflow: hidden;
}

.modal-overlay.is-open .modal {
  transform: translateY(0) scale(1);
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-lg) var(--s-xl) 0;
}

.modal__header h2 {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--c-text);
}

.modal__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: #F1F5F9;
  border: none;
  border-radius: 50%;
  color: var(--c-text-muted);
  cursor: pointer;
  transition: all var(--t-fast);
}

.modal__close:hover {
  background: #E2E8F0;
  color: var(--c-text);
  transform: scale(1.05);
}

.modal__body {
  padding: var(--s-lg) var(--s-xl);
  display: flex;
  flex-direction: column;
  gap: var(--s-lg);
}

.modal__footer {
  padding: 0 var(--s-xl) var(--s-lg);
  display: flex;
  justify-content: flex-end;
  gap: var(--s-sm);
}

/* ── Form ── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--c-text);
}

.form-input {
  padding: 0.6rem 1rem;
  background: #F8FAFC;
  border: 2px solid #E2E8F0;
  border-radius: var(--r-md);
  color: var(--c-text);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  outline: none;
  transition: all var(--t-fast);
}

.form-input::placeholder {
  color: #94A3B8;
  font-weight: 400;
}

.form-input:focus {
  border-color: var(--c-accent);
  background: #FFFFFF;
  box-shadow: 0 0 0 4px rgba(255, 77, 77, 0.15);
}

.form-hint {
  font-size: 0.75rem;
  color: var(--c-text-muted);
  font-weight: 500;
}

/* ── Toast ── */
.toast-container {
  position: fixed;
  bottom: var(--s-lg);
  right: var(--s-lg);
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: var(--s-sm);
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--s-sm);
  padding: 0.6rem 1rem;
  background: #FFFFFF;
  border-radius: var(--r-pill);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--c-text);
  box-shadow: var(--shadow-float);
  border: 1px solid #E2E8F0;
  animation: toastIn 0.4s var(--t-bounce) both;
}

.toast--success { border-left: 4px solid var(--c-success); }
.toast--error   { border-left: 4px solid var(--c-error); }
.toast--info    { border-left: 4px solid var(--c-accent-2); }

.toast.is-leaving {
  animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(20px) scale(0.9); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(20px) scale(0.9); }
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .header {
    top: 0.5rem;
  }
  .header__inner {
    padding: var(--s-sm) var(--s-md);
  }
  .header__title {
    font-size: 1rem;
  }
  .btn span {
    display: none;
  }
  .stats {
    flex-wrap: wrap;
    gap: var(--s-md);
  }
  .grid {
    grid-template-columns: 1fr;
  }
}

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

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

::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: var(--r-pill);
  border: 2px solid var(--c-bg);
}

::-webkit-scrollbar-thumb:hover {
  background: #94A3B8;
}
