/* 2.1 — CSS custom properties for theming */
:root {
  --color-primary: #4f46e5;
  --color-primary-hover: #4338ca;
  --color-bg: #f9fafb;
  --color-surface: #ffffff;
  --color-text: #111827;
  --color-text-secondary: #6b7280;
  --color-border: #e5e7eb;
  --color-error: #dc2626;
  --color-success: #16a34a;
  --color-tag-bg: #eef2ff;
  --color-tag-text: #4f46e5;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.15);
  --max-width: 640px;
  --color-delete-hover-bg: #fef2f2;
  --color-offline-bg: #fef3c7;
  --color-offline-text: #92400e;
}

/* Dark theme overrides */
[data-theme="dark"] {
  --color-bg: #111827;
  --color-surface: #1f2937;
  --color-text: #f9fafb;
  --color-text-secondary: #9ca3af;
  --color-border: #374151;
  --color-tag-bg: #312e81;
  --color-tag-text: #a5b4fc;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.4);
  --color-delete-hover-bg: #451a1a;
  --color-offline-bg: #451a03;
  --color-offline-text: #fbbf24;
}

/* 2.2 — Mobile-first responsive layout */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  min-height: 100dvh;
}

.view {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 16px;
}

.hidden {
  display: none !important;
}

/* 2.3 — Login view */
#login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
}

.login-card {
  text-align: center;
  background: var(--color-surface);
  padding: 48px 32px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 380px;

  & h1 {
    font-size: 2rem;
    margin-bottom: 8px;
  }

  & p {
    color: var(--color-text-secondary);
    margin-bottom: 32px;
  }
}

/* 2.4 — Idea list view */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  background: var(--color-bg);
  z-index: 10;

  & h1 {
    font-size: 1.25rem;
  }
}

.idea-list {
  padding-bottom: 80px;
}

.idea-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 12px;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;

  & .idea-info {
    flex: 1;
    min-width: 0;
  }

  & .idea-title {
    font-weight: 600;
    margin-bottom: 4px;
  }

  & .idea-desc {
    color: var(--color-text-secondary);
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  & .idea-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
  }

  & .idea-delete {
    background: none;
    border: none;
    color: var(--color-text-secondary);
    cursor: pointer;
    font-size: 1.25rem;
    padding: 4px 8px;
    border-radius: var(--radius);
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;

    &:hover {
      color: var(--color-error);
      background: var(--color-delete-hover-bg);
    }
  }
}

.tag {
  display: inline-block;
  background: var(--color-tag-bg);
  color: var(--color-tag-text);
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 500;
}

.empty-state {
  text-align: center;
  padding: 64px 16px;
  color: var(--color-text-secondary);
}

/* 2.5 — Add idea form/modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
}

.modal-content {
  position: relative;
  background: var(--color-surface);
  width: 100%;
  max-width: var(--max-width);
  padding: 24px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  max-height: 90dvh;
  overflow-y: auto;

  & h2 {
    margin-bottom: 16px;
    font-size: 1.25rem;
  }

  & label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 4px;
    margin-top: 12px;
  }

  & label:first-of-type {
    margin-top: 0;
  }

  & input[type="text"],
  & textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
    background: var(--color-surface);
    color: var(--color-text);
    outline: none;
    transition: border-color 0.15s;

    &:focus {
      border-color: var(--color-primary);
      box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
    }
  }

  & textarea {
    resize: vertical;
  }
}

.tag-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;

  & .tag {
    cursor: pointer;

    &:hover {
      background: var(--color-primary);
      color: white;
    }
  }
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  justify-content: flex-end;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  min-height: 44px;
  transition: background-color 0.15s;
}

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

  &:hover {
    background: var(--color-primary-hover);
  }

  &:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }
}

.btn-secondary {
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);

  &:hover {
    background: var(--color-border);
  }
}

.btn-text {
  background: none;
  color: var(--color-text-secondary);
  padding: 8px 12px;

  &:hover {
    color: var(--color-text);
  }
}

/* Theme toggle */
.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.25rem;
  padding: 8px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  color: var(--color-text-secondary);
  transition: color 0.15s;

  &:hover {
    color: var(--color-text);
  }
}

/* 2.6 — Floating action button */
.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  font-size: 1.75rem;
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s, transform 0.15s;
  z-index: 50;

  &:hover {
    background: var(--color-primary-hover);
    transform: scale(1.05);
  }

  &:active {
    transform: scale(0.95);
  }
}

/* 2.7 — Feedback elements */
.toast {
  position: fixed;
  bottom: 96px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  z-index: 200;
  box-shadow: var(--shadow-lg);
  transition: opacity 0.3s;

  &.toast-success {
    background: var(--color-success);
    color: white;
  }

  &.toast-error {
    background: var(--color-error);
    color: white;
  }
}

.offline-indicator {
  background: var(--color-offline-bg);
  color: var(--color-offline-text);
  text-align: center;
  padding: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius);
  margin-top: 12px;
}

/* Desktop adjustments */
@media (min-width: 768px) {
  .modal {
    align-items: center;
  }

  .modal-content {
    border-radius: var(--radius-lg);
    max-width: 480px;
  }
}
