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

:root {
  --primary: #fed751;
  --primary-hover: #e5c148;
  --primary-text: #0f172a;
  --secondary: #64748b;
  --success: #10b981;
  --danger: #ef4444;
  --border: #e2e8f0;
  --bg-light: #f8fafc;
  --bg-white: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  --code-bg: #1e293b;
  --code-text: #e2e8f0;
  --note-bg: #fffbeb;
  --note-border: #fbbf24;
  --note-text: #92400e;
}

[data-theme="dark"] {
  --primary: #fed751;
  --primary-hover: #ffe175;
  --primary-text: #0f172a;
  --secondary: #94a3b8;
  --success: #34d399;
  --danger: #f87171;
  --border: #334155;
  --bg-light: #0f172a;
  --bg-white: #1e293b;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.3);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4);
  --code-bg: #0f172a;
  --code-text: #e2e8f0;
  --note-bg: #422006;
  --note-border: #b45309;
  --note-text: #fcd34d;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-light);
  color: var(--text-primary);
  line-height: 1.6;
  padding: 20px;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
}

/* Header */
header {
  background: var(--bg-white);
  padding: 16px 24px;
  border-radius: 8px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header h1 {
  font-size: 24px;
  font-weight: 600;
}

.brand {
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand:hover h1 {
  color: var(--primary);
}

.brand-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 400;
}

/* Menu Toggle (Hamburger) */
.menu-toggle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 42px;
  height: 42px;
  padding: 11px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.menu-toggle:hover {
  background: var(--bg-light);
  border-color: var(--text-secondary);
}

.menu-toggle span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text-secondary);
  border-radius: 1px;
  transition: all 0.15s ease;
}

.menu-toggle:hover span {
  background: var(--text-primary);
}

/* Menu Overlay */
.menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 998;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

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

/* Side Menu */
.side-menu {
  position: fixed;
  top: 0;
  right: -300px;
  width: 280px;
  height: 100vh;
  background: var(--bg-white);
  box-shadow: var(--shadow-lg);
  z-index: 999;
  display: flex;
  flex-direction: column;
  transition: right 0.25s ease;
}

.side-menu.active {
  right: 0;
}

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

.side-menu-header h3 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

.menu-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 22px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.menu-close:hover {
  background: var(--bg-light);
  border-color: var(--text-secondary);
  color: var(--text-primary);
}

.side-menu-nav {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  background: transparent;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 450;
  color: var(--text-primary);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}

.menu-item:hover {
  background: var(--bg-light);
}

.menu-item-danger {
  color: var(--danger);
}

.menu-item-danger:hover {
  background: rgba(239, 68, 68, 0.08);
}

.menu-icon {
  font-size: 16px;
  width: 22px;
  text-align: center;
  opacity: 0.85;
}

.side-menu-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}

.theme-item {
  background: var(--bg-light);
  border: 1px solid var(--border);
}

.theme-item:hover {
  border-color: var(--text-secondary);
}

/* Buttons */
.btn {
  height: 42px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.15s ease;
  white-space: nowrap;
  box-sizing: border-box;
}

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

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

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

.btn-secondary:hover {
  background: var(--bg-light);
  border-color: var(--text-secondary);
}

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

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

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

.btn-small {
  height: 36px;
  padding: 0 14px;
  font-size: 13px;
}

.btn-icon {
  width: 42px;
  height: 42px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 16px;
}

.btn-icon:hover {
  background: var(--bg-light);
  border-color: var(--text-secondary);
  color: var(--text-primary);
}

.btn-icon-small {
  width: 28px;
  height: 28px;
  font-size: 14px;
}

.btn-icon-danger {
  color: var(--danger);
  border-color: var(--danger);
  font-size: 20px;
  font-weight: 300;
}

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

/* Sections */
section {
  background: var(--bg-white);
  padding: 24px;
  border-radius: 8px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

section h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.count {
  background: var(--primary);
  color: var(--primary-text);
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 14px;
}

/* Form */
.search-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 15px;
  align-items: end;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-control {
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  background: var(--bg-white);
  color: var(--text-primary);
  transition: all 0.15s ease;
  box-sizing: border-box;
}

.form-control option {
  background: var(--bg-white);
  color: var(--text-primary);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

input.form-control {
  width: 100%;
}

/* Search Cards */
.search-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 15px;
  transition: all 0.15s ease;
}

.search-card:hover {
  box-shadow: var(--shadow-lg);
}

.search-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px;
  margin: -20px -20px 0 -20px;
  cursor: pointer;
  border-radius: 8px 8px 0 0;
  transition: background 0.15s ease;
}

.search-header:hover {
  background: var(--bg-light);
}

.search-card.collapsed .search-header {
  margin-bottom: -20px;
  border-radius: 8px;
}

.search-info {
  flex: 1;
}

.search-query {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.search-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.search-rating-badge {
  color: var(--primary);
  font-weight: 500;
}

.search-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.collapse-icon {
  font-size: 12px;
  color: var(--text-secondary);
  transition: transform 0.2s ease;
}

.search-card.collapsed .collapse-icon {
  transform: rotate(-90deg);
}

.search-content {
  padding-top: 15px;
}

.search-card.collapsed .search-content {
  display: none;
}

.search-template-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 15px;
}

.search-template {
  font-family: 'Courier New', monospace;
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--bg-light);
  padding: 6px 10px;
  border-radius: 6px;
  display: inline-block;
}

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

.search-notes {
  background: var(--note-bg);
  border: 1px solid var(--note-border);
  border-radius: 8px;
  padding: 12px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--note-text);
}

.search-notes textarea {
  width: 100%;
  border: none;
  background: transparent;
  resize: vertical;
  min-height: 60px;
  font-family: inherit;
  font-size: 13px;
  color: inherit;
}

