/* ============================================================
   report.css — Kujco Daily Progress Reporting Portal
   Standalone: does NOT import or modify style.css
   ============================================================ */

/* ── Design Tokens ──────────────────────────────────────────── */
:root {
  --font-body: "Manrope", "Segoe UI", sans-serif;
  --font-display: "Space Grotesk", "Segoe UI", sans-serif;

  --brand-1: #f29f05;
  --brand-2: #ed5b2f;
  --brand-3: #ffd166;
  --brand-grd: linear-gradient(120deg, var(--brand-1), var(--brand-2));

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;

  --shadow-sm: 0 8px 24px rgba(0,0,0,0.07);
  --shadow-md: 0 20px 48px rgba(0,0,0,0.13);
  --shadow-lg: 0 32px 72px rgba(0,0,0,0.18);
  --transition: 220ms ease;

  /* Light mode */
  --bg:           #f4f6fa;
  --bg-elev:      #ffffff;
  --bg-panel:     rgba(255,255,255,0.72);
  --bg-input:     #f0f2f7;
  --text:         #1d2936;
  --text-soft:    #4b5a69;
  --text-muted:   #8da0b3;
  --border:       rgba(16,24,40,0.10);
  --border-focus: var(--brand-1);
  --overlay-bg:   rgba(15,23,35,0.55);
  --header-bg:    rgba(244,246,250,0.85);
  --success:      #2ec17b;
  --error:        #e53e3e;
  --warning:      #f59e0b;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:           #0b1220;
    --bg-elev:      #121d2e;
    --bg-panel:     rgba(18,29,46,0.82);
    --bg-input:     #0f1929;
    --text:         #e7edf5;
    --text-soft:    #9eb0c4;
    --text-muted:   #5a7390;
    --border:       rgba(151,172,195,0.18);
    --header-bg:    rgba(11,18,32,0.88);
    --overlay-bg:   rgba(0,0,0,0.72);
  }
}

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

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

h1, h2, h3, h4 { font-family: var(--font-display); }

a { color: inherit; text-decoration: none; }

button, input, select, textarea {
  font-family: var(--font-body);
  font-size: 1rem;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--brand-1);
  border-radius: 99px;
  opacity: 0.6;
}

/* ── Utility ────────────────────────────────────────────────── */
.gradient-text {
  background: var(--brand-grd);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.5rem;
  border: none; border-radius: 999px;
  padding: 0.78rem 1.4rem;
  font-weight: 700; font-size: 0.9rem; letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition);
  background: var(--brand-grd);
  color: #fff;
  box-shadow: 0 10px 28px rgba(237,91,47,0.28);
  white-space: nowrap;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 14px 32px rgba(237,91,47,0.38); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

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

.btn-ghost {
  background: transparent;
  color: var(--text-soft);
  box-shadow: none;
  border: none;
}
.btn-ghost:hover { color: var(--brand-2); background: transparent; box-shadow: none; }

.btn-google {
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.btn-google:hover { background: var(--bg-input); box-shadow: var(--shadow-md); }

.btn-sm { padding: 0.5rem 1rem; font-size: 0.82rem; }
.btn-full { width: 100%; }
.btn-danger { background: var(--error); box-shadow: 0 8px 20px rgba(229,62,62,0.25); }
.btn-danger:hover { box-shadow: 0 12px 28px rgba(229,62,62,0.38); }

/* ── Page Layout ────────────────────────────────────────────── */
.rp-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Animated Header Strip ──────────────────────────────────── */
.rp-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 0 clamp(1rem, 4vw, 3rem);
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}

.rp-header::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--brand-grd);
  background-size: 200% 100%;
  animation: headerShimmer 3s linear infinite;
}

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

.rp-logo {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.rp-logo-badge {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--brand-grd);
  display: grid; place-items: center;
  font-size: 0.78rem;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}

.rp-header-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.rp-user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--brand-grd);
  display: grid; place-items: center;
  font-weight: 800;
  font-size: 0.85rem;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}

.rp-user-avatar img {
  width: 100%; height: 100%;
  object-fit: cover;
}

.rp-user-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Login Wall ─────────────────────────────────────────────── */
#login-wall {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background:
    radial-gradient(circle at 20% 20%, rgba(242,159,5,0.25) 0%, transparent 45%),
    radial-gradient(circle at 80% 80%, rgba(237,91,47,0.22) 0%, transparent 45%),
    var(--bg);
  position: relative;
}

