/* ============================================================
   QuickCapture - Main Stylesheet
   Dark Mode Default | Mobile First | Minimalist
   ============================================================ */

/* ─── CSS VARIABLES ─── */
:root {
  --bg-primary: #0a0a0a;
  --bg-secondary: #1c1c1e;
  --bg-tertiary: #2c2c2e;
  --bg-elevated: #3a3a3c;
  --bg-overlay: rgba(0, 0, 0, 0.7);

  --text-primary: #ffffff;
  --text-secondary: #98989d;
  --text-tertiary: #636366;
  --text-inverse: #000000;

  --accent: #48aff6;
  --accent-hover: #5ab8f7;
  --accent-muted: rgba(72, 175, 246, 0.15);

  --success: #30d158;
  --warning: #ff9f0a;
  --error: #ff453a;
  --info: #64d2ff;

  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.15);

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 350ms ease;

  --topbar-height: 56px;
  --bottom-nav-height: 64px;
  --fab-size: 56px;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', monospace;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Hide scrollbar but keep functionality */
body::-webkit-scrollbar {
  width: 0;
  height: 0;
}

/* ─── TYPOGRAPHY ─── */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

p {
  color: var(--text-secondary);
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--accent-hover);
}

/* ─── LAYOUT ─── */
.qc-body {
  padding-top: var(--topbar-height);
  padding-bottom: calc(var(--bottom-nav-height) + 16px);
}

.qc-main {
  max-width: 768px;
  margin: 0 auto;
  padding: 16px;
  min-height: calc(100vh - var(--topbar-height) - var(--bottom-nav-height));
}

/* ─── TOPBAR ─── */
.qc-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-height);
  background: rgba(10, 10, 10, 0.85);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 1000;
}

.qc-topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.qc-logo {
  width: 24px;
  height: 24px;
  color: var(--accent);
  flex-shrink: 0;
}

.qc-logo-lg {
  width: 48px;
  height: 48px;
  color: var(--accent);
}

.qc-brand-text {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-primary);
}

.qc-topbar-actions {
  display: flex;
  gap: 4px;
}

/* ─── BUTTONS ─── */
.qc-btn-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.qc-btn-icon svg {
  width: 20px;
  height: 20px;
}

.qc-btn-icon:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.qc-btn-icon:active {
  transform: scale(0.92);
}

.qc-btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  border: none;
  background: var(--accent);
  color: var(--text-inverse);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  min-height: 48px;
}

.qc-btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(72, 175, 246, 0.3);
}

.qc-btn-primary:active {
  transform: scale(0.98);
}

.qc-btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.qc-btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.qc-btn-ghost:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.qc-btn-ghost svg {
  width: 16px;
  height: 16px;
}

.qc-btn-full {
  width: 100%;
}

.qc-btn-sm {
  padding: 6px 10px;
  font-size: 12px;
}

/* ─── FORMS ─── */
.qc-form-group {
  margin-bottom: 16px;
}

.qc-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.qc-input,
.qc-textarea,
.qc-select {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 15px;
  transition: all var(--transition-fast);
  outline: none;
}

.qc-input::placeholder,
.qc-textarea::placeholder {
  color: var(--text-tertiary);
}

.qc-input:focus,
.qc-textarea:focus,
.qc-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

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

.qc-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23636366' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}

.qc-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
}

.qc-checkbox input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ─── AUTH PAGES ─── */
.qc-auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, var(--bg-primary) 0%, #111 100%);
}

.qc-auth-card {
  width: 100%;
  max-width: 400px;
  padding: 40px 32px;
  background: var(--bg-secondary);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}

.qc-auth-brand {
  text-align: center;
  margin-bottom: 32px;
}

.qc-auth-brand h1 {
  font-size: 28px;
  margin-top: 16px;
  margin-bottom: 8px;
}

.qc-auth-brand p {
  font-size: 15px;
  color: var(--text-tertiary);
}

.qc-auth-form {
  margin-bottom: 24px;
}

.qc-form-options {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.qc-auth-footer {
  text-align: center;
  font-size: 14px;
  color: var(--text-tertiary);
}

.qc-auth-footer a {
  font-weight: 600;
}

/* ─── DASHBOARD ─── */
.qc-dashboard {
  padding-bottom: 80px;
}

.qc-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  margin-top: 24px;
}

.qc-section-header:first-child {
  margin-top: 0;
}

.qc-section-title {
  font-size: 20px;
  font-weight: 700;
}

.qc-section-count {
  font-size: 13px;
  color: var(--text-tertiary);
  background: var(--bg-tertiary);
  padding: 4px 10px;
  border-radius: 20px;
}

/* ─── STATS CARDS ─── */
.qc-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.qc-stat-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  border: 1px solid var(--border);
  transition: all var(--transition-fast);
}

.qc-stat-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
}

.qc-stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 4px;
}

.qc-stat-label {
  font-size: 12px;
  color: var(--text-tertiary);
  font-weight: 500;
}

/* ─── NOTE CARDS ─── */
.qc-notes-grid {
  display: grid;
  gap: 12px;
}

.qc-note-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 16px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.qc-note-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.qc-note-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.qc-note-card:hover::before {
  opacity: 1;
}

.qc-note-card.pinned {
  border-left: 3px solid var(--warning);
}

.qc-note-card.favorite {
  border-left: 3px solid #ff453a;
}

.qc-note-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 8px;
}

.qc-note-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
  flex: 1;
  margin-right: 8px;
}

.qc-note-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.qc-note-card:hover .qc-note-actions {
  opacity: 1;
}

.qc-note-action-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.qc-note-action-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.qc-note-action-btn.active {
  color: var(--warning);
}

