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

:root {
  --bg: #faf8f5;
  --bg-card: #fff;
  --bg-warm: #f2ede6;
  --text: #3a3330;
  --text-light: #8a7e78;
  --accent: #6b4c2a;
  --accent-hover: #8a6540;
  --border: #ddd5cc;
  --border-light: #ece7e0;
  --radius: 3px;
  --max-width: 1100px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

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

img { max-width: 100%; display: block; }

/* ===== Header ===== */
.site-header {
  background: var(--text);
  color: var(--bg);
  padding: 2.5rem 2rem 2rem;
  text-align: center;
}

.site-header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.site-header p {
  color: #b0a89e;
  margin-top: 0.35rem;
  font-size: 0.85rem;
  letter-spacing: 0.06em;
}

/* ===== Main container ===== */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 3rem 2rem;
}

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

.project-card {
  background: var(--bg-card);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  border-radius: var(--radius);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.project-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.project-card .card-image {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  background: var(--bg-warm);
}

.project-card .card-body {
  padding: 1rem 1.1rem 1.1rem;
}

.project-card .card-body h2 {
  font-size: 1rem;
  font-weight: 600;
}

.project-card .card-body .card-date {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-top: 0.2rem;
}

.project-card .card-body .card-cost {
  margin-top: 0.4rem;
  font-size: 0.9rem;
  color: var(--text-light);
}

/* ===== No projects placeholder ===== */
.empty-state {
  text-align: center;
  padding: 6rem 1rem;
  color: var(--text-light);
}

.empty-state p {
  font-size: 1rem;
  font-style: italic;
}

/* ===== Project Detail (modal/overlay) ===== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(58,51,48,0.5);
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  padding: 2rem 1rem;
  backdrop-filter: blur(3px);
}

.overlay.hidden { display: none; }

.detail {
  background: var(--bg-card);
  max-width: 760px;
  width: 100%;
  margin: 3rem auto;
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border);
}

.detail-header h2 {
  font-size: 1.3rem;
  font-weight: 400;
  letter-spacing: 0.04em;
}

.detail-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-light);
  line-height: 1;
  padding: 0.25rem;
}

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

.detail-body { padding: 2rem; }

.detail-body .detail-date {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 1.25rem;
  font-style: italic;
}

.detail-body .detail-desc {
  margin-bottom: 2rem;
  line-height: 1.8;
}

/* Detail images */
.detail-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.detail-images img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  cursor: pointer;
  transition: opacity 0.3s;
}

.detail-images img:hover { opacity: 0.8; }

/* Purchases table */
.purchases {
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
}

.purchases h3 {
  margin-bottom: 1rem;
  font-size: 0.85rem;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-light);
}

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

.purchases th,
.purchases td {
  text-align: left;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.9rem;
}

.purchases th {
  font-weight: 400;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-light);
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.purchases .cost-cell { text-align: right; }

.purchases .total-row td {
  font-weight: 600;
  border-top: 1px solid var(--text);
  border-bottom: none;
  padding-top: 0.75rem;
}

/* ===== Lightbox ===== */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(58,51,48,0.9);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}

.lightbox.hidden { display: none; }

.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
}

/* ===== ADMIN STYLES ===== */
.admin-login {
  max-width: 340px;
  margin: 5rem auto;
  padding: 2.5rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  text-align: center;
}

.admin-login h2 {
  margin-bottom: 1.5rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 1rem;
}

.admin-login input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--bg);
}

.admin-login .error {
  color: #9e3030;
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

.admin-panel { display: none; }

.admin-panel.active { display: block; }

/* Admin toolbar */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.toolbar h2 {
  font-weight: 400;
  font-size: 1.1rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.5rem 1.4rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  letter-spacing: 0.02em;
  background: var(--bg-card);
  color: var(--accent);
}

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

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

.btn-danger {
  border-color: #9e3030;
  color: #9e3030;
  background: var(--bg);
}
.btn-danger:hover {
  background: #9e3030;
  color: #fff;
}

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

.btn-sm {
  padding: 0.35rem 0.9rem;
  font-size: 0.8rem;
}

/* Admin project list */
.admin-projects {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.admin-project-card {
  background: var(--bg-card);
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--border-light);
}

.admin-project-card .card-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.admin-project-card h3 {
  font-weight: 400;
  font-size: 1rem;
  margin-bottom: 0.15rem;
}

.order-buttons {
  display: flex;
  gap: 0.25rem;
}

.btn-order {
  width: 30px;
  height: 30px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-order:hover:not(:disabled) {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-order:disabled {
  opacity: 0.3;
  cursor: default;
}

.admin-project-card .meta {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-bottom: 0.75rem;
}

.admin-project-card .actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Forms */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-light);
  margin-bottom: 0.4rem;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--bg);
}

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

