@font-face{font-family:'TheYearofHandicrafts';src:url('/assets/fonts/TheYearofHandicrafts-Regular.otf') format('opentype');font-weight:400;font-style:normal}
@font-face{font-family:'TheYearofHandicrafts';src:url('/assets/fonts/TheYearofHandicrafts-Medium.otf') format('opentype');font-weight:500;font-style:normal}
@font-face{font-family:'TheYearofHandicrafts';src:url('/assets/fonts/TheYearofHandicrafts-SemiBold.otf') format('opentype');font-weight:600;font-style:normal}
@font-face{font-family:'TheYearofHandicrafts';src:url('/assets/fonts/TheYearofHandicrafts-Bold.otf') format('opentype');font-weight:700;font-style:normal}

:root{
  --green:#7C9381;
  --green-dark:#5e755c;
  --ink:#222;
  --muted:#6c6c6c;
  --bg:#f6f2ed;
  --card:#ffffff;
  --border:#e6e1da;
  --danger:#a96464;
  --shadow:0 12px 30px rgba(0,0,0,0.08);
}

*{box-sizing:border-box;margin:0;padding:0}
body{
  font-family:'TheYearofHandicrafts',sans-serif;
  background:radial-gradient(circle at top right, #fdfbf8 0%, #f3eee7 45%, #efe9e0 100%);
  color:var(--ink);
  min-height:100vh;
  padding:24px 0 120px;
  direction:rtl;
  text-align:right;
}

a{color:inherit;text-decoration:none}

.page{
  width:min(1100px, 92vw);
  margin:0 auto;
}

.page-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  margin-bottom:24px;
  flex-wrap:wrap;
}

.page-title{
  font-size:2rem;
  font-weight:700;
  color:var(--green-dark);
}

.page-subtitle{
  color:var(--muted);
  margin-top:6px;
  font-size:1rem;
}

.view{
  background:var(--card);
  border-radius:18px;
  padding:22px;
  box-shadow:var(--shadow);
  border:1px solid var(--border);
}

.view + .view{
  margin-top:20px;
}

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

.view-title{
  font-size:1.4rem;
  font-weight:700;
  color:var(--green-dark);
}

.view-hint{
  color:var(--muted);
  margin-top:6px;
  font-size:0.95rem;
}

.toolbar{
  display:flex;
  align-items:center;
  gap:12px;
  flex-wrap:wrap;
  margin-bottom:18px;
}

.search-field{
  flex:1 1 260px;
  position:relative;
}

.search-field input{
  width:100%;
  padding:12px 14px;
  border-radius:12px;
  border:1px solid var(--border);
  font-size:1rem;
  font-family:inherit;
  background:#fff;
  outline:none;
  transition:border 0.2s ease, box-shadow 0.2s ease;
}

.search-field input:focus{
  border-color:var(--green);
  box-shadow:0 0 0 3px rgba(124,147,129,0.15);
}

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

.item-card{
  border:1px solid var(--border);
  border-radius:16px;
  padding:14px;
  display:flex;
  flex-direction:column;
  gap:10px;
  background:#fff;
  transition:transform 0.2s ease, box-shadow 0.2s ease;
}

.item-card.section{
  background:#5e755c;
  border-color:#5e755c;
  color:#fff;
}

.item-card.section .name-button{
  color:#fff;
}

.item-card.section .edit-btn{
  background:rgba(255,255,255,0.2);
  color:#fff;
}

.item-card.section .media-box{
  border-color:rgba(255,255,255,0.2);
  background:rgba(255,255,255,0.08);
}

.item-card.section .media-placeholder{
  color:#fff;
}

.item-card.section .media-icon{
  background:rgba(255,255,255,0.2);
  color:#fff;
}

.item-card.section .media-edit{
  background:rgba(255,255,255,0.25);
  color:#fff;
}

.item-card:hover{
  transform:translateY(-3px);
  box-shadow:0 10px 20px rgba(0,0,0,0.08);
}

.media-box{
  width:100%;
  aspect-ratio:1 / 1;
  border-radius:14px;
  overflow:hidden;
  background:#f5f1eb;
  border:1px solid var(--border);
  position:relative;
}

.media-box.clickable{
  cursor:pointer;
}

.media-grid{
  width:100%;
  height:100%;
  display:grid;
  gap:2px;
  background:#f5f1eb;
}

.media-grid.grid-1{
  grid-template-columns:1fr;
  grid-template-rows:1fr;
}

.media-grid.grid-2,
.media-grid.grid-3,
.media-grid.grid-4{
  grid-template-columns:repeat(2, 1fr);
  grid-template-rows:repeat(2, 1fr);
}

.media-grid img{
  width:100%;
  height:100%;
  object-fit:cover;
  display:block;
}

.media-placeholder{
  width:100%;
  height:100%;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:6px;
  color:var(--muted);
  font-size:0.9rem;
}

.media-icon{
  width:44px;
  height:44px;
  border-radius:12px;
  background:#efe7dc;
  display:flex;
  align-items:center;
  justify-content:center;
  color:var(--green-dark);
  font-size:1.2rem;
}

.media-edit{
  position:absolute;
  top:8px;
  right:8px;
  border:none;
  background:rgba(241,237,231,0.95);
  color:var(--green-dark);
  width:34px;
  height:34px;
  border-radius:10px;
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  box-shadow:0 6px 14px rgba(0,0,0,0.12);
}

.media-edit:active{
  transform:scale(0.96);
}

.name-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
}

.name-button{
  flex:1;
  border:none;
  background:transparent;
  text-align:right;
  font-family:inherit;
  font-size:1.05rem;
  font-weight:600;
  color:var(--ink);
  cursor:pointer;
  padding:2px 0;
}

