/* ═══════════════════════════════════════════════════════════════════════════
   Site Launcher PWA — Styles
   Professional variant: Inter font, clean cards, blue-neutral palette.
   Inspired by ticked-off's card layout, shadows, and polish.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Design Tokens ──────────────────────────────────────────────────────── */
:root {
  /* Primary */
  --blue-50: #eff6ff;
  --blue-100: #dbeafe;
  --blue-200: #bfdbfe;
  --blue-500: #3b82f6;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;
  --blue-800: #1e40af;
  --blue-900: #1e3a8a;

  /* Neutrals (Slate) */
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;

  /* Accent Colors */
  --green-500: #22c55e;
  --green-600: #16a34a;
  --red-500: #ef4444;
  --red-600: #dc2626;
  --amber-500: #f59e0b;
  --amber-600: #d97706;

  /* Semantic */
  --bg: var(--slate-50);
  --bg-card: #ffffff;
  --bg-header: var(--blue-800);
  --text-primary: var(--slate-800);
  --text-secondary: var(--slate-500);
  --text-muted: var(--slate-400);
  --border: var(--slate-200);
  --border-strong: var(--slate-300);
  --primary: var(--blue-600);
  --primary-hover: var(--blue-700);
  --danger: var(--red-500);
  --danger-hover: var(--red-600);

  /* Shadows (inspired by ticked-off's clean shadows) */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);

  /* Radius */
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Transitions */
  --transition: all 0.15s ease;
  --transition-slow: all 0.2s ease;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Selection */
::selection {
  background: var(--blue-200);
  color: var(--blue-900);
}

/* Focus visible */
*:focus-visible {
  outline: 2px solid var(--blue-500);
  outline-offset: 2px;
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--slate-100); }
::-webkit-scrollbar-thumb {
  background: var(--slate-300);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: var(--slate-400); }

/* ─── Utility ────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.required { color: var(--danger); }

/* ─── Screen Management ──────────────────────────────────────────────────── */
.screen { display: none; }
.screen.active { display: block; }

/* ═══════════════════════════════════════════════════════════════════════════
   AUTH SCREEN
   ═══════════════════════════════════════════════════════════════════════════ */

.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: linear-gradient(135deg, var(--blue-800) 0%, var(--blue-900) 50%, var(--slate-900) 100%);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255, 255, 255, 0.1);
  padding: 2.5rem;
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-header {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-logo {
  display: inline-flex;
  margin-bottom: 1rem;
}

.auth-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--slate-900);
  letter-spacing: -0.02em;
}

.auth-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.auth-form { display: flex; flex-direction: column; gap: 1rem; }

.auth-switch {
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
}

.auth-switch a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.auth-switch a:hover { text-decoration: underline; }

/* ═══════════════════════════════════════════════════════════════════════════
   FORM ELEMENTS
   ═══════════════════════════════════════════════════════════════════════════ */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  flex: 1;
}

.form-group label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--slate-700);
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 0.625rem 0.75rem;
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--text-primary);
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  transition: var(--transition);
}

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

.form-group input:hover,
.form-group textarea:hover {
  border-color: var(--slate-300);
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-row {
  display: flex;
  gap: 1rem;
}

.form-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-top: 0.5rem;
  margin-bottom: -0.25rem;
}

.form-error {
  background: #fef2f2;
  color: var(--danger);
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid #fecaca;
}

/* URL Label Icons */
.url-label-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  font-size: 0.5625rem;
  font-weight: 700;
  color: white;
  letter-spacing: -0.02em;
}

.sp-icon { background: #1a9ba1; }
.pw-icon { background: #0067b3; }

/* Description textarea — full width, min 3 rows */
.form-group textarea {
  resize: vertical;
  min-height: 4.5rem;
}

/* Custom URL entries */
.custom-urls-section {
  margin-top: 1rem;
  margin-bottom: 0.25rem;
}

.custom-url-entry {
  margin-bottom: 0.5rem;
}

.custom-url-entry .form-row {
  align-items: flex-end;
}

.custom-url-entry .form-group {
  flex: 1;
}

.custom-url-remove {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
  height: 38px;
  width: 38px;
}

.custom-url-remove:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: #fef2f2;
}

.btn-icon {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

/* ═══════════════════════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  padding: 0.625rem 1rem;
  border-radius: var(--radius);
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.btn:active { transform: scale(0.97); }

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

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

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--slate-100); color: var(--text-primary); }

.btn-outline-light {
  background: transparent;
  color: white;
  border-color: rgba(255, 255, 255, 0.25);
}
.btn-outline-light:hover { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.4); }

.btn-sm { font-size: 0.8125rem; padding: 0.4375rem 0.75rem; }
.btn-xs { font-size: 0.6875rem; padding: 0.25rem 0.625rem; }
.btn-full { width: 100%; }

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════════════════════
   APP HEADER
   ═══════════════════════════════════════════════════════════════════════════ */

.app-header {
  background: var(--bg-header);
  color: white;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

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

.header-logo { flex-shrink: 0; }

.header-title {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.header-user {
  font-size: 0.75rem;
  opacity: 0.7;
  font-weight: 400;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.header-right-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
}

.signout-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Online Indicator */
.online-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  opacity: 0.8;
}

.online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green-500);
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
  transition: var(--transition);
}

.online-dot.offline {
  background: var(--red-500);
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.5);
}

