/* ==========================================================================
   DomekUMore — Styles
   ========================================================================== */

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #dbeafe;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --white: #ffffff;
  --red-500: #ef4444;
  --red-600: #dc2626;
  --green-500: #22c55e;
  --green-600: #16a34a;
  --amber-500: #f59e0b;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
  --radius: 8px;
  --radius-lg: 12px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--gray-800);
  background: var(--gray-50);
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Header ===== */

header {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.header-left {
  display: flex;
  align-items: center;
  gap: 24px;
}

.header-logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--gray-900);
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  text-decoration: none;
}
.header-logo:hover { text-decoration: none; }

.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.header-nav a,
.header-nav button {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-600);
  border-radius: 6px;
  transition: all 0.15s;
  text-decoration: none;
  border: none;
  background: none;
  cursor: pointer;
}
.header-nav a:hover,
.header-nav button:hover {
  background: var(--gray-100);
  color: var(--gray-900);
  text-decoration: none;
}
.header-nav a.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

/* ===== Main Content ===== */

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px;
  min-height: calc(100vh - 56px);
}

/* ===== Loading ===== */

.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  color: var(--gray-400);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-bottom: 12px;
}

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

/* ===== Page Header ===== */

.page-header {
  margin-bottom: 24px;
}
.page-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--gray-900);
}
.page-subtitle {
  font-size: 14px;
  color: var(--gray-500);
  margin-top: 2px;
}

/* ===== Public Page: Property Cards ===== */

.property-grid {
  display: grid;
  gap: 16px;
}

.property-card {
  display: flex;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: box-shadow 0.15s;
}
.property-card:hover {
  box-shadow: var(--shadow-md);
}

.property-image {
  width: 200px;
  min-height: 150px;
  flex-shrink: 0;
  background: var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  color: var(--gray-300);
  overflow: hidden;
}
.property-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.property-info {
  flex: 1;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.property-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-900);
  line-height: 1.3;
}
.property-title a {
  color: inherit;
}
.property-title a:hover {
  color: var(--primary);
  text-decoration: none;
}

.property-meta {
  font-size: 13px;
  color: var(--gray-500);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.property-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.property-price {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}

.property-source {
  font-size: 11px;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.property-newsletter-date {
  font-size: 12px;
  color: var(--gray-400);
  margin-top: auto;
}

@media (max-width: 640px) {
  .property-card {
    flex-direction: column;
  }
  .property-image {
    width: 100%;
    height: 180px;
  }
}

/* ===== Pagination ===== */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 32px;
  padding: 16px 0;
}

.pagination button {
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  background: var(--white);
  color: var(--gray-700);
  cursor: pointer;
  transition: all 0.15s;
}
.pagination button:hover:not(:disabled) {
  background: var(--gray-100);
  border-color: var(--gray-300);
}
.pagination button:disabled {
  opacity: 0.4;
  cursor: default;
}
.pagination button.active {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
}

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

/* ===== Login Page ===== */

.login-container {
  max-width: 360px;
  margin: 80px auto;
  padding: 32px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.login-title {
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 24px;
  color: var(--gray-900);
}

.form-group {
  margin-bottom: 16px;
}
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 4px;
}
.form-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  outline: none;
  transition: border-color 0.15s;
}
.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--white);
  color: var(--gray-700);
  text-decoration: none;
}
.btn:hover { background: var(--gray-100); text-decoration: none; }
.btn-primary {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-full { width: 100%; }

.form-error {
  color: var(--red-600);
  font-size: 13px;
  margin-top: 8px;
  text-align: center;
}

/* ===== Empty State ===== */

.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--gray-400);
}
.empty-state-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state-title { font-size: 18px; font-weight: 600; color: var(--gray-600); margin-bottom: 4px; }

/* ===== Admin Placeholder ===== */

.admin-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  font-size: 18px;
  font-weight: 600;
  color: var(--gray-400);
}

/* ===== Admin Table ===== */

.admin-table-wrap {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}

.admin-table td {
  padding: 10px 12px;
  font-size: 14px;
  color: var(--gray-700);
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}

