/* Simple backoffice-style layout */

:root {
  --bg: #f5f5f5;
  --surface: #fff;
  --text: #1a1a1a;
  --text-muted: #666;
  --border: #e0e0e0;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --font: 'Segoe UI', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

#auth-screen[hidden],
#app-screen[hidden],
#public-posts-screen[hidden] {
  display: none !important;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

.app {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.user-email {
  font-size: 14px;
  color: var(--text-muted);
}

.app-nav {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.app-nav-btn {
  padding: 10px 20px;
  font: inherit;
  font-size: 14px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  color: var(--text-muted);
}

.app-nav-btn:hover { color: var(--text); }
.app-nav-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }

.posts-subnav { display: flex; gap: 0; margin-bottom: 16px; }
.posts-subnav-btn { padding: 8px 16px; font: inherit; font-size: 14px; border: none; border-bottom: 2px solid transparent; background: none; color: var(--text-muted); cursor: pointer; }
.posts-subnav-btn:hover { color: var(--text); }
.posts-subnav-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }

.booking-subnav { display: flex; gap: 0; margin-bottom: 16px; }
.booking-subnav-btn { padding: 8px 16px; font: inherit; font-size: 14px; border: none; border-bottom: 2px solid transparent; background: none; color: var(--text-muted); cursor: pointer; }
.booking-subnav-btn:hover { color: var(--text); }
.booking-subnav-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }

.booking-mine-wrap .empty,
.booking-book-wrap .empty { margin: 16px 0; }
.services-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.service-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.service-card-title { margin: 0 0 8px; font-weight: 600; }
.service-card-date { font-size: 14px; color: var(--text-muted); margin: 0 0 8px; }
.service-card-desc { font-size: 14px; color: var(--text-muted); margin: 0 0 8px; line-height: 1.4; }
.service-card-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 120px; }
.text-muted { color: var(--text-muted); font-size: 14px; margin: 0 0 12px; }

.app-section { min-height: 120px; }

.posts-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.post-card-image {
  width: 100%;
  height: 160px;
  object-fit: cover;
  background: var(--bg);
}

.post-card-body { padding: 14px; flex: 1; }
.post-card-title { margin: 0 0 8px; font-size: 1.05rem; font-weight: 600; }
.post-card-price { margin: 0 0 8px; font-weight: 600; color: var(--primary); }
.post-card-desc { margin: 0; font-size: 14px; color: var(--text-muted); line-height: 1.4; }
.post-card-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

.post-image-preview { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 8px; }
.post-image-preview .post-preview-thumb { position: relative; }
.post-image-preview .post-preview-thumb img { max-width: 80px; max-height: 80px; object-fit: cover; border-radius: var(--radius); display: block; }
.post-image-preview .post-preview-remove { position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; padding: 0; border: none; border-radius: 50%; background: var(--danger); color: #fff; font-size: 16px; line-height: 1; cursor: pointer; }
.post-card-image-wrap { position: relative; }
.post-card-image-count { position: absolute; bottom: 6px; right: 6px; background: rgba(0,0,0,0.6); color: #fff; font-size: 12px; padding: 2px 6px; border-radius: 4px; }
.post-view-image { display: flex; flex-wrap: wrap; gap: 8px; }
.post-view-image img { max-width: 100%; max-height: 200px; object-fit: contain; border-radius: var(--radius); }
.post-view-body { padding: 20px; }
.post-view-price { font-weight: 600; color: var(--primary); margin: 0 0 12px; }
.post-view-description { margin: 0; white-space: pre-wrap; }

/* Auth screen */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 380px;
  padding: 24px;
}

.auth-title {
  margin: 0 0 20px;
  font-size: 1.35rem;
  text-align: center;
}

.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.auth-tab {
  flex: 1;
  padding: 10px 16px;
  font: inherit;
  font-size: 14px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  color: var(--text-muted);
}

.auth-tab:hover {
  color: var(--text);
}

.auth-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 500;
}

.auth-form .form-group {
  margin-bottom: 16px;
}

.auth-form .form-actions {
  margin-top: 8px;
}

.btn-block {
  width: 100%;
}

.auth-demo {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.auth-demo .btn + .btn,
.auth-demo .btn + a.btn,
.auth-demo a.btn + .btn {
  margin-top: 8px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  font: inherit;
  font-size: 14px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
  pointer-events: auto;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

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

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

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

.btn-danger {
  background: var(--danger);
  color: #fff;
}

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

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

/* Table */
.main {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.loading, .empty {
  padding: 32px;
  text-align: center;
  color: var(--text-muted);
  margin: 0;
}

.table-wrap {
  overflow-x: auto;
}

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

.table th,
.table td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.table th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.table tbody tr:hover {
  background: var(--bg);
}

.th-actions {
  width: 140px;
  text-align: right;
}

.table .actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
}
.modal-overlay[hidden] {
  display: none;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-sm {
  max-width: 360px;
}

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

.modal-header h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
}

.btn-close {
  background: none;
  border: none;
  font-size: 24px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 4px;
}

.btn-close:hover {
  color: var(--text);
}

/* Form */
#customer-form,
.modal .form-actions {
  padding: 20px;
}

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

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

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  font-size: 14px;
}

.required {
  color: var(--danger);
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.form-group textarea { resize: vertical; min-height: 80px; }

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.form-group input.error {
  border-color: var(--danger);
}

.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  padding-top: 8px;
}

#delete-message {
  margin: 0 0 20px;
  padding: 0 20px;
  color: var(--text-muted);
}

.modal-sm .form-actions {
  padding: 16px 20px;
}

/* Message (errors) */
.message {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 14px;
}

.message.error {
  background: #fef2f2;
  color: var(--danger);
}

.message.success {
  background: #f0fdf4;
  color: #166534;
}

/* Responsive: small screens and mobile */
@media (max-width: 640px) {
  .app {
    padding: 12px;
  }
  .header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .header-actions {
    width: 100%;
    flex-wrap: wrap;
  }
  .app-nav {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .app-nav-btn {
    padding: 8px 14px;
    font-size: 13px;
    white-space: nowrap;
  }
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .table th, .table td {
    padding: 10px 12px;
    font-size: 14px;
  }
  .posts-list {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .post-card-image {
    height: 140px;
  }
  .modal {
    max-width: 100%;
    margin: 8px;
    max-height: 85vh;
  }
  .modal-overlay {
    padding: 8px;
    align-items: flex-start;
  }
  .form-actions {
    flex-wrap: wrap;
  }
  .form-actions .btn {
    flex: 1;
    min-width: 100px;
  }
}

.app-nav-version {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
  padding: 10px 0;
}
