/* Lightward Universal Cloud Sync & Auth Styles */
:root {
  --lw-sync-primary: #1548b5;
  --lw-sync-primary-hover: #0c3991;
  --lw-sync-success: #10b981;
  --lw-sync-warning: #f59e0b;
  --lw-sync-danger: #ef4444;
  --lw-sync-bg: rgba(15, 23, 42, 0.95);
  --lw-sync-card-bg: #1e293b;
  --lw-sync-border: rgba(255, 255, 255, 0.12);
  --lw-sync-text: #f8fafc;
  --lw-sync-muted: #94a3b8;
}

/* Ensure profile switcher trigger looks polished and seamless in topbar */
.profile-switcher {
  position: relative;
  display: inline-flex !important;
  align-items: center;
  margin: 0 4px;
}

.profile-switcher-trigger {
  cursor: pointer;
  user-select: none;
}

.lw-sync-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  margin-right: 2px;
}

.lw-sync-indicator.synced { background: var(--lw-sync-success); box-shadow: 0 0 6px var(--lw-sync-success); }
.lw-sync-indicator.syncing { background: var(--lw-sync-warning); box-shadow: 0 0 6px var(--lw-sync-warning); animation: lw-pulse 1.2s infinite; }
.lw-sync-indicator.offline { background: var(--lw-sync-muted); }
.lw-sync-indicator.signed-out { background: #38bdf8; }
.lw-sync-indicator.error { background: var(--lw-sync-danger); box-shadow: 0 0 6px var(--lw-sync-danger); }

@keyframes lw-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

/* Modal Overlay */
.lw-sync-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: lw-fade-in 0.2s ease-out;
}