.admin-table tbody tr:hover {
  background: var(--gray-50);
}

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

/* ===== Admin Pagination ===== */

.admin-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  padding: 12px 0;
  gap: 16px;
  flex-wrap: wrap;
}

.admin-pagination-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--gray-500);
}

.admin-pagination-left select {
  padding: 4px 8px;
  font-size: 13px;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  background: var(--white);
}

.admin-pagination-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-pagination-right button {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  background: var(--white);
  color: var(--gray-700);
  cursor: pointer;
  transition: all 0.15s;
}
.admin-pagination-right button:hover:not(:disabled) {
  background: var(--gray-100);
  border-color: var(--gray-300);
}
.admin-pagination-right button:disabled {
  opacity: 0.4;
  cursor: default;
}

/* ===== Filter Buttons ===== */

.filter-buttons {
  display: flex;
  gap: 4px;
  background: var(--gray-100);
  padding: 3px;
  border-radius: 8px;
}

.filter-btn {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--gray-600);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.filter-btn:hover {
  color: var(--gray-900);
}
.filter-btn-active {
  background: var(--white);
  color: var(--gray-900);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}
.btn-sm:disabled {
  opacity: 0.5;
  cursor: default;
}

/* ===== Admin merged layout ===== */

.admin-layout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.admin-listings-panel {
  flex: 2;
  min-width: 0;
}

.admin-settings-panel {
  flex: 1;
  min-width: 280px;
  max-width: 360px;
  position: sticky;
  top: 12px;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  padding: 16px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}

.admin-settings-panel .settings-section {
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--gray-100);
}

.admin-settings-panel .settings-section:last-of-type {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

@media (max-width: 900px) {
  .admin-layout {
    flex-direction: column;
  }
  .admin-settings-panel {
    max-width: 100%;
    position: static;
    max-height: none;
  }
}

/* ===== Settings Form ===== */

.settings-form {
  max-width: 640px;
}

.settings-section {
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--gray-100);
}
.settings-section:last-of-type {
  border-bottom: none;
}

.settings-section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 2px;
}

.settings-section-desc {
  font-size: 13px;
  color: var(--gray-400);
  margin-bottom: 12px;
}

.settings-checkbox-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.settings-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 13px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}
.settings-checkbox:hover {
  background: var(--gray-100);
  border-color: var(--gray-300);
}
.settings-checkbox input[type="checkbox"] {
  accent-color: var(--primary);
}
.settings-checkbox:has(input:checked) {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.settings-inline {
  display: flex;
  gap: 16px;
}

/* ===== Responsive Admin Table ===== */

@media (max-width: 768px) {
  .admin-table thead {
    display: none;
  }

  .admin-table,
  .admin-table tbody,
  .admin-table tr,
  .admin-table td {
    display: block;
  }

  .admin-table tr {
    padding: 12px;
    border-bottom: 1px solid var(--gray-200);
  }
  .admin-table tr:last-child {
    border-bottom: none;
  }

  .admin-table td {
    padding: 4px 0;
    border-bottom: none;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .admin-table td:before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    min-width: 65px;
    flex-shrink: 0;
  }

  .admin-table td:first-child {
    padding-top: 0;
  }

  .admin-table td.cell-price {
    font-weight: 600;
    color: var(--primary);
  }

  .admin-table tr:hover {
    background: var(--gray-50);
  }
}

/* ===== Property Detail ===== */

.property-detail {
  max-width: 800px;
  margin: 0 auto;
}

.property-detail-back {
  margin-bottom: 16px;
  font-size: 14px;
}
.property-detail-back a {
  color: var(--gray-500);
}
.property-detail-back a:hover {
  color: var(--primary);
}

.property-detail-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1.25;
  margin-bottom: 8px;
}

.property-detail-source-title {
  font-size: 13px;
  color: var(--gray-500);
  margin-bottom: 8px;
}

.property-detail-location {
  font-size: 16px;
  color: var(--gray-500);
  margin-bottom: 10px;
}