/* ═══════════════════════════════════════════════════════════════════════════
   MAIN CONTENT
   ═══════════════════════════════════════════════════════════════════════════ */

.app-main {
  min-height: calc(100vh - 60px);
}

.content-container {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* ─── Toolbar ────────────────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.search-wrapper {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 0.625rem 2.25rem 0.625rem 2.5rem;
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--text-primary);
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  transition: var(--transition);
}

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

.search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-clear {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  border-radius: 4px;
  transition: var(--transition);
}

.search-clear:hover { color: var(--text-primary); background: var(--slate-100); }

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.results-count {
  font-size: 0.8125rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ─── Project List ───────────────────────────────────────────────────────── */
.project-list {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

/* ─── Project Card ───────────────────────────────────────────────────────── */
.project-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-slow);
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.project-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.project-card-archived {
  opacity: 0.5;
  background: var(--slate-100);
}

.project-card-archived:hover {
  opacity: 0.7;
}

.project-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.25rem;
}

.project-card-title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--slate-800);
  line-height: 1.3;
}

.project-card-number {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--slate-100);
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: 0.01em;
}

.project-card-desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 0.75rem;
  white-space: pre-line;
}

.project-card-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  position: relative;
}

/* URL Buttons */
.url-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  line-height: 1.2;
}

.url-btn:hover { filter: brightness(0.9); transform: translateY(-1px); }
.url-btn:active { transform: translateY(0); }

.url-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* SharePoint — Teal */
.url-btn-sp { background: #1a9ba1; }
/* ProjectWise — Bentley blue */
.url-btn-pw { background: #0067b3; }
/* Custom URLs — green */
.url-btn-custom { background: #E8952D; }

/* Edit/Archive/Delete buttons on card */
.card-action-btns {
  display: flex;
  gap: 0.25rem;
  position: absolute;
  right: 0;
  bottom: 0;
}

.card-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  padding: 0;
}

.card-action-btn svg {
  width: 15px;
  height: 15px;
}

.card-edit-btn:hover {
  color: var(--primary);
  background: var(--blue-50);
  border-color: var(--blue-200);
}

.card-archive-btn:hover {
  color: var(--amber-600);
  background: #fffbeb;
  border-color: #fde68a;
}

.card-delete-btn:hover {
  color: var(--danger);
  background: #fef2f2;
  border-color: #fecaca;
}

/* ─── Empty / Loading States ─────────────────────────────────────────────── */
.empty-state,
.loading-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-secondary);
}

.empty-icon { margin-bottom: 1rem; opacity: 0.4; }

.empty-state h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.375rem;
}

.empty-state p { font-size: 0.875rem; }

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--slate-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  margin: 0 auto 1rem;
  animation: spin 0.7s linear infinite;
}

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

/* ═══════════════════════════════════════════════════════════════════════════
   TOGGLE (Archived — inline in header)
   ═══════════════════════════════════════════════════════════════════════════ */

.toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.6875rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.toggle-label input {
  display: none;
}

.toggle-switch {
  position: relative;
  width: 28px;
  height: 16px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  transition: var(--transition);
  flex-shrink: 0;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  background: white;
  border-radius: 50%;
  transition: var(--transition);
}

.toggle-label input:checked + .toggle-switch {
  background: var(--blue-500);
}

.toggle-label input:checked + .toggle-switch::after {
  left: 14px;
}

/* Delete confirmation skip label */
.delete-skip-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  cursor: pointer;
  margin-top: 0.75rem;
}

.delete-skip-label input {
  accent-color: var(--primary);
}

/* ═══════════════════════════════════════════════════════════════════════════
   MODALS
   ═══════════════════════════════════════════════════════════════════════════ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
  animation: fadeIn 0.15s ease-out;
}

.modal {
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modalSlideUp 0.2s ease-out;
}

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

.modal-sm { max-width: 400px; }

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

.modal-header h2 {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--slate-800);
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  display: flex;
  transition: var(--transition);
}

.modal-close-btn:hover { color: var(--text-primary); background: var(--slate-100); }

.modal-body {
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  background: var(--slate-50);
}

.modal-footer-right {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
}

.delete-message {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ═══════════════════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════════════════════════════════════════ */

.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.75rem 1rem;
  background: var(--slate-800);
  color: white;
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.2s ease-out;
  max-width: 360px;
}

.toast.toast-success { background: var(--green-600); }
.toast.toast-error { background: var(--danger); }

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

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

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 640px) {
  .content-container { padding: 1rem; }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .search-wrapper { min-width: unset; }

  .toolbar-actions {
    justify-content: space-between;
  }

  .form-row { flex-direction: column; gap: 0.875rem; }

  .auth-card { padding: 1.75rem; }

  .header-inner { padding: 0.625rem 1rem; }

  .header-title { font-size: 1rem; }

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

  .project-card-actions { gap: 0.375rem; }

  .url-btn { padding: 0.375rem 0.625rem; font-size: 0.6875rem; }

  .modal { margin: 0.5rem; }

  .toast-container { left: 1rem; right: 1rem; bottom: 1rem; }
  .toast { max-width: 100%; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   PRINT
   ═══════════════════════════════════════════════════════════════════════════ */
@media print {
  .app-header,
  .toolbar,
  .card-edit-btn,
  .modal-overlay,
  .toast-container { display: none !important; }

  .project-card { break-inside: avoid; box-shadow: none; border: 1px solid #ccc; }
}
