/* SiteBuilder Client Dashboard - CSS */

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

:root {
  --primary: #2563EB;
  --primary-dark: #1D4ED8;
  --success: #059669;
  --warning: #D97706;
  --danger: #DC2626;
  --bg: #F8FAFC;
  --card-bg: #FFFFFF;
  --text: #1E293B;
  --text-light: #475569;
  --text-muted: #64748B;
  --border: #E2E8F0;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.04);
}

body {
  font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.text-muted { color: var(--text-muted); }
.link { color: var(--primary); cursor: pointer; }

/* --- Buttons --- */
.btn {
  display: inline-block;
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
  line-height: 1.4;
}

.btn-primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  text-decoration: none;
}

.btn-outline {
  background: white;
  color: var(--primary);
  border-color: var(--border);
}
.btn-outline:hover {
  border-color: var(--primary);
  text-decoration: none;
}

.btn-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

.btn-sm { padding: 6px 14px; font-size: 0.82rem; }
.btn-block { display: block; width: 100%; text-align: center; }

/* --- Login page --- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.login-container { width: 100%; max-width: 400px; }

.login-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 2.5rem 2rem;
}

.login-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.login-header h1 {
  font-size: 1.5rem;
  color: var(--primary);
  margin-bottom: 0.25rem;
}

.login-form {
  margin-bottom: 1.5rem;
}

.login-form label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-light);
}

.login-form input[type="email"] {
  display: block;
  width: 100%;
  padding: 10px 14px;
  font-size: 1rem;
  font-family: inherit;
  border: 2px solid var(--border);
  border-radius: 8px;
  margin-bottom: 1rem;
  transition: border-color 0.15s;
}

.login-form input[type="email"]:focus {
  outline: none;
  border-color: var(--primary);
}

.login-footer {
  text-align: center;
  font-size: 0.82rem;
  line-height: 1.7;
}

/* --- Alerts --- */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.alert-error {
  background: #FEF2F2;
  color: #991B1B;
  border: 1px solid #FECACA;
}

.alert-success {
  background: #ECFDF5;
  color: #065F46;
  border: 1px solid #A7F3D0;
}

.alert-info {
  background: #EFF6FF;
  color: #1E40AF;
  border: 1px solid #BFDBFE;
}

/* --- Dashboard header --- */
.dashboard-header {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 0 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  gap: 12px;
}

.header-title {
  font-size: 1.1rem;
  color: var(--primary);
  margin: 0;
}

.header-client {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-left: 12px;
}

.header-brand {
  display: flex;
  align-items: baseline;
  gap: 4px;
  flex-wrap: wrap;
}

.client-switcher {
  font-family: inherit;
  font-size: 0.82rem;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  color: var(--text);
  cursor: pointer;
  margin-left: 8px;
}

/* --- Header nav --- */
.header-nav {
  display: flex;
  gap: 4px;
  align-items: center;
}

.nav-link {
  display: inline-block;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-light);
  border-radius: 6px;
  text-decoration: none;
  background: none;
  border: none;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover {
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
}

.nav-link.active {
  background: var(--bg);
  color: var(--primary);
  font-weight: 600;
}

.nav-signout {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.nav-signout:hover { color: var(--danger); }

/* --- Hamburger --- */
.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  flex-direction: column;
  gap: 5px;
}

.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
  transition: transform 0.2s, opacity 0.2s;
}

.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* --- Dashboard main --- */
.dashboard-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

.greeting h2 {
  font-size: 1.4rem;
  margin-bottom: 1rem;
}

.dashboard-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  align-items: start;
}

.card + .card,
.card + .dashboard-row,
.dashboard-row + .card,
.dashboard-row + a {
  margin-top: 1.25rem;
}

.card-compact { padding: 1rem; }
.card-compact .card-title { margin-bottom: 0.5rem; }

/* --- Cards --- */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

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

.card-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

/* --- Pending actions --- */
.pending-card {
  padding: 14px;
  border-radius: 8px;
  margin-bottom: 10px;
  border-left: 4px solid var(--primary);
  background: #F8FAFC;
}

.pending-card:last-child { margin-bottom: 0; }

.pending-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.pending-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--primary);
}

.pending-confirm { border-left-color: var(--success); }
.pending-confirm .pending-label { color: var(--success); }
.pending-approval { border-left-color: var(--primary); }
.pending-clarification { border-left-color: var(--warning); }
.pending-clarification .pending-label { color: var(--warning); }
.pending-image { border-left-color: var(--primary); }
.pending-destructive { border-left-color: var(--danger); }
.pending-destructive .pending-label { color: var(--danger); }

.pending-detail {
  font-size: 0.88rem;
  color: var(--text-light);
  margin: 8px 0;
  padding: 8px 12px;
  background: white;
  border-radius: 6px;
  white-space: pre-wrap;
}

.pending-actions { margin-top: 10px; }