.property-detail-price {
  font-size: 32px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 16px;
}

.property-detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 20px;
}

.property-detail-gallery {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 32px;
}

.property-detail-gallery-item {
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
}
.property-detail-gallery-item.gallery-main {
  grid-column: 1 / -1;
  max-height: 400px;
}
.property-detail-gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.2s;
}
.property-detail-gallery-item:hover img {
  transform: scale(1.02);
}

.property-detail-section {
  margin-bottom: 28px;
}
.property-detail-section h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 8px;
}
.property-detail-section p {
  font-size: 15px;
  line-height: 1.7;
  color: var(--gray-700);
}

.property-detail-ai {
  background: #f8fdfb;
  padding: 20px;
  border-radius: var(--radius-lg);
  border: 1px solid #cce9dd;
}
.property-detail-ai h2 {
  color: #0f766e;
}
.property-detail-ai p {
  color: var(--gray-700);
}

.property-detail-features {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.property-detail-features li {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  font-size: 13px;
  background: var(--gray-100);
  color: var(--gray-700);
  border-radius: 20px;
}

.property-detail-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 40px;
  flex-wrap: wrap;
}

.property-detail-newsletter-cta {
  text-align: center;
  padding: 32px;
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
  border-radius: var(--radius-lg);
  color: var(--white);
  margin-bottom: 32px;
}
.property-detail-newsletter-cta h3 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}
.property-detail-newsletter-cta p {
  font-size: 14px;
  opacity: 0.9;
  margin-bottom: 16px;
}
.property-detail-newsletter-cta .btn {
  background: var(--white);
  color: var(--primary);
  border: none;
  font-weight: 600;
  padding: 12px 28px;
  font-size: 15px;
}
.property-detail-newsletter-cta .btn:hover {
  background: var(--gray-100);
}

.admin-panel {
  background: var(--white);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.admin-panel-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

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

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--white);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-md);
  padding: 16px;
}

.metric-label {
  font-size: 12px;
  color: var(--gray-500);
  margin-bottom: 6px;
}

.metric-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--gray-900);
}

.metric-value-sm {
  font-size: 18px;
  line-height: 1.3;
}

.newsletter-selection-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.newsletter-card {
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--white);
}

.newsletter-card-image {
  height: 180px;
  background: var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
}

.newsletter-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.newsletter-card-body {
  padding: 14px;
}

.newsletter-card-title {
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--gray-900);
}

.newsletter-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
  color: var(--gray-600);
  margin-bottom: 8px;
}

.newsletter-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.status-draft {
  background: #fef3c7;
  color: #92400e;
}

.status-confirmed {
  background: #dbeafe;
  color: #1d4ed8;
}

.status-published {
  background: #dcfce7;
  color: #166534;
}

.ops-source-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.ops-source-card {
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-md);
  padding: 14px;
  background: var(--gray-50);
}

.ops-source-alert {
  border-color: #fca5a5;
  background: #fef2f2;
}

.ops-source-title {
  font-weight: 700;
  margin-bottom: 6px;
}

.ops-source-meta {
  font-size: 13px;
  color: var(--gray-600);
  margin-bottom: 4px;
}

.substack-result {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--gray-50);
  color: var(--gray-700);
  border: 1px solid var(--gray-100);
}

.substack-result-ok {
  background: #ecfdf5;
  border-color: #86efac;
  color: #166534;
}

.substack-result-fail {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #991b1b;
}

@media (max-width: 640px) {
  .property-detail-title {
    font-size: 22px;
  }
  .property-detail-price {
    font-size: 26px;
  }
  .property-detail-gallery {
    grid-template-columns: 1fr;
  }
  .property-detail-newsletter-cta {
    padding: 24px 16px;
  }
  .metrics-grid,
  .ops-source-grid,
  .newsletter-selection-grid {
    grid-template-columns: 1fr;
  }
}

/* ===== Footer ===== */

footer {
  text-align: center;
  padding: 24px 20px;
  font-size: 12px;
  color: var(--gray-400);
  border-top: 1px solid var(--gray-100);
}
