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

:root {
  --green-dark:  #4A6B36;
  --green-mid:   #5B8243;
  --green-light: #8FA67E;
  --cream:       #F9F6EB;
  --beige:       #EDE8D8;
  --border:      #DCE0D5;
  --text:        #2F332D;
  --text-muted:  #6B7280;
  --white:       #FFFFFF;
  --red:         #DC2626;
  --red-light:   #FEE2E2;
  --shadow:      0 1px 3px rgba(0,0,0,0.08);
  --shadow-md:   0 4px 12px rgba(0,0,0,0.1);
  --radius:      8px;
}

body {
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  background: var(--cream);
  color: var(--text);
  min-height: 100vh;
}

/* ── Layout ── */
.app { display: flex; flex-direction: column; min-height: 100vh; }

header {
  background: var(--green-dark);
  color: var(--white);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
}

header h1 {
  font-family: Georgia, serif;
  font-size: 20px;
  letter-spacing: 2px;
  font-weight: 700;
}

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

.main { display: flex; flex: 1; }

/* ── Sidebar ── */
.sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: calc(100vh - 60px);
  position: sticky;
  top: 60px;
  overflow-y: auto;
}

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

.sidebar-header h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); }

.category-list { flex: 1; overflow-y: auto; padding: 8px 0; }

.category-item {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all 0.15s;
  gap: 10px;
}

.category-item:hover { background: var(--cream); }

.category-item.active {
  background: #EBF2E6;
  border-left-color: var(--green-mid);
}

.category-item .cat-name {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
}

.category-item .cat-count {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--beige);
  padding: 2px 7px;
  border-radius: 10px;
}

.category-item .inactive-badge {
  font-size: 10px;
  color: var(--text-muted);
  background: #F3F4F6;
  padding: 1px 6px;
  border-radius: 10px;
}

/* ── Content ── */
.content { flex: 1; padding: 24px; overflow-y: auto; }

.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.content-header h2 { font-size: 20px; font-weight: 700; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
}

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

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