/* --- Timeline --- */
.timeline-entry {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.timeline-entry:last-child { border-bottom: none; }

.timeline-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.change-id {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.78rem;
  font-weight: 600;
  background: #EFF6FF;
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 4px;
}

.timeline-date {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.timeline-request {
  font-size: 0.88rem;
  color: var(--text-light);
  margin-bottom: 2px;
}

.timeline-summary {
  font-size: 0.88rem;
  color: var(--text);
  font-style: italic;
}

.timeline-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
  display: flex;
  gap: 12px;
}

.rating {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
}
.rating-nailed_it { background: #ECFDF5; color: #065F46; }
.rating-close { background: #FEF3C7; color: #92400E; }
.rating-not_quite { background: #FEF2F2; color: #991B1B; }

/* --- Collapsible content --- */
.collapsible-body {
  max-height: 120px;
  overflow: hidden;
  position: relative;
  transition: max-height 0.25s ease;
}

.collapsible-body.expanded {
  max-height: none;
}

.collapsible-body:not(.expanded)::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40px;
  background: linear-gradient(transparent, #F8FAFC);
  pointer-events: none;
}

/* Timeline entries sit on white bg, pending cards on #F8FAFC */
.timeline-entry .collapsible-body:not(.expanded)::after {
  background: linear-gradient(transparent, var(--card-bg));
}

.collapsible-body.no-overflow {
  max-height: none;
}

.collapsible-body.no-overflow::after {
  display: none;
}

.collapsible-toggle {
  display: block;
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  padding: 4px 0;
  margin-top: 2px;
}

.collapsible-toggle:hover {
  text-decoration: underline;
}

.collapsible-toggle.hidden {
  display: none;
}

/* --- Forms --- */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-light);
}

.form-input,
.form-textarea {
  display: block;
  width: 100%;
  padding: 10px 14px;
  font-size: 0.9rem;
  font-family: inherit;
  border: 2px solid var(--border);
  border-radius: 8px;
  transition: border-color 0.15s;
  resize: vertical;
}

.form-input:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.form-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 1rem;
}

/* --- File upload --- */
.file-upload input[type="file"] { display: none; }

.file-drop {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
}

.file-drop input[type="file"] {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  opacity: 0;
  cursor: pointer;
}

.file-drop:hover,
.file-drop.drag-over {
  border-color: var(--primary);
  background: #F0F6FF;
}

.file-item {
  font-size: 0.82rem;
  padding: 6px 10px;
  background: #F1F5F9;
  border-radius: 6px;
  margin-top: 6px;
}

/* --- Site links --- */
.site-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  transition: border-color 0.15s;
}

.site-link:hover {
  border-color: var(--primary);
  text-decoration: none;
}

.site-link-label { font-weight: 600; font-size: 0.9rem; }
.site-link-arrow { font-size: 1.1rem; }

/* --- Usage bars --- */
.usage-section { margin-top: 1rem; }

.usage-title {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-light);
}

.usage-bar-container { margin-bottom: 8px; }

.usage-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.usage-bar {
  height: 6px;
  background: #E2E8F0;
  border-radius: 3px;
  overflow: hidden;
}

.usage-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.usage-fill.over-limit {
  background: var(--warning);
}

/* --- Changes section (unpublished changes hero) --- */
.changes-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.changes-count {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
}

.changes-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.site-links-inline {
  display: flex;
  gap: 10px;
  align-items: center;
}

.site-links-inline a {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--primary);
  text-decoration: none;
  white-space: nowrap;
}

.site-links-inline a:hover {
  text-decoration: underline;
}

/* --- Action Needed section --- */
.action-needed-section {
  margin-top: 1.25rem;
}

.action-needed-section .card-subtitle {
  margin-bottom: 1rem;
}

/* --- Status strip --- */
.status-strip {
  margin-top: 1.25rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  padding: 8px 0;
}

/* --- Footer --- */
.dashboard-footer {
  text-align: center;
  padding: 2rem 1rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .dashboard-row {
    grid-template-columns: 1fr;
  }

  .hamburger {
    display: flex;
  }

  .header-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    flex-direction: column;
    padding: 8px;
    gap: 2px;
  }

  .header-nav.open {
    display: flex;
  }

  .header-inner {
    flex-wrap: wrap;
    position: relative;
  }

  .header-client {
    display: block;
    margin-left: 0;
  }

  .nav-link {
    display: block;
    padding: 10px 14px;
    border-radius: 8px;
  }

  .greeting h2 {
    font-size: 1.2rem;
  }

  .changes-section {
    flex-direction: column;
    align-items: flex-start;
  }

  .changes-actions {
    width: 100%;
  }

  .changes-actions .btn {
    flex: 1;
  }

  .card { padding: 1rem; }
  .card-compact { padding: 0.875rem; }
}

@media (max-width: 480px) {
  .form-row {
    flex-direction: column;
    align-items: stretch;
  }

  .form-row .btn {
    width: 100%;
    text-align: center;
  }
}