#login-wall::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(transparent 97%, rgba(0,0,0,0.04) 97%),
    linear-gradient(90deg, transparent 97%, rgba(0,0,0,0.04) 97%);
  background-size: 28px 28px;
  opacity: 0.4;
  pointer-events: none;
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-panel);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: clamp(1.8rem, 5vw, 2.8rem);
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
  animation: cardEntrance 0.55s cubic-bezier(0.16,1,0.3,1) both;
}

@keyframes cardEntrance {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.login-card-badge {
  width: 52px; height: 52px;
  border-radius: 16px;
  background: var(--brand-grd);
  display: grid; place-items: center;
  margin-bottom: 1.4rem;
  box-shadow: 0 10px 28px rgba(242,159,5,0.35);
}

.login-card-badge svg {
  width: 28px; height: 28px;
  fill: #fff;
}

.login-card h1 {
  font-size: 1.7rem;
  line-height: 1.15;
  margin-bottom: 0.4rem;
}

.login-card p.subtitle {
  color: var(--text-soft);
  font-size: 0.95rem;
  margin-bottom: 1.8rem;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.4rem 0;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
}
.login-divider::before, .login-divider::after {
  content: ""; flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Form Elements ──────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 0.42rem;
  margin-bottom: 1rem;
}

.field label {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-soft);
  letter-spacing: 0.02em;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 0.78rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--brand-1);
  box-shadow: 0 0 0 3px rgba(242,159,5,0.18);
  background: var(--bg-elev);
}

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

.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238da0b3' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
  cursor: pointer;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}

.field-error {
  font-size: 0.8rem;
  color: var(--error);
  margin-top: 0.2rem;
  display: none;
}
.field.has-error .field-error { display: block; }
.field.has-error input,
.field.has-error select,
.field.has-error textarea {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(229,62,62,0.15);
}

/* ── Dashboard ──────────────────────────────────────────────── */
#dashboard {
  flex: 1;
  width: min(1140px, 95vw);
  margin: 0 auto;
  padding: 2rem 0 4rem;
}

.dash-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 1.5rem;
  align-items: start;
}

/* ── Panel / Card ───────────────────────────────────────────── */
.panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.panel-header {
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.panel-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.panel-title .panel-icon {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--brand-grd);
  display: grid; place-items: center;
  flex-shrink: 0;
}

.panel-title .panel-icon svg {
  width: 16px; height: 16px;
  fill: #fff;
}

.panel-body {
  padding: 1.5rem;
}

/* ── Section Headings ───────────────────────────────────────── */
.dash-welcome {
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.dash-welcome h2 {
  font-size: clamp(1.3rem, 3vw, 1.8rem);
  line-height: 1.2;
}

.dash-date-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text-soft);
  box-shadow: var(--shadow-sm);
}

/* ── Image Upload Zone ──────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 1.8rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  position: relative;
  overflow: hidden;
}

.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--brand-1);
  background: rgba(242,159,5,0.05);
}

.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.upload-zone-icon {
  width: 48px; height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(242,159,5,0.15), rgba(237,91,47,0.12));
  border: 1px solid rgba(242,159,5,0.25);
  display: grid; place-items: center;
  margin: 0 auto 0.8rem;
}

.upload-zone-icon svg {
  width: 24px; height: 24px;
  stroke: var(--brand-1);
  fill: none;
}

.upload-zone p {
  font-size: 0.9rem;
  color: var(--text-soft);
}

.upload-zone strong {
  color: var(--brand-1);
}

.upload-zone small {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ── Image Preview Grid ─────────────────────────────────────── */
.image-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 0.6rem;
  margin-top: 0.9rem;
}

.preview-thumb {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 1;
  background: var(--bg-input);
  box-shadow: var(--shadow-sm);
  animation: thumbPop 0.3s cubic-bezier(0.16,1,0.3,1) both;
}

@keyframes thumbPop {
  from { opacity: 0; transform: scale(0.8); }
  to   { opacity: 1; transform: scale(1); }
}

.preview-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}

.preview-thumb-remove {
  position: absolute;
  top: 4px; right: 4px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: rgba(0,0,0,0.65);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 700;
  display: grid; place-items: center;
  line-height: 1;
  transition: background var(--transition);
}

.preview-thumb-remove:hover { background: var(--error); }

