/* Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --black: #000000;
  --white: #ffffff;
  --gray-50: #fafafa;
  --gray-100: #f5f5f5;
  --gray-200: #eeeeee;
  --gray-300: #e0e0e0;
  --gray-400: #bdbdbd;
  --gray-500: #9e9e9e;
  --gray-600: #757575;
  --gray-700: #616161;
  --gray-800: #424242;
  --gray-900: #212121;
  --star-filled: #000000;
  --star-empty: #e0e0e0;
  --danger: #ef4444;
  --danger-hover: #dc2626;
}

html {
  font-size: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--white);
  color: var(--gray-900);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  z-index: 100;
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-size: 24px;
  font-weight: 800;
  color: var(--black);
  text-decoration: none;
  letter-spacing: -0.5px;
}

.nav {
  display: flex;
  gap: 32px;
}

.nav-link {
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-600);
  text-decoration: none;
  padding: 8px 0;
  position: relative;
  transition: color 0.2s ease;
}

.nav-link:hover,
.nav-link.active {
  color: var(--black);
}

.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--black);
}

.btn-add {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: var(--black);
  color: var(--white);
  border: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
}

.btn-add:hover {
  background: var(--gray-800);
}

/* Main */
.main {
  margin-top: 60px;
  min-height: calc(100vh - 60px - 120px);
}

/* Hero Section */
.hero {
  background: var(--gray-50);
  padding: 60px 24px;
  text-align: center;
}

.hero-content {
  max-width: 600px;
  margin: 0 auto;
}

.hero-title {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 12px;
}

.hero-subtitle {
  font-size: 16px;
  color: var(--gray-600);
}

/* Filter Section */
.filter-section {
  border-bottom: 1px solid var(--gray-200);
}

.filter-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.result-count {
  font-size: 14px;
  color: var(--gray-600);
}

.result-count span {
  font-weight: 600;
  color: var(--black);
}

.sort-options {
  display: flex;
  gap: 8px;
}

.sort-btn {
  padding: 8px 16px;
  background: transparent;
  border: 1px solid var(--gray-300);
  border-radius: 20px;
  font-size: 13px;
  color: var(--gray-600);
  cursor: pointer;
  transition: all 0.2s ease;
}

.sort-btn:hover {
  border-color: var(--gray-400);
  color: var(--gray-800);
}

.sort-btn.active {
  background: var(--black);
  border-color: var(--black);
  color: var(--white);
}

/* Grid Section */
.grid-section {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 24px;
}

.restaurant-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
}

/* Restaurant Card */
.restaurant-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  overflow: hidden;
  transition: all 0.2s ease;
  cursor: pointer;
}

.restaurant-card:hover {
  border-color: var(--gray-400);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.card-image {
  aspect-ratio: 1 / 1;
  background: var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.card-image-placeholder {
  font-size: 48px;
  opacity: 0.3;
}

.card-category-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 4px 10px;
  background: var(--white);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-800);
}

.card-actions {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.restaurant-card:hover .card-actions {
  opacity: 1;
}

.card-action-btn {
  width: 32px;
  height: 32px;
  background: var(--white);
  border: none;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease;
}

.card-action-btn:hover {
  background: var(--gray-100);
}

.card-action-btn svg {
  width: 16px;
  height: 16px;
  stroke: var(--gray-700);
}

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

.card-action-btn.delete:hover svg {
  stroke: var(--white);
}

.card-content {
  padding: 16px;
}

.card-name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-address {
  font-size: 13px;
  color: var(--gray-500);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-call {
  font-size: 13px;
  color: var(--gray-500);
  margin-bottom: 12px;
}

.card-rating {
  display: flex;
  gap: 2px;
}

.card-rating .star {
  width: 16px;
  height: 16px;
}

.card-rating .star.filled {
  fill: var(--star-filled);
}

.card-rating .star.empty {
  fill: var(--star-empty);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 80px 24px;
}

.empty-icon {
  margin-bottom: 24px;
  color: var(--gray-300);
}

.empty-text {
  font-size: 16px;
  color: var(--gray-500);
  margin-bottom: 24px;
}

/* Loading State */
.loading-state {
  text-align: center;
  padding: 80px 24px;
  color: var(--gray-500);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--black);
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: spin 1s linear infinite;
}

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

/* Footer */
.footer {
  background: var(--gray-50);
  border-top: 1px solid var(--gray-200);
  padding: 40px 24px;
}

.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  text-align: center;
}

