/* =========================
   Edit Page UI — Refactored & Fixed
   ========================= */

/* 1) Tokens */
:root{
  --primary:#2c5f2d;
  --primary-dark:#1e4620;
  --accent:#FF8C42;

  --bg-cream:#FFFBF5;
  --border-soft:#E5E7EB;

  --text-dark:#1F2937;
  --text-medium:#6B7280;

  --shadow-sm:0 1px 3px rgba(0,0,0,.05);
  --shadow-md:0 4px 12px rgba(0,0,0,.08);
  --shadow-lg:0 10px 30px rgba(0,0,0,.12);

  --radius-sm:10px;
  --radius-md:12px;
  --radius-lg:16px;

  --focus-ring:0 0 0 4px rgba(44,95,45,.10);
}

/* 2) Base */
*{ box-sizing:border-box; }

/* page wrapper */
.edit-page{
  min-height:100vh;
  background:linear-gradient(135deg,#f0f7f0 0%,#e8f4e8 100%);
  padding:40px 20px;
}

.edit-wrapper{ max-width:1100px; margin:0 auto; }

/* 3) Sticky header */
.sticky-header{
  position:sticky;
  top:0;
  z-index:100;

  background:#fff;
  padding:24px 32px;
  border-radius:var(--radius-lg);
  box-shadow:var(--shadow-md);

  margin-bottom:30px;

  display:flex;
  justify-content:space-between;
  align-items:center;
  flex-wrap:wrap;
  gap:16px;
}

.header-left{ flex:1; min-width:300px; }

.product-type-pill{
  display:inline-block;
  padding:6px 16px;
  background:var(--primary);
  color:#fff;
  border-radius:999px;

  font-size:13px;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:.5px;
  margin-bottom:8px;
}

.page-title{
  font-family:'Fraunces',serif;
  font-size:36px;
  font-weight:900;
  color:var(--primary-dark);
  margin:0;
  line-height:1.2;
}

.quick-actions{ display:flex; gap:12px; }

/* 4) Layout */
.content-grid{
  display:grid;
  grid-template-columns:350px 1fr;
  gap:30px;
}

/* 5) Sidebar */
.sidebar{
  position:sticky;
  top:140px;
  height:fit-content;
}

.image-card{
  background:#fff;
  border-radius:var(--radius-lg);
  padding:24px;
  box-shadow:var(--shadow-md);
  margin-bottom:20px;
}

.image-preview{
  position:relative;
  width:100%;
  aspect-ratio:1;

  background:var(--bg-cream);
  border-radius:var(--radius-md);
  overflow:hidden;

  margin-bottom:16px;
  border:2px dashed var(--border-soft);
}

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

.image-placeholder{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  height:100%;
  color:var(--text-medium);
}

.image-placeholder i{ font-size:48px; margin-bottom:12px; }

/* Upload button wrapper */
.upload-btn-wrapper{
  position:relative;
  overflow:hidden;
  display:inline-block;
  width:100%;
}

.upload-btn{
  width:100%;
  padding:12px;

  background:var(--primary);
  color:#fff;

  border-radius:8px;
  font-weight:600;
  cursor:pointer;

  text-align:center;
  transition:transform .2s ease, background .2s ease;
  border:none;

  display:flex;
  align-items:center;
  justify-content:center;
  gap:8px;
}

.upload-btn:hover{
  background:var(--primary-dark);
  transform:translateY(-1px);
}

.upload-btn-wrapper input[type=file]{
  position:absolute;
  inset:0;
  opacity:0;
  cursor:pointer;
}

/* Info card */
.info-card{
  background:#fff;
  border-radius:var(--radius-lg);
  padding:20px;
  box-shadow:var(--shadow-sm);
}

.info-item{
  display:flex;
  align-items:center;
  gap:12px;
  padding:12px 0;
  border-bottom:1px solid var(--border-soft);
}
.info-item:last-child{ border-bottom:none; }

.info-icon{
  width:40px;
  height:40px;
  border-radius:10px;
  background:var(--bg-cream);
  display:flex;
  align-items:center;
  justify-content:center;
  color:var(--primary);
}

.info-text{ flex:1; }

.info-label{
  font-size:12px;
  color:var(--text-medium);
  font-weight:600;
  text-transform:uppercase;
  letter-spacing:.5px;
}

.info-value{
  font-size:14px;
  color:var(--text-dark);
  font-weight:600;
  margin-top:2px;
}

/* 6) Form container */
.form-container{
  background:#fff;
  border-radius:var(--radius-lg);
  box-shadow:var(--shadow-md);
  overflow:hidden;
}

.form-section{
  padding:32px;
  border-bottom:1px solid var(--border-soft);
}
.form-section:last-child{ border-bottom:none; }

.section-header{
  display:flex;
  align-items:center;
  gap:12px;
  margin-bottom:24px;
  padding-bottom:16px;
  border-bottom:2px solid var(--border-soft);
}

.section-icon{
  width:48px;
  height:48px;
  border-radius:12px;
  background:linear-gradient(135deg,var(--primary),var(--primary-dark));
  display:flex;
  align-items:center;
  justify-content:center;
  color:#fff;
  font-size:24px;
}

.section-title{
  font-family:'Fraunces',serif;
  font-size:22px;
  font-weight:700;
  color:var(--primary-dark);
  margin:0;
}

/* grid rows */
.form-row{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(280px,1fr));
  gap:20px;
  margin-bottom:20px;
}

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