/* ── Upload Progress Bar ────────────────────────────────────── */
.upload-progress-wrap {
  margin-top: 0.6rem;
  display: none;
}

.upload-progress-wrap.visible { display: block; }

.upload-progress-bar-bg {
  height: 6px;
  border-radius: 99px;
  background: var(--bg-input);
  overflow: hidden;
}

.upload-progress-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--brand-grd);
  width: 0%;
  transition: width 0.3s ease;
}

.upload-progress-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

/* ── Past Reports Sidebar ───────────────────────────────────── */
.report-history-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.report-history-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.report-history-empty svg {
  width: 40px; height: 40px;
  stroke: var(--text-muted);
  fill: none;
  margin: 0 auto 0.75rem;
  display: block;
}

.history-card {
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-elev);
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
  position: relative;
}

.history-card:hover {
  border-color: var(--brand-1);
  box-shadow: var(--shadow-sm);
  transform: translateX(3px);
}

.history-card-date {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--brand-2);
  letter-spacing: 0.03em;
  margin-bottom: 0.3rem;
}

.history-card-project {
  font-weight: 700;
  font-size: 0.92rem;
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-card-snippet {
  font-size: 0.82rem;
  color: var(--text-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-card-images {
  display: flex;
  gap: 4px;
  margin-top: 0.55rem;
  flex-wrap: wrap;
}

.history-thumb {
  width: 32px; height: 32px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--border);
}

.history-thumb-more {
  width: 32px; height: 32px;
  border-radius: 6px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  display: grid; place-items: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-soft);
}

/* ── Report Detail Modal ────────────────────────────────────── */
.rp-modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 500;
  display: grid;
  place-items: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.rp-modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.rp-modal {
  width: 100%;
  max-width: 620px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  transform: scale(0.94);
  transition: transform 0.28s cubic-bezier(0.16,1,0.3,1);
}

.rp-modal-overlay.open .rp-modal { transform: scale(1); }

.rp-modal-head {
  padding: 1.3rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  position: sticky;
  top: 0;
  background: var(--bg-elev);
  z-index: 1;
}

.rp-modal-title { font-size: 1.05rem; font-weight: 700; }
.rp-modal-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-input);
  cursor: pointer;
  display: grid; place-items: center;
  font-size: 1rem;
  color: var(--text-soft);
  transition: background var(--transition), color var(--transition);
}
.rp-modal-close:hover { background: var(--error); color: #fff; border-color: var(--error); }

.rp-modal-body { padding: 1.5rem; }

.modal-field-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.9rem;
  flex-wrap: wrap;
}

.modal-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

.modal-badge-brand {
  background: rgba(242,159,5,0.14);
  color: var(--brand-1);
  border: 1px solid rgba(242,159,5,0.28);
}

.modal-badge-soft {
  background: var(--bg-input);
  color: var(--text-soft);
  border: 1px solid var(--border);
}

.modal-section-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 0.4rem;
}

.modal-section-value {
  font-size: 0.95rem;
  color: var(--text);
  line-height: 1.65;
  margin-bottom: 1.2rem;
  white-space: pre-wrap;
}

.modal-images-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 0.6rem;
  margin-top: 0.4rem;
}

.modal-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  border: 1px solid var(--border);
}

.modal-img:hover { transform: scale(1.04); box-shadow: var(--shadow-md); }

/* ── Image Lightbox ─────────────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 999;
  display: grid;
  place-items: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.lightbox.open {
  opacity: 1;
  pointer-events: all;
}

.lightbox img {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}

.lightbox-close {
  position: absolute;
  top: 1rem; right: 1rem;
  width: 40px; height: 40px;
  background: rgba(255,255,255,0.12);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: grid; place-items: center;
  font-size: 1.2rem;
  color: #fff;
  transition: background var(--transition);
}
.lightbox-close:hover { background: var(--error); }

/* ── Toast Notifications ────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 900;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.9rem 1.2rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: 0.9rem;
  font-weight: 600;
  min-width: 260px;
  max-width: 360px;
  pointer-events: all;
  animation: toastIn 0.35s cubic-bezier(0.16,1,0.3,1) both;
  border: 1px solid rgba(255,255,255,0.1);
}

.toast.removing { animation: toastOut 0.3s ease forwards; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px) scale(0.95); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toastOut {
  to   { opacity: 0; transform: translateX(40px) scale(0.95); }
}

.toast-success { background: #0f2a1c; color: #6ee7a8; }
.toast-error   { background: #2a0f0f; color: #fca5a5; }
.toast-info    { background: #0f1e2a; color: #93c5fd; }

.toast-icon {
  width: 22px; height: 22px;
  flex-shrink: 0;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 0.75rem;
}

.toast-success .toast-icon { background: var(--success); color: #fff; }
.toast-error   .toast-icon { background: var(--error);   color: #fff; }
.toast-info    .toast-icon { background: #3b82f6;        color: #fff; }

/* ── Loading Spinner ────────────────────────────────────────── */
.spinner {
  width: 18px; height: 18px;
  border: 2.5px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}

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

