/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: #f5f5f5;
  color: #1a1a1a;
  line-height: 1.5;
}

/* App Layout */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  background: white;
  border-bottom: 1px solid #e5e5e5;
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  color: #1a1a1a;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
  max-width: 600px;
}

/* Buttons */
.btn-primary {
  background: #1a1a1a;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover {
  background: #333;
}

.btn-secondary {
  background: white;
  color: #1a1a1a;
  border: 1px solid #e5e5e5;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: #f5f5f5;
}

/* Main Content */
.main {
  flex: 1;
  padding: 2rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* Search Component */
.search-wrapper {
  position: relative;
  flex: 1;
}

.autocomplete-input {
  width: 100%;
  padding: 0.5rem 1rem;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.2s;
}

.autocomplete-input:focus {
  border-color: #1a1a1a;
}

.autocomplete-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  margin-top: 4px;
  max-height: 300px;
  overflow-y: auto;
  display: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 200;
}

.autocomplete-results.active {
  display: block;
}

.autocomplete-item {
  padding: 0.75rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid #f5f5f5;
}

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

.autocomplete-item:hover {
  background: #f5f5f5;
}

.autocomplete-name {
  font-weight: 500;
  display: block;
}

.autocomplete-secondary {
  font-size: 0.75rem;
  color: #6b7280;
}

.autocomplete-loading,
.autocomplete-empty,
.autocomplete-error {
  padding: 1rem;
  text-align: center;
  color: #6b7280;
  font-size: 0.875rem;
}

.autocomplete-error {
  color: #ef4444;
}

/* List Component */
.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.list-filters {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.list-filters .search-input,
.list-filters select {
  padding: 0.5rem 0.75rem;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  font-size: 0.875rem;
  outline: none;
  background: white;
}

.list-filters .search-input {
  min-width: 200px;
}

.list-filters .search-input:focus,
.list-filters select:focus {
  border-color: #1a1a1a;
}

.list-count {
  font-size: 0.875rem;
  color: #6b7280;
}

/* Places Grid */
.places-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 2rem;
  color: #6b7280;
}

/* Place Card */
.place-card {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  position: relative;
  transition: box-shadow 0.2s;
}

.place-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.place-photo {
  height: 150px;
  background-size: cover;
  background-position: center;
  background-color: #e5e5e5;
}

.place-photo-empty {
  display: flex;
  align-items: center;
  justify-content: center;
}

.place-photo-empty::after {
  content: '🍽️';
  font-size: 3rem;
  opacity: 0.3;
}

.place-content {
  padding: 1rem;
}

.place-name {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 0.25rem;
}

.place-address {
  font-size: 0.75rem;
  color: #6b7280;
  margin: 0 0 0.5rem;
}

.place-rating {
  font-size: 0.75rem;
  color: #f59e0b;
  margin-bottom: 0.5rem;
}

.place-status {
  margin-bottom: 0.5rem;
}

.status-select {
  padding: 0.25rem 0.5rem;
  border: 1px solid #e5e5e5;
  border-radius: 4px;
  font-size: 0.75rem;
  outline: none;
  background: white;
  cursor: pointer;
}

.place-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
}

.tag {
  background: #f5f5f5;
  padding: 0.125rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  color: #6b7280;
}

.add-tag-btn {
  background: none;
  border: 1px dashed #e5e5e5;
  padding: 0.125rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  color: #6b7280;
  cursor: pointer;
}

.add-tag-btn:hover {
  border-color: #1a1a1a;
  color: #1a1a1a;
}

.delete-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0,0,0,0.5);
  color: white;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.place-card:hover .delete-btn {
  opacity: 1;
}

.delete-btn:hover {
  background: rgba(239, 68, 68, 0.9);
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
}

.modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.modal-content {
  position: relative;
  background: white;
  border-radius: 12px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal-large {
  max-width: 800px;
}

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

.modal-header h2 {
  margin: 0;
  font-size: 1.25rem;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #6b7280;
  padding: 0;
  line-height: 1;
}

.modal-close:hover {
  color: #1a1a1a;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid #e5e5e5;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* Modal Tabs */
.modal-tabs {
  display: flex;
  border-bottom: 1px solid #e5e5e5;
}

.tab-btn {
  flex: 1;
  padding: 0.75rem 1rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 0.875rem;
  font-weight: 500;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn:hover {
  color: #1a1a1a;
}

.tab-btn.active {
  color: #1a1a1a;
  border-bottom-color: #1a1a1a;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.tab-description {
  font-size: 0.875rem;
  color: #6b7280;
  margin: 0 0 1rem;
}

/* File Upload */
.file-upload {
  margin-bottom: 1rem;
}

.file-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  border: 2px dashed #e5e5e5;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.file-label:hover,
.file-label.dragover {
  border-color: #1a1a1a;
  background: #f5f5f5;
}

.file-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.file-preview {
  display: none;
  margin-top: 1rem;
}

.file-preview.active {
  display: block;
}

.file-preview img {
  max-width: 100%;
  max-height: 200px;
  border-radius: 8px;
}

/* Text Input */
.text-input {
  width: 100%;
  min-height: 150px;
  padding: 0.75rem;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  font-size: 0.875rem;
  font-family: inherit;
  resize: vertical;
  outline: none;
  margin-bottom: 1rem;
}

.text-input:focus {
  border-color: #1a1a1a;
}

.extract-btn {
  width: 100%;
  padding: 0.75rem;
  background: #1a1a1a;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.extract-btn:disabled {
  background: #e5e5e5;
  color: #6b7280;
  cursor: not-allowed;
}

.extract-btn:not(:disabled):hover {
  background: #333;
}

/* Loading */
.modal-loading {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  z-index: 10;
}

.modal-loading[hidden] {
  display: none;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #e5e5e5;
  border-top-color: #1a1a1a;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Confirmation Table */
.confirm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.confirm-table th {
  text-align: left;
  padding: 0.75rem;
  border-bottom: 2px solid #e5e5e5;
  font-weight: 600;
}

.confirm-table td {
  padding: 0.75rem;
  border-bottom: 1px solid #f5f5f5;
  vertical-align: top;
}

.confirm-table tr:last-child td {
  border-bottom: none;
}

.confirm-table tr.no-match {
  background: #fef2f2;
}

.extracted-name {
  font-weight: 500;
}

.extracted-location {
  font-size: 0.75rem;
  color: #6b7280;
}

.candidate-select {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #e5e5e5;
  border-radius: 4px;
  font-size: 0.875rem;
  outline: none;
  background: white;
}

.candidate-details {
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: #6b7280;
}

.candidate-address {
  display: block;
}

.confidence {
  font-weight: 500;
}

.status-add {
  color: #10b981;
  font-weight: 500;
}

.status-skip {
  color: #6b7280;
}

.skip-label {
  color: #ef4444;
  font-weight: 500;
}

.error-cell {
  color: #ef4444;
}

.location-context {
  background: #f5f5f5;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

/* Manual Search in Confirm Modal */
.manual-search-inline {
  position: relative;
}

.manual-search-input {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #e5e5e5;
  border-radius: 4px;
  font-size: 0.875rem;
  outline: none;
}

.manual-search-input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.manual-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #e5e5e5;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
  display: none;
}

.manual-search-results.active {
  display: block;
}

.manual-search-results .autocomplete-item {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  border-bottom: 1px solid #f5f5f5;
}

.manual-search-results .autocomplete-item:last-child {
  border-bottom: none;
}

.manual-search-results .autocomplete-item:hover {
  background: #f5f5f5;
}

.manual-search-results .autocomplete-name {
  display: block;
  font-weight: 500;
}

.manual-search-results .autocomplete-secondary {
  display: block;
  font-size: 0.75rem;
  color: #6b7280;
}

.manual-search-results .autocomplete-loading,
.manual-search-results .autocomplete-empty,
.manual-search-results .autocomplete-error {
  padding: 0.75rem;
  text-align: center;
  color: #6b7280;
  font-size: 0.875rem;
}

.manual-search-results .autocomplete-error {
  color: #ef4444;
}

.manual-selected {
  padding: 0.5rem;
  background: #f0fdf4;
  border-radius: 4px;
  border: 1px solid #86efac;
}

.manual-selected strong {
  display: block;
  margin-bottom: 0.25rem;
}

.no-match-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.no-match-text {
  color: #ef4444;
  font-size: 0.875rem;
}

.btn-link {
  background: none;
  border: none;
  color: #3b82f6;
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0;
  text-decoration: underline;
}

.btn-link:hover {
  color: #1d4ed8;
}

.cancel-manual {
  margin-top: 0.5rem;
}

/* Responsive */
@media (max-width: 768px) {
  .header {
    flex-direction: column;
    padding: 1rem;
    gap: 1rem;
  }

  .header-actions {
    width: 100%;
    max-width: none;
  }

  .main {
    padding: 1rem;
  }

  .places-grid {
    grid-template-columns: 1fr;
  }

  .list-filters {
    width: 100%;
  }

  .list-filters .search-input {
    flex: 1;
    min-width: 0;
  }

  .modal-content {
    width: 95%;
    margin: 1rem;
  }

  .confirm-table {
    font-size: 0.75rem;
  }

  .confirm-table th,
  .confirm-table td {
    padding: 0.5rem;
  }
}

/* Hidden state */
.hidden {
  display: none !important;
}

/* Auth Screen */
.auth-screen {
  display: none;
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  z-index: 2000;
}

.auth-screen.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-container {
  width: 100%;
  max-width: 400px;
  padding: 1rem;
}

.auth-card {
  background: white;
  border-radius: 16px;
  padding: 2rem;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.auth-logo {
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
  margin: 0 0 0.5rem;
  color: #1a1a1a;
}

.auth-tagline {
  text-align: center;
  color: #6b7280;
  margin: 0 0 2rem;
  font-size: 0.875rem;
}

.auth-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.auth-tab {
  flex: 1;
  padding: 0.75rem;
  background: #f5f5f5;
  border: none;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.2s;
}

.auth-tab:hover {
  background: #e5e5e5;
}

.auth-tab.active {
  background: #1a1a1a;
  color: white;
}

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

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

.form-group label {
  font-size: 0.875rem;
  font-weight: 500;
  color: #1a1a1a;
}

.form-group input {
  padding: 0.75rem;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: #1a1a1a;
}

.auth-error {
  background: #fef2f2;
  color: #dc2626;
  padding: 0.75rem;
  border-radius: 8px;
  font-size: 0.875rem;
}

.auth-error[hidden] {
  display: none;
}

.auth-submit {
  padding: 0.875rem;
  background: #1a1a1a;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.auth-submit:hover:not(:disabled) {
  background: #333;
}

.auth-submit:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}

/* User Menu */
.user-menu {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-email {
  font-size: 0.875rem;
  color: #6b7280;
}

.btn-small {
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
}

/* Loading State */
.loading-state {
  text-align: center;
  padding: 4rem 2rem;
  color: #6b7280;
}

.loading-state .spinner {
  margin: 0 auto 1rem;
}