.qc-note-content {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 12px;
}

.qc-note-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--text-tertiary);
}

.qc-note-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.qc-note-meta svg {
  width: 14px;
  height: 14px;
}

.qc-note-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.qc-note-tag {
  font-size: 11px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--accent-muted);
  color: var(--accent);
}

.qc-note-attachments {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.qc-note-thumb {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--bg-tertiary);
}

/* ─── EMPTY STATE ─── */
.qc-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-tertiary);
}

.qc-empty svg {
  width: 48px;
  height: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.qc-empty h3 {
  font-size: 18px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.qc-empty p {
  font-size: 14px;
}

/* ─── SEARCH ─── */
.qc-search-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 2000;
  display: none;
  flex-direction: column;
  padding: 16px;
  padding-top: calc(var(--topbar-height) + 16px);
}

.qc-search-overlay.active {
  display: flex;
}

.qc-search-box {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  border: 1px solid var(--border);
}

.qc-search-icon {
  width: 20px;
  height: 20px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.qc-search-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 16px;
  outline: none;
}

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

.qc-search-close {
  flex-shrink: 0;
}

.qc-search-results {
  margin-top: 16px;
  overflow-y: auto;
  flex: 1;
}

/* ─── FLOATING ACTION BUTTON ─── */
.qc-fab {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + 16px);
  right: 16px;
  width: var(--fab-size);
  height: var(--fab-size);
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--text-inverse);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(72, 175, 246, 0.4);
  transition: all var(--transition-base);
  z-index: 900;
}

.qc-fab svg {
  width: 24px;
  height: 24px;
}

.qc-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(72, 175, 246, 0.5);
}

.qc-fab:active {
  transform: scale(0.95);
}

/* ─── BOTTOM NAVIGATION ─── */
.qc-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background: rgba(10, 10, 10, 0.9);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 1000;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.qc-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  color: var(--text-tertiary);
  text-decoration: none;
  font-size: 11px;
  font-weight: 500;
  transition: color var(--transition-fast);
  border: none;
  background: transparent;
  cursor: pointer;
}

.qc-nav-item svg {
  width: 22px;
  height: 22px;
  stroke-width: 2;
  transition: all var(--transition-fast);
}

.qc-nav-item.active,
.qc-nav-item:hover {
  color: var(--accent);
}

.qc-nav-item.active svg {
  stroke-width: 2.5;
}

/* ─── MODAL ─── */
.qc-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3000;
  display: none;
  align-items: flex-end;
  justify-content: center;
}

.qc-modal.active {
  display: flex;
}

.qc-modal-backdrop {
  position: absolute;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.qc-modal-content {
  position: relative;
  background: var(--bg-secondary);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  animation: slideUp var(--transition-base);
  border-top: 1px solid var(--border);
}

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

.qc-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 0;
}

.qc-modal-header h3 {
  font-size: 18px;
}

.qc-modal-close {
  color: var(--text-tertiary);
}

.qc-quick-form {
  padding: 16px 20px 24px;
}

.qc-quick-form .qc-input,
.qc-quick-form .qc-textarea {
  margin-bottom: 12px;
  font-size: 16px;
}

.qc-quick-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.qc-reminder-input {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.qc-reminder-input .qc-input {
  flex: 2;
}

.qc-reminder-input .qc-select {
  flex: 1;
}

.qc-checklist-input {
  margin-bottom: 12px;
}

.qc-checklist-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.qc-checklist-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.qc-checklist-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.qc-checklist-row .qc-input {
  margin-bottom: 0;
  flex: 1;
}

.qc-modal-footer {
  padding-top: 8px;
}

/* ─── TOAST ─── */
.qc-toast-container {
  position: fixed;
  top: calc(var(--topbar-height) + 8px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 4000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: 90%;
  max-width: 400px;
}

.qc-toast {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toastIn var(--transition-base);
  pointer-events: auto;
}

.qc-toast.success {
  border-color: var(--success);
  color: var(--success);
}

.qc-toast.error {
  border-color: var(--error);
  color: var(--error);
}

.qc-toast.warning {
  border-color: var(--warning);
  color: var(--warning);
}

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

/* ─── SPINNER ─── */
.qc-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  display: inline-block;
}

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

/* ─── SWIPE ACTIONS (Mobile) ─── */
.qc-swipe-container {
  position: relative;
  overflow: hidden;
}

.qc-swipe-actions {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 0;
}

.qc-swipe-action {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 24px;
  color: white;
  font-weight: 600;
  font-size: 14px;
}

.qc-swipe-action.archive {
  background: var(--warning);
}

.qc-swipe-action.delete {
  background: var(--error);
}

.qc-swipe-action.pin {
  background: var(--accent);
}

/* ─── RESPONSIVE ─── */
@media (min-width: 768px) {
  .qc-main {
    padding: 24px;
  }

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

  .qc-notes-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .qc-modal-content {
    border-radius: var(--radius-xl);
    max-height: 70vh;
    margin-bottom: 40px;
  }
}

@media (min-width: 1024px) {
  .qc-notes-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .qc-fab {
    bottom: 32px;
    right: 32px;
  }
}

/* ─── REDUCED MOTION ─── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ─── OFFLINE INDICATOR ─── */
.qc-offline-bar {
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  right: 0;
  background: var(--warning);
  color: var(--text-inverse);
  text-align: center;
  padding: 6px;
  font-size: 13px;
  font-weight: 600;
  z-index: 950;
  animation: slideDown var(--transition-base);
}

@keyframes slideDown {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}

/* ─── LOADING SKELETON ─── */
.qc-skeleton {
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-elevated) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

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