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

.hidden {
  display: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f4f8;
  color: #1a202c;
  min-height: 100vh;
  padding: 2rem;
  display: flex;
  justify-content: center;
}

.container {
  background: white;
  max-width: 800px;
  width: 100%;
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  align-self: flex-start;
}

h1 {
  font-size: 1.75rem;
  margin-bottom: 0.25rem;
}

.subtitle {
  color: #4a5568;
  margin-bottom: 1.5rem;
}

h2 {
  font-size: 1.15rem;
  margin-bottom: 0.75rem;
  color: #2d3748;
}

section {
  padding-top: 1.25rem;
  margin-top: 0.25rem;
}

section + section {
  border-top: 1px solid #e2e8f0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
}

.field label {
  font-size: 0.875rem;
  font-weight: 600;
  color: #2d3748;
}

input[type="text"],
input[type="file"],
input[type="number"] {
  padding: 0.5rem 0.75rem;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.95rem;
  transition: border-color 0.15s;
}

input[type="text"]:focus,
input[type="number"]:focus {
  outline: none;
  border-color: #4299e1;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  opacity: 1;
}

.price-warning {
  border-color: #ed8936 !important;
  background: #fffaf0;
}

button {
  padding: 0.5rem 1.25rem;
  background: #4299e1;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

button:hover:not(:disabled) {
  background: #3182ce;
}

button:active:not(:disabled) {
  background: #2b6cb0;
}

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

/* Preview */
.preview {
  margin-bottom: 0.75rem;
}

.preview img {
  max-width: 200px;
  max-height: 200px;
  border-radius: 8px;
  border: 2px solid #e2e8f0;
  object-fit: cover;
}

.preview.hidden {
  display: none;
}

/* Search */
#search-input {
  width: 100%;
}

/* Search mode toggle */
.search-mode {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.35rem;
  font-size: 0.8rem;
}

.search-mode.hidden {
  display: none;
}

.search-mode-label {
  color: #718096;
  font-weight: 500;
}

.search-mode-btn {
  background: #edf2f7;
  color: #4a5568;
  border: 2px solid transparent;
  padding: 0.2rem 0.6rem;
  border-radius: 14px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.search-mode-btn:hover {
  background: #e2e8f0;
}

.search-mode-active {
  background: #ebf8ff;
  color: #2b6cb0;
  border-color: #4299e1;
  font-weight: 600;
}

/* Keyword suggestions */
.suggest-field {
  position: relative;
}

.suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 10;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 0 0 8px 8px;
  max-height: 180px;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.suggestions:empty,
.suggestions.hidden {
  display: none;
}

.suggestion-item {
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  font-size: 0.875rem;
  color: #2d3748;
}

.suggestion-item:hover,
.suggestion-item.highlighted {
  background: #ebf8ff;
  color: #2b6cb0;
}

.suggestion-item::before {
  content: '#';
  color: #90cdf4;
  margin-right: 0.15rem;
}

/* Gallery */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.photo-card {
  background: #f7fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
}

.photo-card img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
}

.photo-card .card-body {
  padding: 0.75rem;
}

.photo-card .card-name {
  font-size: 0.8rem;
  color: #718096;
  margin-bottom: 0.5rem;
  word-break: break-all;
}

.keywords-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.keyword-chip {
  background: #ebf8ff;
  color: #2b6cb0;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
}

.keyword-chip::before {
  content: '#';
}

.card-details {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.price-row {
  font-size: 0.8rem;
  color: #4a5568;
}

.price-label {
  color: #718096;
  margin-right: 0.25rem;
}

.price-value {
  font-weight: 600;
  color: #2d3748;
}

.card-actions {
  display: flex;
  justify-content: flex-end;
}

.edit-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: #718096;
  margin-bottom: 0.1rem;
}

/* Edit-mode suggestions inside photo cards */
.photo-card .edit-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 10;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 0 0 8px 8px;
  max-height: 150px;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.photo-card .edit-suggestions.hidden {
  display: none;
}

.photo-card .edit-suggestions .suggestion-item {
  padding: 0.3rem 0.5rem;
  font-size: 0.8rem;
}

.count {
  font-size: 0.875rem;
  font-weight: 400;
  color: #718096;
}

.empty-state {
  padding: 2rem;
  text-align: center;
  color: #a0aec0;
}

/* No results */
.no-results {
  grid-column: 1 / -1;
  text-align: center;
  color: #a0aec0;
  padding: 1rem;
}