@keyframes lw-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Modal Card */
.lw-sync-modal-card {
  background: var(--lw-sync-card-bg);
  border: 1px solid var(--lw-sync-border);
  border-radius: 16px;
  width: 100%;
  max-width: 420px;
  color: var(--lw-sync-text);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  position: relative;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  animation: lw-slide-up 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes lw-slide-up {
  from { transform: translateY(20px) scale(0.97); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.lw-sync-modal-header {
  padding: 20px 24px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--lw-sync-border);
}

.lw-sync-modal-title {
  font-size: 18px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.lw-sync-modal-close {
  background: transparent;
  border: none;
  color: var(--lw-sync-muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
}

.lw-sync-modal-close:hover {
  color: var(--lw-sync-text);
}

.lw-sync-modal-body {
  padding: 24px;
}

/* Tabs */
.lw-sync-tabs {
  display: flex;
  background: rgba(15, 23, 42, 0.6);
  padding: 4px;
  border-radius: 10px;
  margin-bottom: 20px;
}

.lw-sync-tab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--lw-sync-muted);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.lw-sync-tab.active {
  background: var(--lw-sync-primary);
  color: white;
  box-shadow: 0 2px 8px rgba(21, 72, 181, 0.4);
}

/* Form controls */
.lw-sync-form-group {
  margin-bottom: 16px;
}

.lw-sync-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--lw-sync-muted);
}

.lw-sync-input {
  width: 100%;
  box-sizing: border-box;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--lw-sync-border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--lw-sync-text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.lw-sync-input:focus {
  border-color: var(--lw-sync-primary);
  box-shadow: 0 0 0 3px rgba(21, 72, 181, 0.3);
}

.lw-sync-btn-primary {
  width: 100%;
  background: var(--lw-sync-primary);
  border: none;
  border-radius: 8px;
  padding: 11px 16px;
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.lw-sync-btn-primary:hover {
  background: var(--lw-sync-primary-hover);
}

.lw-sync-btn-primary:active {
  transform: scale(0.99);
}

.lw-sync-btn-secondary {
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--lw-sync-border);
  border-radius: 8px;
  padding: 10px 16px;
  color: var(--lw-sync-text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 10px;
}

.lw-sync-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.14);
}

/* Alert messages */
.lw-sync-alert {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}
.lw-sync-alert.error { background: rgba(239, 68, 68, 0.2); border: 1px solid rgba(239, 68, 68, 0.4); color: #fca5a5; }
.lw-sync-alert.success { background: rgba(16, 185, 129, 0.2); border: 1px solid rgba(16, 185, 129, 0.4); color: #6ee7b7; }

/* Profile View when Logged In */
.lw-sync-profile-info {
  background: rgba(15, 23, 42, 0.6);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
  border: 1px solid var(--lw-sync-border);
}

.lw-sync-user-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.lw-sync-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--lw-sync-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  color: white;
}

.lw-sync-user-details h4 {
  margin: 0 0 4px 0;
  font-size: 16px;
  font-weight: 600;
}

.lw-sync-user-details p {
  margin: 0;
  font-size: 12px;
  color: var(--lw-sync-muted);
}

.lw-sync-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  font-size: 12px;
  color: var(--lw-sync-muted);
  border-top: 1px solid var(--lw-sync-border);
  padding-top: 12px;
}

.lw-sync-meta-item strong {
  display: block;
  color: var(--lw-sync-text);
  font-size: 13px;
  margin-bottom: 2px;
}

/* ==========================================================================
   Mobile & Portrait Mode Reader Toolbar & Dropdown Cleanup
   ========================================================================== */

@media (max-width: 820px), (orientation: portrait) {
  /* Toolbar Container: clean column layout with subtle shadow */
  .app-shell.web-zoom-mobile .reader-toolbar,
  .reader-toolbar {
    min-height: auto !important;
    padding: 8px 12px 6px !important;
    gap: 6px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    background: var(--surface, #1e293b) !important;
    border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.12)) !important;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25) !important;
  }

  /* Grid layout for Passage Selectors */
  .app-shell.web-zoom-mobile .passage-selectors,
  .passage-selectors {
    display: grid !important;
    width: 100% !important;
    grid-template-columns: minmax(0, 1.55fr) minmax(95px, 1fr) !important;
    grid-template-rows: auto auto !important;
    gap: 6px !important;
    align-items: center !important;
  }

  /* Row 1: Source / Translation dropdown (e.g. 1876 Doctrine and Covenants, NIV, KJV) spans full width */
  .passage-source-select,
  .app-shell.web-zoom-mobile .passage-source-select {
    grid-column: 1 / -1 !important;
    grid-row: 1 !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  /* Row 2: Book dropdown on the left */
  .passage-book-select,
  .app-shell.web-zoom-mobile .passage-book-select {
    grid-column: 1 !important;
    grid-row: 2 !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  /* Row 2: Chapter / Section dropdown on the right */
  .passage-chapter-select,
  .app-shell.web-zoom-mobile .passage-chapter-select {
    grid-column: 2 !important;
    grid-row: 2 !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  /* Hide the duplicate history buttons in the dropdown row (already in top strip) */
  .reader-history-buttons,
  .app-shell.web-zoom-mobile .reader-history-buttons {
    display: none !important;
  }

  /* Jump select spans full width if active */
  .passage-chapter-jump-select,
  .app-shell.web-zoom-mobile .passage-chapter-jump-select {
    grid-column: 1 / -1 !important;
    width: 100% !important;
  }

  /* Styled Dropdowns: modern, legible, tactile 38px tap target with custom chevron */
  .passage-selectors select,
  .app-shell.web-zoom-mobile .passage-selectors select {
    appearance: none !important;
    -webkit-appearance: none !important;
    height: 38px !important;
    line-height: 38px !important;
    padding: 0 32px 0 12px !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    border-radius: 8px !important;
    background-color: var(--nav-control, #252d2b) !important;
    border: 1px solid var(--nav-border, rgba(255, 255, 255, 0.16)) !important;
    color: var(--text, #f8fafc) !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 10px center !important;
    background-size: 14px !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2) !important;
    transition: border-color 0.15s, background-color 0.15s !important;
  }

  .passage-selectors select:hover,
  .app-shell.web-zoom-mobile .passage-selectors select:hover {
    border-color: rgba(255, 255, 255, 0.3) !important;
    background-color: var(--nav-hover, #2d3835) !important;
  }

  .passage-selectors select:focus-visible,
  .app-shell.web-zoom-mobile .passage-selectors select:focus-visible {
    outline: 2px solid var(--focus, #3b82f6) !important;
    outline-offset: 1px !important;
    border-color: var(--focus, #3b82f6) !important;
  }

  /* Row 3: Tools bar - clean single horizontal row with smooth swipe */
  .app-shell.web-zoom-mobile .reader-tools,
  .reader-tools {
    width: 100% !important;
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 6px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    padding: 3px 0 2px !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
  }

  .reader-tools::-webkit-scrollbar {
    display: none !important;
  }

  /* All tool buttons uniform 36x36px icon-only squares */
  .reader-tools button,
  .reader-tools .secondary-button,
  .reader-tools .toggle-button,
  .reader-tools .search-panel-button,
  .reader-tools .compare-button,
  .reader-tools .present-button,
  .reader-tools .translations-button {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    flex: 0 0 36px !important;
    padding: 0 !important;
    font-size: 0 !important;
    border-radius: 7px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .reader-tools button svg,
  .reader-tools .search-panel-button svg {
    margin: auto !important;
  }
}
