/* Brain Dumper - Clean Modern UI */
:root {
  --bg: #0f1419;
  --panel: #1a2332;
  --border: #2d3a4d;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #22c55e;
  --text: #e8eaed;
  --muted: #8b9cb3;
  --radius: 12px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

.app {
  max-width: 500px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

header h1 {
  font-size: 24px;
  font-weight: 700;
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  max-width: 300px;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}

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

.search-input:focus {
  outline: none;
  border-color: var(--primary);
  background: #1e2838;
}

/* Hide search on mobile to save space */
@media (max-width: 600px) {
  .search-input {
    display: none;
  }
}

.icon-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: background 0.2s;
}

.icon-btn:hover {
  background: var(--panel);
}

/* Main Content */
main {
  flex: 1;
  padding: 16px 20px;
  padding-bottom: 80px;
  overflow-y: auto;
}

/* Views */
.view {
  display: block;
}

#dumpsView,
#itemsView,
#selectionView,
#editDumpView,
#editItemView,
#successView,
#searchResultsView {
  display: none;
}

/* Input Section */
.input-section {
  margin-bottom: 24px;
}

.text-input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  width: 100%;
  max-width: 100%;
}

.note-input {
  flex: 1;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 16px;
  min-width: 0;
  box-sizing: border-box;
}

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

.note-input:focus {
  outline: none;
  border-color: var(--primary);
}

.dump-btn {
  padding: 14px 24px;
  font-weight: 600;
  flex-shrink: 0;
  box-sizing: border-box;
}

.record-btn {
  width: 100%;
  padding: 16px;
  font-size: 18px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: var(--radius);
}

.mic-icon {
  width: 24px;
  height: 24px;
  filter: invert(1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Dump list mic icons - smooth like record button */
.dump-mic-icon,
.dump-card-mic-icon,
.result-mic-icon {
  width: 20px;
  height: 20px;
  filter: invert(1);
  object-fit: contain;
  display: block;
}

/* List icons for items - same size as mic icons */
.list-icon-img,
.result-list-icon {
  width: 20px;
  height: 20px;
  filter: invert(1);
  object-fit: contain;
  display: block;
}

/* Recording Controls */
.recording-controls {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 16px;
}

.recording-status {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.recording-indicator {
  color: var(--danger);
  font-size: 12px;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.recording-buttons {
  display: flex;
  gap: 8px;
}

.recording-buttons .btn {
  flex: 1;
}

/* Buttons */
.btn {
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn:hover {
  background: #243044;
}

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

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

.btn.secondary {
  background: var(--panel);
  border-color: var(--primary);
  color: var(--primary);
}

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

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

.btn.small {
  padding: 8px 14px;
  font-size: 14px;
}

/* Split View */
.split-view {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.split-column {
  min-width: 0;
}

.column-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
}

.preview-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.empty-state {
  color: var(--muted);
  text-align: center;
  padding: 24px;
  background: var(--panel);
  border-radius: var(--radius);
  font-size: 14px;
}

/* Dump Preview Card */
.dump-preview {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  background: var(--panel);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s;
}

.dump-preview:hover {
  background: #243044;
}

.dump-icon {
  width: 44px;
  height: 44px;
  background: rgba(59, 130, 246, 0.2);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.dump-icon .dump-mic-icon {
  width: 20px;
  height: 20px;
}

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

.dump-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dump-meta {
  font-size: 12px;
  color: var(--muted);
}

/* Item Group Preview */
.item-group-preview {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  background: var(--panel);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s;
}

.item-group-preview:hover {
  background: #243044;
}

.item-group-icon {
  width: 44px;
  height: 44px;
  background: rgba(59, 130, 246, 0.2);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.item-group-icon .list-icon-img {
  width: 20px;
  height: 20px;
}

.item-group-info {
  flex: 1;
  min-width: 0;
}

.item-group-where {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 2px;
}

.item-group-items {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-group-count {
  font-size: 12px;
  color: var(--primary);
  margin-top: 4px;
}

/* View Header */
.view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.view-header h2 {
  font-size: 20px;
  font-weight: 700;
}

/* Full Lists */
.full-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Dump Card (Full List) */
.dump-card {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 16px;
}

.dump-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.dump-card-icon {
  font-size: 20px;
}

.dump-card-title {
  font-weight: 600;
  font-size: 16px;
}

.dump-card-meta {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}

.dump-card-preview {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 8px;
  line-height: 1.4;
}

.dump-card-date {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
}

.dump-card-actions {
  display: flex;
  gap: 8px;
}

/* Item Group (Full List) */
.item-group {
  background: var(--panel);
  border-radius: var(--radius);
  overflow: hidden;
}

.item-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: rgba(59, 130, 246, 0.1);
  border-bottom: 1px solid var(--border);
}

.item-group-title {
  font-weight: 600;
  font-size: 15px;
}

.item-group-list {
  list-style: none;
}

.item-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.item-entry:last-child {
  border-bottom: none;
}

.item-entry.checked .item-text {
  text-decoration: line-through;
  color: var(--muted);
}

.item-checkbox {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
}

.item-text {
  flex: 1;
  font-size: 15px;
}

/* Selection View */
.selection-preview {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
  font-size: 14px;
  color: var(--muted);
  min-height: 60px;
}

.selection-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.selection-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 24px 16px;
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text);
}

.selection-btn:hover {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.1);
}

.selection-btn.selected {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.2);
}

.selection-icon {
  font-size: 32px;
}

.selection-label {
  font-size: 16px;
  font-weight: 600;
}

/* Selection Fields */
.selection-fields {
  margin-bottom: 20px;
}

.field-group {
  margin-bottom: 16px;
}

.field-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--muted);
}

.field-input {
  width: 100%;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 15px;
}

.field-input:focus {
  outline: none;
  border-color: var(--primary);
}

.field-textarea {
  width: 100%;
  min-height: 120px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 15px;
  resize: vertical;
  font-family: inherit;
}

.field-textarea:focus {
  outline: none;
  border-color: var(--primary);
}

/* Option Buttons */
.project-options,
.where-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.option-btn {
  padding: 10px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

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

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

.confirm-btn {
  width: 100%;
  padding: 16px;
  font-size: 16px;
  font-weight: 600;
}

/* Edit View */
.edit-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.edit-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.audio-player {
  width: 100%;
  border-radius: 8px;
}

/* Success View */
.success-content {
  text-align: center;
  padding: 40px 20px;
}

.success-icon {
  width: 64px;
  height: 64px;
  background: var(--success);
  color: white;
  font-size: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
}

.success-content h2 {
  font-size: 24px;
  margin-bottom: 8px;
}

.success-content p {
  color: var(--muted);
  margin-bottom: 24px;
}

.success-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--panel);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: center;
  padding: 8px 0;
  z-index: 100;
}