/* Gallery header & delete */
.gallery-header {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin-bottom: 0.75rem;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.gallery-actions {
  position: absolute;
  right: 0;
  display: flex;
  gap: 0.5rem;
}

.view-tabs {
  display: flex;
  gap: 0.25rem;
  background: #edf2f7;
  border-radius: 8px;
  padding: 0.2rem;
}

.tab {
  background: none;
  border: none;
  padding: 0.35rem 0.85rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #4a5568;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.tab:hover {
  color: #2d3748;
  background: rgba(255, 255, 255, 0.5);
}

.tab.tab-active {
  background: white;
  color: #2b6cb0;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.tab .count {
  font-weight: 400;
  color: inherit;
  opacity: 0.65;
}

.btn-danger {
  background: #fc8181;
  font-size: 0.8rem;
  padding: 0.35rem 0.75rem;
}

.btn-danger:hover:not(:disabled) {
  background: #f56565;
}

.btn-pdf {
  background: #667eea;
  font-size: 0.8rem;
  padding: 0.35rem 0.75rem;
}

.btn-pdf:hover:not(:disabled) {
  background: #5a67d8;
}

/* Photo card states */
.photo-card {
  position: relative;
  background: #f7fafc;
  border: 2px solid transparent;
  border-radius: 10px;
  overflow: hidden;
  transition: border-color 0.15s;
}

.photo-card.selected {
  border-color: #4299e1;
  background: #ebf8ff;
}

/* Selection checkbox */
.card-select {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.12s;
}

.photo-card:hover .card-select,
.photo-card.selected .card-select {
  opacity: 1;
}

.card-select input {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #4299e1;
}

/* Edit icon button */
.btn-edit-icon {
  background: none;
  border: none;
  padding: 0 0.25rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: #a0aec0;
  line-height: 1;
  flex-shrink: 0;
}

.btn-edit-icon:hover {
  color: #4299e1;
  background: none;
}

/* Pin button */
.btn-pin {
  background: none;
  border: none;
  padding: 0 0.25rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: #cbd5e0;
  line-height: 1;
  flex-shrink: 0;
}

.btn-pin:hover {
  color: #e53e3e;
  background: none;
}

.btn-pinned {
  color: #e53e3e;
}

/* Pin badge */
.pin-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  background: #e53e3e;
  color: white;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
}

.photo-card.pinned {
  border-color: #fc8181;
  background: #fff5f5;
}

.btn-restore-card {
  background: #9ae6b4;
  color: #22543d;
  border: none;
  padding: 0.3rem 0.7rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-restore-card:hover {
  background: #68d391;
}

.btn-restore {
  background: #9ae6b4;
  color: #22543d;
  font-size: 0.8rem;
  padding: 0.35rem 0.75rem;
}

.btn-restore:hover:not(:disabled) {
  background: #68d391;
}

/* Tag Chips */
.tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding-bottom: 0.5rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid #e2e8f0;
}

.tag-chip {
  background: #edf2f7;
  color: #4a5568;
  border: 2px solid transparent;
  padding: 0.3rem 0.7rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.tag-chip:hover {
  background: #e2e8f0;
  color: #2d3748;
}

.tag-chip-active {
  background: #ebf8ff;
  color: #2b6cb0;
  border-color: #4299e1;
  font-weight: 600;
}

.tag-chip-count {
  font-size: 0.7rem;
  opacity: 0.6;
  margin-left: 0.15rem;
}

/* Tag mode toggle */
.tag-mode {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
}

.tag-mode-label {
  color: #718096;
  font-weight: 500;
}

.tag-mode-btn {
  background: #edf2f7;
  color: #4a5568;
  border: 2px solid transparent;
  padding: 0.2rem 0.6rem;
  border-radius: 14px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.tag-mode-btn:hover {
  background: #e2e8f0;
}

.tag-mode-active {
  background: #ebf8ff;
  color: #2b6cb0;
  border-color: #4299e1;
  font-weight: 600;
}

/* Inline edit mode */
.edit-keywords {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.edit-input {
  padding: 0.35rem 0.5rem;
  border: 2px solid #4299e1;
  border-radius: 6px;
  font-size: 0.8rem;
  width: 100%;
}

.edit-input:focus {
  outline: none;
}

.edit-actions {
  display: flex;
  gap: 0.35rem;
}

.btn-sm {
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  border-radius: 6px;
  font-weight: 600;
}

.btn-save {
  background: #48bb78;
}

.btn-save:hover {
  background: #38a169 !important;
}

.btn-cancel {
  background: #a0aec0;
}

.btn-cancel:hover {
  background: #718096 !important;
}

/* Auth overlay */
.auth-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;
}

.auth-overlay.hidden {
  display: none;
}

.auth-card {
  background: white;
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
  width: 100%;
  max-width: 380px;
}

.auth-card h2 {
  margin-bottom: 1rem;
  text-align: center;
}

.auth-card .field {
  margin-bottom: 0.75rem;
}

.auth-card button[type="submit"] {
  width: 100%;
  margin-top: 0.25rem;
}

.auth-error {
  color: #e53e3e;
  font-size: 0.85rem;
  margin-top: 0.5rem;
  text-align: center;
}

.auth-switch {
  text-align: center;
  font-size: 0.85rem;
  color: #718096;
  margin-top: 0.75rem;
}

.auth-switch a {
  color: #4299e1;
  cursor: pointer;
  text-decoration: none;
}

.auth-switch a:hover {
  text-decoration: underline;
}

/* Header row */
.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-logo {
  height: 40px;
  width: auto;
  border-radius: 6px;
}

.btn-logout {
  background: none;
  border: 1px solid #e2e8f0;
  color: #718096;
  font-size: 0.8rem;
  padding: 0.25rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
}

.btn-logout:hover {
  background: #edf2f7;
}