.skeleton {
  background: linear-gradient(90deg, var(--bg-input) 25%, var(--bg-elev) 50%, var(--bg-input) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-sm);
}

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

/* ── Auth Error Banner ──────────────────────────────────────── */
.auth-error {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  background: rgba(229,62,62,0.1);
  border: 1px solid rgba(229,62,62,0.3);
  color: var(--error);
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 0.9rem;
  display: none;
}

.auth-error.visible { display: block; }

/* ── Form submit row ────────────────────────────────────────── */
.form-submit-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

/* ── Character counter ──────────────────────────────────────── */
.char-counter {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: right;
  margin-top: 0.2rem;
}

/* ── Stats Strip ────────────────────────────────────────────── */
.stats-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.8rem;
  margin-bottom: 1.5rem;
}

.stat-chip {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow-sm);
}

.stat-chip-value {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 0.25rem;
}

.stat-chip-label {
  font-size: 0.78rem;
  color: var(--text-soft);
  font-weight: 600;
}

/* ── Loading overlay ────────────────────────────────────────── */
.page-loading {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 9999;
  display: grid;
  place-items: center;
  flex-direction: column;
  gap: 1rem;
  transition: opacity 0.4s ease;
}

.page-loading.hidden {
  opacity: 0;
  pointer-events: none;
}

.page-loading-logo {
  width: 56px; height: 56px;
  border-radius: 18px;
  background: var(--brand-grd);
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.2rem;
  color: #fff;
  box-shadow: 0 12px 32px rgba(242,159,5,0.35);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1);    box-shadow: 0 12px 32px rgba(242,159,5,0.35); }
  50%       { transform: scale(1.06); box-shadow: 0 18px 48px rgba(242,159,5,0.5);  }
}