.name-button:focus{
  outline:none;
  color:var(--green-dark);
}

.edit-btn{
  border:none;
  background:#f1ede7;
  color:var(--green-dark);
  border-radius:10px;
  width:34px;
  height:34px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  flex-shrink:0;
}

.edit-btn:active{
  transform:scale(0.96);
}

.btn{
  border:none;
  border-radius:12px;
  padding:10px 16px;
  font-family:inherit;
  cursor:pointer;
  display:inline-flex;
  align-items:center;
  gap:8px;
  transition:transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn.primary{
  background:var(--green);
  color:#fff;
  box-shadow:0 8px 18px rgba(124,147,129,0.25);
}

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

.btn.ghost{
  background:#f1ede7;
  color:var(--green-dark);
}

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

.btn.small{
  padding:8px 12px;
  font-size:0.9rem;
}

.btn:active{
  transform:scale(0.98);
}

.back-btn{
  background:#f1ede7;
  color:var(--green-dark);
}

.add-menu{
  position:relative;
}

.add-menu-list{
  position:fixed;
  top:0;
  left:0;
  width:100%;
  height:100%;
  background:rgba(0,0,0,0.35);
  display:flex;
  align-items:center;
  justify-content:center;
  padding:16px;
  z-index:1002;
}

.add-menu-list[hidden]{
  display:none;
}

.add-menu-card{
  width:min(520px, 92vw);
}

.add-menu-actions{
  display:flex;
  flex-direction:column;
  gap:12px;
}

.add-menu-actions .btn{
  width:100%;
  justify-content:center;
  font-size:1rem;
}

.section-meta{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
}

.badge{
  background:#f1ede7;
  color:var(--green-dark);
  border-radius:999px;
  padding:4px 10px;
  font-size:0.85rem;
}

.empty-state,
.loading-state{
  text-align:center;
  padding:24px 12px;
  color:var(--muted);
}

.modal{
  position:fixed;
  top:0;
  left:0;
  width:100%;
  height:100%;
  background:rgba(0,0,0,0.35);
  display:none;
  align-items:center;
  justify-content:center;
  padding:16px;
  z-index:999;
}

.modal.active{
  display:flex;
}

.modal-card{
  width:min(520px, 92vw);
  background:#fff;
  border-radius:18px;
  padding:20px;
  box-shadow:var(--shadow);
}

.modal-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}

.modal-title{
  font-size:1.3rem;
  font-weight:700;
  color:var(--green-dark);
}

.modal-subtitle{
  margin-top:6px;
  color:var(--muted);
  font-size:0.95rem;
}

.modal-close{
  border:none;
  background:#f1ede7;
  color:var(--green-dark);
  border-radius:10px;
  width:36px;
  height:36px;
  cursor:pointer;
  font-size:1.2rem;
}

.modal form{
  margin-top:16px;
  display:flex;
  flex-direction:column;
  gap:12px;
}

.modal label{
  font-weight:600;
  color:var(--ink);
}

.modal input[type="text"],
.modal select{
  width:100%;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--border);
  font-family:inherit;
  background:#fff;
}

.modal input[type="text"]:focus,
.modal select:focus{
  border-color:var(--green);
  box-shadow:0 0 0 3px rgba(124,147,129,0.15);
  outline:none;
}

.file-input{
  display:flex;
  align-items:center;
  flex-wrap:wrap;
  gap:10px;
}

.file-input input[type="file"]{
  display:none;
}

.file-btn{
  padding:8px 14px;
}

.file-hint{
  font-size:0.9rem;
  color:var(--muted);
}

.existing-files{
  display:flex;
  flex-direction:column;
  gap:10px;
  align-items:stretch;
}

.file-chip{
  display:flex;
  align-items:center;
  gap:10px;
  background:#f1ede7;
  padding:6px 8px;
  border-radius:12px;
  width:100%;
}

.file-thumb{
  width:72px;
  height:72px;
  border-radius:10px;
  object-fit:cover;
  flex-shrink:0;
}

.file-icon{
  width:72px;
  height:72px;
  border-radius:10px;
  background:#efe7dc;
  display:flex;
  align-items:center;
  justify-content:center;
  color:var(--green-dark);
  font-size:1.2rem;
  flex-shrink:0;
}

.file-preview{
  display:flex;
  align-items:center;
  gap:10px;
}

.file-actions{
  display:flex;
  align-items:center;
  gap:6px;
  margin-inline-start:auto;
}

.file-move{
  border:none;
  background:#e3d8cd;
  color:var(--green-dark);
  width:28px;
  height:28px;
  border-radius:8px;
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  flex-shrink:0;
}

.file-remove{
  border:none;
  background:#e3d8cd;
  color:var(--danger);
  width:28px;
  height:28px;
  border-radius:8px;
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  flex-shrink:0;
}

.modal-actions{
  display:flex;
  gap:12px;
  justify-content:flex-end;
  flex-wrap:wrap;
  margin-top:6px;
}

.toast{
  position:fixed;
  bottom:24px;
  right:24px;
  background:var(--green-dark);
  color:#fff;
  padding:12px 16px;
  border-radius:12px;
  box-shadow:var(--shadow);
  opacity:0;
  transform:translateY(10px);
  transition:opacity 0.2s ease, transform 0.2s ease;
  z-index:1001;
}

.toast.show{
  opacity:1;
  transform:translateY(0);
}

.forbidden{
  min-height:100vh;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:1.4rem;
  color:var(--green-dark);
}

@media (max-width:640px){
  .page-header{
    flex-direction:column;
    align-items:flex-start;
  }
  .view{
    padding:18px;
  }
}