.nav-tab {
  flex: 1;
  max-width: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s;
}

.nav-tab:hover,
.nav-tab.active {
  color: var(--primary);
}

.nav-icon {
  font-size: 20px;
}

.nav-label {
  font-size: 12px;
  font-weight: 500;
}

/* Search Results */
.search-query-display {
  margin-bottom: 16px;
  padding: 12px;
  background: var(--panel);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--muted);
}

.search-query-display::before {
  content: 'Searching for: ';
}

.search-results-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.search-results-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.results-group-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.results-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.search-result {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  background: var(--panel);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s;
}

.search-result:hover {
  background: #243044;
}

.result-icon {
  width: 40px;
  height: 40px;
  background: rgba(59, 130, 246, 0.2);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.result-icon .result-mic-icon,
.result-icon .result-list-icon {
  width: 20px;
  height: 20px;
}

.result-content {
  flex: 1;
  min-width: 0;
}

.result-title {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 4px;
  color: var(--text);
}

.result-preview {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
  line-height: 1.4;
}

.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 12px;
}

.match-badge {
  padding: 2px 8px;
  background: rgba(59, 130, 246, 0.2);
  color: var(--primary);
  border-radius: 4px;
  font-weight: 500;
}

.result-project,
.result-where {
  color: var(--muted);
}

.result-date {
  color: var(--muted);
  margin-left: auto;
}

mark {
  background: rgba(59, 130, 246, 0.3);
  color: var(--text);
  padding: 0 2px;
  border-radius: 2px;
}

.empty-hint {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}

/* Responsive */
@media (max-width: 400px) {
  .split-view {
    grid-template-columns: 1fr;
  }
  
  .selection-buttons {
    grid-template-columns: 1fr;
  }

  header {
    flex-wrap: wrap;
  }

  header h1 {
    order: 1;
  }

  .icon-btn {
    order: 2;
  }

  .text-input-row {
    max-width: 100%;
  }
}

/* Safari-specific fixes */
@supports (-webkit-appearance: none) {
  .search-input {
    -webkit-appearance: none;
    appearance: none;
    border-radius: 8px;
  }
  
  .btn {
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
  }
  
  .note-input {
    -webkit-appearance: none;
    appearance: none;
  }
}