.footer-logo {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 12px;
}

.footer-text {
  font-size: 13px;
  color: var(--gray-500);
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--white);
  border-radius: 12px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform 0.3s ease;
}

.modal-overlay.active .modal {
  transform: translateY(0);
}

.modal-small {
  max-width: 400px;
}

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

.modal-title {
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  width: 40px;
  height: 40px;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: background 0.2s ease;
}

.modal-close:hover {
  background: var(--gray-100);
}

.modal-close svg {
  stroke: var(--gray-600);
}

.modal-form {
  padding: 24px;
}

.modal-body {
  padding: 24px;
}

.delete-message {
  font-size: 15px;
  margin-bottom: 8px;
}

.delete-warning {
  font-size: 13px;
  color: var(--gray-500);
}

.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--gray-800);
}

.form-input,
.form-select {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.2s ease;
  background: var(--white);
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--black);
}

.form-input::placeholder {
  color: var(--gray-400);
}

/* Rating Input */
.rating-input {
  display: flex;
  gap: 4px;
}

.star-btn {
  background: transparent;
  border: none;
  padding: 4px;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.star-btn:hover {
  transform: scale(1.1);
}

.star-icon {
  width: 28px;
  height: 28px;
  fill: var(--star-empty);
  stroke: none;
  transition: fill 0.15s ease;
}

.star-btn.active .star-icon,
.star-btn:hover .star-icon {
  fill: var(--star-filled);
}

.star-btn.active ~ .star-btn .star-icon {
  fill: var(--star-empty);
}

.rating-input:hover .star-btn .star-icon {
  fill: var(--star-empty);
}

.rating-input:hover .star-btn:hover .star-icon,
.rating-input:hover .star-btn:hover ~ .star-btn .star-icon {
  fill: var(--star-empty);
}

.rating-input .star-btn:hover .star-icon,
.rating-input .star-btn:hover ~ .star-btn .star-icon {
  fill: var(--star-empty);
}

.rating-input .star-btn:hover .star-icon {
  fill: var(--star-filled);
}

.rating-input .star-btn:hover ~ .star-btn .star-icon {
  fill: var(--star-empty);
}

/* Fix: Show filled stars up to hovered star */
.rating-input:hover .star-btn .star-icon {
  fill: var(--star-empty);
}

.rating-input .star-btn:hover .star-icon,
.rating-input .star-btn.hovered .star-icon {
  fill: var(--star-filled);
}

.form-actions {
  display: flex;
  gap: 12px;
  padding: 0 24px 24px;
}

.modal-form .form-actions {
  padding: 0;
  margin-top: 24px;
}

.btn-primary,
.btn-secondary,
.btn-danger {
  flex: 1;
  padding: 14px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

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

.btn-primary:disabled {
  background: var(--gray-300);
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--white);
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}

.btn-secondary:hover {
  border-color: var(--gray-400);
  background: var(--gray-50);
}

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

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

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--gray-900);
  color: var(--white);
  padding: 14px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 300;
}

.toast.active {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  visibility: visible;
}

/* Responsive */
@media (max-width: 1024px) {
  .restaurant-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .header-inner {
    padding: 0 16px;
  }

  .nav {
    display: none;
  }

  .hero {
    padding: 40px 16px;
  }

  .hero-title {
    font-size: 24px;
  }

  .filter-inner {
    padding: 12px 16px;
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }

  .grid-section {
    padding: 24px 16px;
  }

  .restaurant-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }

  .card-actions {
    opacity: 1;
  }

  .modal {
    margin: 16px;
  }
}

@media (max-width: 480px) {
  .restaurant-grid {
    grid-template-columns: 1fr;
  }

  .btn-add span {
    display: none;
  }

  .btn-add {
    padding: 10px;
  }
}