.btn-danger { background: var(--red); color: var(--white); }
.btn-danger:hover { background: #B91C1C; }

.btn-ghost { background: transparent; color: var(--text-muted); padding: 6px 10px; }
.btn-ghost:hover { background: var(--beige); color: var(--text); }

.btn-pdf {
  background: var(--white);
  color: var(--green-dark);
  border: 1.5px solid var(--green-mid);
  font-weight: 600;
}
.btn-pdf:hover { background: #EBF2E6; }

.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ── Items Table ── */
.items-table {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.items-table th {
  background: var(--beige);
  padding: 10px 14px;
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 600;
}

.items-table td {
  padding: 11px 14px;
  border-top: 1px solid var(--border);
  font-size: 14px;
  vertical-align: middle;
}

.items-table tr:hover td { background: #FAFAF8; }

.item-name { font-weight: 500; }
.item-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.price-badge {
  font-family: Georgia, serif;
  font-weight: 700;
  color: var(--green-dark);
  font-size: 14px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.status-active   { background: #D1FAE5; color: #065F46; }
.status-inactive { background: #F3F4F6; color: #6B7280; }

.row-actions { display: flex; gap: 6px; }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--white);
  border-radius: 12px;
  width: 480px;
  max-width: 95vw;
  box-shadow: var(--shadow-md);
  transform: translateY(10px);
  transition: transform 0.2s;
}

.modal-overlay.open .modal { transform: translateY(0); }

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

.modal-header h3 { font-size: 16px; font-weight: 700; }

.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ── Form ── */
.form-group { display: flex; flex-direction: column; gap: 5px; }

.form-group label { font-size: 13px; font-weight: 600; color: var(--text); }

.form-group input,
.form-group textarea,
.form-group select {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--white);
  transition: border-color 0.15s;
  outline: none;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus { border-color: var(--green-mid); }

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

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--cream);
  border-radius: 6px;
}

.toggle-row label { font-size: 14px; font-weight: 500; }

/* Toggle switch */
.toggle {
  position: relative;
  width: 40px;
  height: 22px;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: #D1D5DB;
  border-radius: 22px;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle input:checked + .toggle-slider { background: var(--green-mid); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ── Toast ── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 300;
}

.toast {
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: slideIn 0.2s ease;
  max-width: 320px;
}

.toast-success { background: #065F46; color: white; }
.toast-error   { background: var(--red); color: white; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state svg { margin-bottom: 12px; opacity: 0.4; }
.empty-state p { font-size: 15px; }

/* ── Loading ── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: var(--text-muted);
  gap: 10px;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--green-mid);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* ── Category edit inline ── */
.cat-edit-form {
  padding: 12px 16px;
  background: var(--cream);
  border-top: 1px solid var(--border);
  display: none;
  gap: 8px;
  flex-direction: column;
}

.cat-edit-form.open { display: flex; }

/* ── Drag & Drop ── */
.drag-handle {
  cursor: grab;
  color: var(--text-muted);
  font-size: 16px;
  padding: 0 4px;
  user-select: none;
  flex-shrink: 0;
}

.drag-handle:active { cursor: grabbing; }

.sortable-ghost {
  opacity: 0.4;
  background: var(--beige) !important;
}

.category-item .drag-handle { opacity: 0.4; transition: opacity 0.15s; }
.category-item:hover .drag-handle { opacity: 1; }

tbody tr .drag-handle { opacity: 0.3; transition: opacity 0.15s; }
tbody tr:hover .drag-handle { opacity: 1; }

/* ── Mobil Tab Bar — masaüstünde gizli ── */
.mobile-tabs { display: none; }
.mobile-only { display: none; }

/* ── Drawer ── */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.drawer-overlay.open { opacity: 1; pointer-events: all; }

.drawer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--white);
  border-radius: 16px 16px 0 0;
  max-height: 75vh;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.25s ease;
}

.drawer-overlay.open .drawer { transform: translateY(0); }

.drawer-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}

.drawer-list { overflow-y: auto; padding: 8px 0; flex: 1; }

/* ── Responsive: Tablet & Mobile ── */

/* Tablet (≤900px): sidebar daralt */
@media (max-width: 900px) {
  header h1 { font-size: 15px; letter-spacing: 1px; }

  .sidebar { width: 220px; min-width: 220px; }

  .content { padding: 16px; }
}

/* Mobile (≤640px): sidebar gizle, alt tab bar göster */
@media (max-width: 640px) {
  header {
    padding: 0 14px;
    height: 52px;
  }

  header h1 { font-size: 13px; letter-spacing: 0.5px; }

  .btn-header-text { display: none; }

  .header-actions { gap: 6px; }

  .btn-pdf, .btn-secondary.preview-btn {
    padding: 7px 10px;
    font-size: 18px;
  }

  /* Sidebar gizle */
  .sidebar { display: none; }

  /* Mobil buton göster */
  .mobile-only { display: inline-flex; }

  /* main flex yönünü düzenle */
  .main { flex-direction: column; }

  /* Mobil tab bar göster */
  .mobile-tabs {
    display: flex;
    overflow-x: auto;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 52px;
    z-index: 90;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .mobile-tabs::-webkit-scrollbar { display: none; }

  .mobile-tab {
    flex-shrink: 0;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
  }

  .mobile-tab.active {
    color: var(--green-dark);
    border-bottom-color: var(--green-mid);
    font-weight: 600;
  }

  /* İçerik alanı */
  .content {
    padding: 12px;
    width: 100%;
  }

  .content-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 14px;
  }

  .content-header h2 { font-size: 16px; }

  .content-header > div { width: 100%; justify-content: flex-end; }

  /* Kart listesi (mobil) */
  .items-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .item-card {
    display: flex;
    align-items: center;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 10px 12px;
    gap: 10px;
  }

  .item-card .drag-handle { flex-shrink: 0; opacity: 0.5; }
  .item-card-body { flex: 1; min-width: 0; }
  .item-card-body .item-name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .item-card-body .item-desc { font-size: 11px; }
  .item-card .price-badge { font-size: 13px; flex-shrink: 0; }
  .item-card .row-actions { flex-shrink: 0; gap: 4px; }
  .item-card .row-actions .btn { padding: 5px 8px; font-size: 12px; }

  /* Modal tam ekran */
  .modal-overlay { align-items: flex-end; }

  .modal {
    width: 100%;
    max-width: 100%;
    border-radius: 16px 16px 0 0;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(100%);
  }

  .modal-overlay.open .modal { transform: translateY(0); }

  /* Toast alt ortada */
  .toast-container {
    bottom: 16px;
    right: 12px;
    left: 12px;
  }

  .toast { max-width: 100%; text-align: center; }
}