.search-notes textarea:focus {
  outline: none;
}

/* Add Website Form */
.add-website-form {
  background: var(--bg-light);
  border-radius: 8px;
  padding: 15px;
  margin-top: 15px;
}

.add-website-form h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
}

.form-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.form-textarea {
  height: auto;
  min-height: 60px;
  padding: 10px 14px;
  resize: vertical;
  font-family: inherit;
}

/* Earnings Display */
.earnings-display {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 8px 12px;
  text-align: left;
}

.earnings-label {
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.earnings-range {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.earnings-min,
.earnings-max {
  font-size: 14px;
  color: var(--text-secondary);
}

.earnings-currency {
  color: var(--primary);
  font-size: 16px;
}

.earnings-amount {
  font-size: 16px;
  font-weight: 500;
  color: var(--primary);
}

.earnings-rsd {
  color: var(--text-secondary);
  font-size: 16px;
}

/* Star Rating */
.star-rating-container {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.star-rating-label {
  font-size: 13px;
  color: var(--text-secondary);
  min-width: 50px;
}

.star-rating {
  display: flex;
  gap: 4px;
}

.star {
  font-size: 32px;
  cursor: pointer;
  color: var(--border);
  transition: color 0.15s ease, transform 0.1s ease;
  position: relative;
  user-select: none;
  line-height: 1;
}

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

.star.full {
  color: var(--primary);
}

.star.half {
  background: linear-gradient(90deg, var(--primary) 50%, var(--border) 50%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.star-rating-value {
  font-size: 18px;
  margin-top: 7px;
  font-weight: 500;
  color: var(--text-primary);
  min-width: 30px;
  transition: opacity 0.15s ease;
}

.star-rating-value.preview {
  opacity: 0.6;
}

/* Website List */
.websites-list {
  margin-top: 15px;
}

.website-card {
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 15px;
  margin-bottom: 10px;
}

.website-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 10px;
}

.website-url {
  font-weight: 500;
  color: var(--text-primary);
  text-decoration: none;
  word-break: break-all;
}

.website-url:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

.website-meta {
  display: flex;
  gap: 15px;
  margin-bottom: 10px;
  font-size: 13px;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.meta-label {
  color: var(--text-secondary);
}

.meta-value {
  font-weight: 600;
}

/* Website Info Row (products, earnings, rating) */
.website-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 10px;
}

.website-info-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.website-products {
  font-weight: 600;
  color: var(--text-primary);
}

.website-earnings-inline {
  color: var(--primary);
  font-weight: 500;
}

.website-rating {
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.star-rating-display .star {
  font-size: 16px;
  cursor: default;
}

.star-rating-display .star:hover {
  transform: none;
}

.website-rating .star-rating-value {
  font-size: 13px;
  margin-top: 0;
  font-weight: 500;
}

.website-checkboxes {
  display: flex;
  gap: 20px;
  margin-bottom: 10px;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.checkbox-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--primary);
}

.website-notes {
  /* background: var(--note-bg); */
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  margin-top: 10px;
  font-size: 13px;
  /* color: var(--note-text); */
}

.website-notes:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(254, 215, 81, 0.2);
}

.website-notes textarea {
  width: 100%;
  border: none;
  background: transparent;
  resize: vertical;
  min-height: 50px;
  font-family: inherit;
  font-size: 13px;
  color: inherit;
}

.website-notes textarea:focus {
  outline: none;
}

.website-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

/* Stats Section */
.stats-section {
  background: var(--bg-white);
  padding: 24px;
  border-radius: 8px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

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

.stat-card {
  background: var(--bg-light);
  padding: 20px;
  border-radius: 6px;
  text-align: center;
}

.stat-number {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 5px;
}

.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

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

.history-header h2 {
  margin-bottom: 0;
}

.search-filter {
  flex: 1;
  max-width: 400px;
}

.search-filter input {
  width: 100%;
}

.history-controls {
  display: flex;
  gap: 12px;
  flex: 1;
  max-width: 500px;
}

.history-controls select {
  min-width: 150px;
}

.history-controls input {
  flex: 1;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--text-secondary);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 10px;
  opacity: 0.3;
}

/* Script Section */
.script-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

.script-info h2 {
  margin-bottom: 4px;
}

.script-info .text-muted {
  margin: 0;
}

.script-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.script-content {
  display: none;
  margin-top: 15px;
}

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

.script-code {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 20px;
  border-radius: 8px;
  font-family: 'Courier New', 'Monaco', monospace;
  font-size: 13px;
  line-height: 1.6;
  overflow-x: auto;
  border: 1px solid var(--border);
  margin: 0;
}

/* Theme Toggle */
.theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  transition: all 0.2s;
}

.theme-toggle:hover {
  background: var(--bg-light);
  border-color: var(--secondary);
}

/* Utilities */
.hidden {
  display: none;
}

.text-muted {
  color: var(--text-secondary);
  font-size: 13px;
}

/* 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: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
}

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

.modal {
  background: var(--bg-white);
  border-radius: 8px;
  padding: 24px;
  max-width: 400px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95);
  transition: transform 0.15s ease;
}

.modal-overlay.active .modal {
  transform: scale(1);
}

.modal-icon {
  font-size: 48px;
  text-align: center;
  margin-bottom: 16px;
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.modal-message {
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 24px;
  line-height: 1.6;
  white-space: pre-line;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.modal-actions .btn {
  min-width: 100px;
}

/* Responsive */
@media (max-width: 768px) {
  .search-form {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

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

  header {
    flex-direction: column;
    gap: 15px;
    align-items: flex-start;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-start;
  }
}