.form-label{
  display:block;
  font-weight:600;
  margin-bottom:8px;
  color:var(--text-dark);
  font-size:14px;
}
.form-label.required::after{ content:" *"; color:#EF4444; }

/* Inputs */
.form-input,.form-select,.form-textarea{
  width:100%;
  padding:12px 16px;
  border:2px solid var(--border-soft);
  border-radius:10px;
  font-size:15px;
  font-family:'DM Sans',sans-serif;
  transition:border-color .2s ease, box-shadow .2s ease;
}

.form-input:focus,.form-select:focus,.form-textarea:focus{
  outline:none;
  border-color:var(--primary);
  box-shadow:var(--focus-ring);
}

.form-textarea{
  resize:vertical;
  min-height:120px;
  line-height:1.6;
}

.input-hint{
  font-size:13px;
  color:var(--text-medium);
  margin-top:6px;
  display:flex;
  align-items:center;
  gap:6px;
}

/* Checkbox */
.checkbox-group{ display:flex; flex-direction:column; gap:12px; }

.checkbox-label{
  display:flex;
  align-items:center;
  gap:10px;
  cursor:pointer;

  padding:12px 16px;
  background:var(--bg-cream);

  border-radius:10px;
  transition:background .2s ease, border-color .2s ease;
  border:2px solid transparent;
}
.checkbox-label:hover{
  border-color:var(--primary);
  background:#fff;
}

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

.checkbox-label span{ font-weight:500; color:var(--text-dark); }

/* 7) Alerts */
.alert{
  padding:16px 20px;
  border-radius:12px;
  margin-bottom:24px;
  display:flex;
  align-items:center;
  gap:12px;
  animation:slideIn .3s ease;
}

.alert-error{
  background:#FEE2E2;
  color:#991B1B;
  border-left:4px solid #DC2626;
}

.alert-success{
  background:#D1FAE5;
  color:#065F46;
  border-left:4px solid #10B981;
}

/* 8) Buttons - Consolidated & Clean */
.btn{
  padding:14px 28px;
  border-radius:10px;
  font-weight:600;
  font-size:15px;
  cursor:pointer;

  transition:transform .2s ease, box-shadow .2s ease, background .2s ease, border-color .2s ease, color .2s ease;
  border:2px solid transparent;
  text-decoration:none;

  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:10px;

  font-family:'DM Sans',sans-serif;
}

.btn-primary{
  background:linear-gradient(135deg,var(--primary),var(--primary-dark));
  color:#fff;
  box-shadow:0 4px 12px rgba(44,95,45,.30);
}
.btn-primary:hover{
  transform:translateY(-2px);
  box-shadow:0 6px 20px rgba(44,95,45,.40);
}
.btn-primary:disabled{
  background:#9CA3AF;
  box-shadow:none;
  cursor:not-allowed;
  transform:none;
}

.btn-secondary{
  background:#fff;
  color:var(--text-dark);
  border-color:var(--border-soft);
}
.btn-secondary:hover{
  border-color:var(--primary);
  color:var(--primary);
}

.btn-outline{
  background:#fff;
  color:var(--text-dark);
  border-color:var(--border-soft);
}
.btn-outline:hover{
  border-color:var(--primary);
  color:var(--primary);
}

.btn-success{
  background:#10B981;
  color:#fff;
  border-color:#10B981;
  box-shadow:0 4px 12px rgba(16,185,129,.25);
}
.btn-success:hover{
  transform:translateY(-2px);
  box-shadow:0 6px 18px rgba(16,185,129,.30);
}

.btn-danger{
  background:#FEE2E2;
  color:#991B1B;
  border-color:#FECACA;
}
.btn-danger:hover{ background:#FCA5A5; }

/* 9) Form actions - properly scoped */
.form-actions{
  display:flex;
  gap:12px;
  justify-content:flex-end;
  padding:24px 32px;
  background:var(--bg-cream);
  border-top:2px solid var(--border-soft);
}

/* Smaller buttons in form actions for cleaner look */
.form-actions .btn{
  padding:12px 24px;
  font-size:14px;
}

/* 10) Validation states */
.form-input.error,
.form-textarea.error,
.form-select.error{
  border-color:#EF4444;
  background-color:#FEF2F2;
}

.form-input.success,
.form-textarea.success,
.form-select.success{
  border-color:#10B981;
}

.field-error{
  color:#EF4444;
  font-size:13px;
  margin-top:6px;
  display:flex;
  align-items:center;
  gap:6px;
  animation:slideDown .2s ease-out;
}

/* 11) Loading states */
.loading-overlay{
  position:fixed;
  top:0;
  left:0;
  right:0;
  bottom:0;
  background:rgba(0,0,0,.5);
  display:none;
  align-items:center;
  justify-content:center;
  z-index:9999;
}

.loading-overlay.active{
  display:flex;
}

.loading-spinner{
  background:white;
  padding:32px 48px;
  border-radius:12px;
  box-shadow:0 20px 60px rgba(0,0,0,.3);
  text-align:center;
}

.spinner{
  width:48px;
  height:48px;
  border:4px solid #E5E7EB;
  border-top-color:var(--primary);
  border-radius:50%;
  animation:spin .8s linear infinite;
  margin:0 auto 16px;
}

/* 12) Toast notifications */
.toast{
  position:fixed;
  top:24px;
  right:24px;
  background:white;
  padding:16px 24px;
  border-radius:8px;
  box-shadow:0 10px 40px rgba(0,0,0,.2);
  display:flex;
  align-items:center;
  gap:12px;
  z-index:10000;
  animation:slideInRight .3s ease-out;
  max-width:400px;
}

.toast.success{
  border-left:4px solid #10B981;
}

.toast.error{
  border-left:4px solid #EF4444;
}

.toast-icon{
  font-size:24px;
}

.toast.success .toast-icon{
  color:#10B981;
}

.toast.error .toast-icon{
  color:#EF4444;
}

.toast-content{
  flex:1;
}

.toast-title{
  font-weight:600;
  margin-bottom:4px;
  color:#111827;
}

.toast-message{
  font-size:14px;
  color:#6B7280;
}

.toast-close{
  background:none;
  border:none;
  color:#9CA3AF;
  cursor:pointer;
  padding:4px;
  font-size:20px;
  line-height:1;
}

.toast-close:hover{
  color:#4B5563;
}

/* 13) Animations */
@keyframes slideIn{
  from{ opacity:0; transform:translateY(-10px); }
  to{ opacity:1; transform:translateY(0); }
}

@keyframes slideDown{
  from{ opacity:0; transform:translateY(-4px); }
  to{ opacity:1; transform:translateY(0); }
}

@keyframes slideInRight{
  from{ transform:translateX(400px); opacity:0; }
  to{ transform:translateX(0); opacity:1; }
}

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

/* 14) Responsive */
@media (max-width:1024px){
  .content-grid{ grid-template-columns:1fr; }
  .sidebar{ position:relative; top:0; }
}

@media (max-width:768px){
  .edit-page{ padding:20px 12px; }
  .sticky-header{ padding:20px; }
  .page-title{ font-size:28px; }

  .form-section{ padding:24px 20px; }
  .form-row{ grid-template-columns:1fr; }

  .form-actions{
    flex-direction:column;
    padding:20px;
  }

  .btn{ width:100%; }
  .form-actions .btn{ width:100%; }
  .quick-actions{ width:100%; }
}