/* ── Responsive — Tablet ────────────────────────────────────── */
@media (max-width: 900px) {
  .dash-grid {
    grid-template-columns: 1fr;
  }

  #dashboard {
    padding: 1.5rem 0 4rem;
  }

  .stats-strip {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ── Responsive — Mobile Portrait (≤ 600px) ─────────────────── */
@media (max-width: 600px) {

  /* --- Header --- */
  .rp-header {
    padding: 0 max(1rem, env(safe-area-inset-right)) 0 max(1rem, env(safe-area-inset-left));
    height: 60px;
  }
  .rp-user-name { display: none; }
  .rp-logo span { font-size: 0.9rem; }

  /* --- Login wall --- */
  #login-wall {
    padding: 1rem;
    align-items: flex-start;
    padding-top: calc(60px + 1.5rem);
  }

  .login-card {
    padding: 1.6rem 1.25rem 2rem;
    border-radius: var(--radius-lg);
  }

  .login-card h1 { font-size: 1.5rem; }
  .login-card p.subtitle { font-size: 0.88rem; margin-bottom: 1.4rem; }
  .login-card-badge { width: 44px; height: 44px; border-radius: 13px; margin-bottom: 1.1rem; }
  .login-card-badge svg { width: 22px; height: 22px; }

  /* --- Dashboard --- */
  #dashboard {
    padding: 1rem 0 env(safe-area-inset-bottom, 2rem);
    width: min(100%, 95vw);
  }

  .dash-welcome {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 1rem;
  }

  .dash-welcome h2 { font-size: 1.35rem; }
  .dash-date-badge { font-size: 0.78rem; padding: 0.35rem 0.75rem; }

  /* --- Stats: 3-col stays but tighter --- */
  .stats-strip {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
  }

  .stat-chip { padding: 0.75rem 0.6rem; }
  .stat-chip-value { font-size: 1.3rem; }
  .stat-chip-label { font-size: 0.7rem; }

  /* --- Panels --- */
  .panel { border-radius: var(--radius-md); }
  .panel-body { padding: 1rem; }
  .panel-header { padding: 0.9rem 1rem; }
  .panel-title { font-size: 0.92rem; }

  /* --- Form fields --- */
  .field-row { grid-template-columns: 1fr; gap: 0; }

  .field input,
  .field select,
  .field textarea {
    font-size: 1rem;        /* prevent iOS zoom-in on focus */
    padding: 0.85rem 0.9rem;
  }

  .field textarea { min-height: 90px; }
  .field label { font-size: 0.82rem; }

  /* --- Upload zone --- */
  .upload-zone { padding: 1.2rem 0.75rem; }
  .upload-zone-icon { width: 40px; height: 40px; border-radius: 10px; margin-bottom: 0.6rem; }
  .upload-zone-icon svg { width: 20px; height: 20px; }
  .upload-zone p { font-size: 0.85rem; }
  .upload-zone small { font-size: 0.74rem; }

  /* --- Image preview tighter --- */
  .image-preview-grid {
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 0.45rem;
  }

  .preview-thumb-remove { width: 20px; height: 20px; font-size: 0.65rem; }

  /* --- Submit row: full-width stacked --- */
  .form-submit-row {
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-elev);
    border-top: 1px solid var(--border);
    margin: 0 -1rem -1rem;
    padding: 0.85rem 1rem max(0.85rem, env(safe-area-inset-bottom));
    justify-content: stretch;
    gap: 0.6rem;
    z-index: 10;
    box-shadow: 0 -6px 20px rgba(0,0,0,0.08);
  }

  .form-submit-row .btn {
    flex: 1;
    justify-content: center;
    padding: 0.88rem 0.75rem;
    font-size: 0.88rem;
  }

  /* --- Modal: slides up from bottom (bottom-sheet style) --- */
  .rp-modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .rp-modal {
    max-width: 100%;
    max-height: 92dvh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.16,1,0.3,1);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

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

  /* Bottom-sheet drag indicator */
  .rp-modal::before {
    content: "";
    display: block;
    width: 36px;
    height: 4px;
    border-radius: 99px;
    background: var(--border);
    margin: 0.75rem auto 0;
  }

  .rp-modal-head { padding: 0.75rem 1rem 0.9rem; }
  .rp-modal-body { padding: 1rem; }

  /* --- Modal images --- */
  .modal-images-grid {
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  }

  /* --- Lightbox close button safe area --- */
  .lightbox-close {
    top: max(1rem, env(safe-area-inset-top));
    right: max(1rem, env(safe-area-inset-right));
  }

  /* --- Toasts: full-width at bottom --- */
  .toast-container {
    right: max(0.75rem, env(safe-area-inset-right));
    left: max(0.75rem, env(safe-area-inset-left));
    bottom: max(1rem, env(safe-area-inset-bottom));
  }

  .toast {
    min-width: unset;
    max-width: 100%;
    font-size: 0.85rem;
    padding: 0.8rem 1rem;
  }

  /* --- History cards: larger tap area --- */
  .history-card { padding: 1rem 1rem; }
  .history-card-project { font-size: 0.88rem; }
  .history-card-snippet { font-size: 0.78rem; }
}

/* ── Very small portrait (≤ 380px — older Android, SE) ─────── */
@media (max-width: 380px) {
  .stats-strip {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  .stat-chip:last-child {
    grid-column: 1 / -1;
  }

  .login-card { padding: 1.3rem 1rem 1.8rem; }
  .login-card h1 { font-size: 1.35rem; }

  .rp-logo span { font-size: 0.8rem; }
  .rp-logo-badge { width: 28px; height: 28px; border-radius: 8px; font-size: 0.7rem; }
}

/* ── Landscape phone (short height) ────────────────────────── */
@media (max-height: 500px) and (orientation: landscape) {
  #login-wall {
    padding-top: calc(60px + 1rem);
    align-items: flex-start;
  }

  .login-card {
    max-height: calc(100dvh - 80px);
    overflow-y: auto;
    padding: 1.2rem 1.5rem;
  }

  .login-card-badge { display: none; }

  .rp-modal {
    max-height: 90dvh;
    overflow-y: auto;
    border-radius: var(--radius-xl);
  }

  .rp-modal-overlay {
    align-items: center;
    padding: 1rem;
  }
}