/* Editor panel */
.editor-panel {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  padding: 2rem;
  margin-bottom: 2rem;
}

.editor-panel h2 {
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

/* Image upload area */
.image-upload-area {
  border: 1px dashed var(--border);
  padding: 2rem;
  text-align: center;
  margin-bottom: 1rem;
  cursor: pointer;
  transition: border-color 0.2s;
  color: var(--text-light);
  font-size: 0.9rem;
}

.image-upload-area:hover { border-color: var(--text); }

.image-upload-area.dragover {
  border-color: var(--text);
  background: var(--bg-warm);
}

.image-thumbnails {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.image-thumb {
  position: relative;
  width: 120px;
  height: 90px;
}

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

.image-thumb .remove-img {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #9e3030;
  color: #fff;
  border: none;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.image-thumb .set-cover {
  position: absolute;
  bottom: 4px;
  left: 4px;
  background: rgba(0,0,0,0.5);
  color: #fff;
  border: none;
  font-size: 0.65rem;
  padding: 2px 6px;
  cursor: pointer;
  letter-spacing: 0.04em;
}

.image-thumb.is-cover { outline: 2px solid var(--text); }

/* Status messages */
.status-msg {
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  border: 1px solid;
}

.status-msg.success { background: #f0f7f0; color: #2d5f2d; border-color: #c8dfc8; }
.status-msg.error { background: #fdf0f0; color: #9e3030; border-color: #e8c8c8; }
.status-msg.info { background: #f0f4f7; color: #2d4a5f; border-color: #c8d8e4; }

/* Footer */
.site-footer {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-light);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  background: var(--bg-warm);
}

/* ===== Price on cards ===== */
.card-price {
  margin-top: 0.3rem;
  font-size: 0.95rem;
  color: var(--text);
}

/* ===== Detail price + actions ===== */
.detail-price {
  font-size: 1.2rem;
  margin-bottom: 1.25rem;
}

.detail-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.qty-control {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--border);
}

.qty-btn {
  width: 36px;
  height: 36px;
  background: var(--bg);
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
}

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

.qty-control span {
  width: 40px;
  text-align: center;
  font-size: 0.95rem;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  line-height: 36px;
}

/* ===== Cart icon ===== */
.cart-icon {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 56px;
  height: 56px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 50;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
  transition: transform 0.2s;
}

.cart-icon:hover { transform: scale(1.05); }

.cart-icon.hidden { display: none; }

.cart-icon #cart-count {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #9e3030;
  color: #fff;
  font-size: 0.7rem;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: -apple-system, sans-serif;
}

/* ===== Cart panel ===== */
.cart-panel {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(4px);
  z-index: 150;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  padding: 2rem 1rem;
}

.cart-panel.hidden { display: none; }

.cart-inner {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  max-width: 500px;
  width: 100%;
  margin: 3rem auto;
  padding: 2rem;
}

.cart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.cart-header h2 {
  font-weight: 400;
  font-size: 1.1rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.cart-empty {
  color: var(--text-light);
  font-style: italic;
  padding: 1rem 0;
}

.cart-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-light);
}

.cart-item-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.cart-item-name {
  font-size: 0.95rem;
}

.cart-item-detail {
  font-size: 0.8rem;
  color: var(--text-light);
}

.cart-item-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.cart-item-sum {
  font-size: 0.9rem;
}

.cart-item-remove {
  background: none;
  border: none;
  color: #9e3030;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 0.25rem;
}

.cart-total {
  text-align: right;
  font-size: 1.05rem;
  padding: 1rem 0;
  border-top: 1px solid var(--text);
  margin-top: 0.5rem;
}

.cart-send {
  display: block;
  text-align: center;
  width: 100%;
  margin-top: 1rem;
  text-decoration: none;
}

.cart-send.hidden { display: none; }

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .gallery {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .detail-images {
    grid-template-columns: 1fr;
  }

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

  .site-header {
    padding: 2rem 1.5rem 1.5rem;
  }

  .site-header h1 { font-size: 1.3rem; }

  .container { padding: 2rem 1.25rem; }

  .detail-body { padding: 1.5rem; }
}
