*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0D1117;
  --surface: #161B22;
  --surface2: #1C2230;
  --border: #2A3142;
  --yellow: #FFD60A;
  --yellow-dim: rgba(255,214,10,0.12);
  --yellow-hover: rgba(255,214,10,0.2);
  --text: #E6EDF3;
  --muted: #8B949E;
  --danger: #FF4C4C;
  --green: #3FB950;
  --blue: #58A6FF;
  --radius: 10px;
  --radius-lg: 16px;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---- HEADER ---- */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 100;
}
.logo {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 1px;
  color: var(--text);
}
.logo span { color: var(--yellow); }
.header-actions { display: flex; gap: 10px; }
.btn {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.18s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
}
.btn-ghost:hover { border-color: var(--yellow); color: var(--yellow); }
.btn-primary {
  background: var(--yellow);
  color: #000;
}
.btn-primary:hover { background: #ffe33d; transform: translateY(-1px); }
.btn-danger { background: rgba(255,76,76,0.15); color: var(--danger); border: 1px solid rgba(255,76,76,0.3); }
.btn-danger:hover { background: rgba(255,76,76,0.25); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-icon { width: 32px; height: 32px; padding: 0; justify-content: center; }

/* ---- LAYOUT ---- */
.app-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: calc(100vh - 65px);
}

/* ---- SIDEBAR ---- */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  overflow-y: auto;
  max-height: calc(100vh - 65px);
  position: sticky;
  top: 65px;
}
.sidebar-section h3 {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
.field input, .field select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: border-color 0.15s;
}
.field input:focus, .field select:focus { border-color: var(--yellow); }
.field select option { background: var(--surface2); }

.goal-tags { display: flex; flex-wrap: wrap; gap: 7px; }
.goal-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 20px;
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  background: transparent;
}
.goal-tag:hover { border-color: var(--yellow); color: var(--yellow); }
.goal-tag.active { background: var(--yellow-dim); border-color: var(--yellow); color: var(--yellow); }

.library-search {
  position: relative;
  margin-bottom: 10px;
}
.library-search input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px 8px 34px;
  border-radius: 8px;
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  outline: none;
}
.library-search input:focus { border-color: var(--yellow); }
.library-search .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 14px;
  pointer-events: none;
}
.muscle-filter { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.muscle-btn {
  font-size: 10px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 12px;
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  background: transparent;
  transition: all 0.12s;
}
.muscle-btn:hover, .muscle-btn.active { border-color: var(--blue); color: var(--blue); background: rgba(88,166,255,0.1); }

.exercise-list { display: flex; flex-direction: column; gap: 5px; max-height: 340px; overflow-y: auto; padding-right: 4px; }
.exercise-list::-webkit-scrollbar { width: 4px; }
.exercise-list::-webkit-scrollbar-track { background: transparent; }
.exercise-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.ex-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  cursor: grab;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 9px;
}
.ex-card:hover { border-color: var(--yellow); transform: translateX(2px); }
.ex-card.dragging { opacity: 0.4; }
.ex-icon {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: var(--yellow-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.ex-info { flex: 1; min-width: 0; }
.ex-name { font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ex-muscle { font-size: 10px; color: var(--muted); margin-top: 1px; }
.ex-add-btn {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  transition: all 0.12s;
}
.ex-add-btn:hover { background: var(--yellow); color: #000; border-color: var(--yellow); }

/* ---- MAIN ---- */
.main { padding: 28px 32px; overflow-y: auto; }

.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.main-header h1 {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 0.5px;
}
.main-header h1 span { color: var(--yellow); }
.stats-bar { display: flex; gap: 20px; }
.stat { text-align: center; }
.stat-val {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 24px;
  font-weight: 800;
  color: var(--yellow);
}
.stat-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }

/* Hafta grid */
.week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}

.day-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  min-height: 480px;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s;
  position: relative;
}
.day-col.drag-over { border-color: var(--yellow); background: var(--yellow-dim); }
.day-col.rest-day { border-style: dashed; opacity: 0.6; }

.day-header {
  padding: 12px 10px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.day-name {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
}
.day-col.active-day .day-name { color: var(--yellow); }
.day-badge {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
  background: var(--yellow-dim);
  color: var(--yellow);
}
.day-badge.rest { background: rgba(139,148,158,0.15); color: var(--muted); }

.day-label-input {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  padding: 6px 10px 4px;
  outline: none;
  font-weight: 500;
  border-bottom: 1px solid transparent;
  transition: border-color 0.12s;
}
.day-label-input:focus { border-bottom-color: var(--border); }
.day-label-input::placeholder { color: var(--border); }

.day-exercises {
  flex: 1;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}
.day-exercises::-webkit-scrollbar { width: 3px; }
.day-exercises::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.prog-ex {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 8px 6px;
  position: relative;
  transition: all 0.15s;
}
.prog-ex:hover { border-color: rgba(255,214,10,0.3); }
.prog-ex-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}
.prog-ex-icon {
  font-size: 13px;
  width: 22px;
  height: 22px;
  background: var(--yellow-dim);
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.prog-ex-name {
  font-size: 11px;
  font-weight: 600;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.prog-ex-del {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s;
  flex-shrink: 0;
}
.prog-ex-del:hover { color: var(--danger); background: rgba(255,76,76,0.1); }

.prog-ex-params {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 4px;
}
.param-field { display: flex; flex-direction: column; }
.param-field label { font-size: 9px; color: var(--muted); margin-bottom: 2px; text-transform: uppercase; letter-spacing: 0.5px; }
.param-field input {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 5px;
  border-radius: 5px;
  font-size: 11px;
  font-family: 'Inter', sans-serif;
  outline: none;
  text-align: center;
  width: 100%;
  transition: border-color 0.12s;
}
.param-field input:focus { border-color: var(--yellow); }

.day-footer {
  padding: 8px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 6px;
}
.day-footer button {
  flex: 1;
  font-size: 10px;
  font-weight: 600;
  padding: 5px;
  border-radius: 6px;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.12s;
  font-family: 'Inter', sans-serif;
}
.day-footer button:hover { border-color: var(--yellow); color: var(--yellow); }
.toggle-rest {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  padding: 0;
  transition: color 0.12s;
}
.toggle-rest:hover { color: var(--yellow); }

.drop-hint {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--border);
  font-size: 11px;
  text-align: center;
  padding: 10px;
}
.drop-hint svg { opacity: 0.3; }

/* Özet paneli */
.summary-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  margin-top: 4px;
}
.summary-panel h2 {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.5px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.summary-panel h2 span { color: var(--yellow); }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}
.summary-stat {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-align: center;
}
.summary-stat .val {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 32px;
  font-weight: 900;
  color: var(--yellow);
  line-height: 1;
}
.summary-stat .lbl { font-size: 11px; color: var(--muted); margin-top: 3px; }

.summary-days { display: flex; flex-direction: column; gap: 8px; }
.summary-day {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface2);
  border-radius: 8px;
  padding: 10px 14px;
  border: 1px solid var(--border);
}
.sum-day-name {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1px;
  width: 32px;
  color: var(--muted);
  text-transform: uppercase;
}
.sum-day-label { font-size: 12px; font-weight: 600; flex: 1; }
.sum-day-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.sum-tag {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(88,166,255,0.1);
  color: var(--blue);
  font-weight: 500;
}
.sum-tag.rest-tag { background: rgba(139,148,158,0.1); color: var(--muted); }
.sum-count {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 16px;
  font-weight: 800;
  color: var(--yellow);
}

.export-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface);
  border: 1px solid var(--green);
  color: var(--green);
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  z-index: 9999;
  transform: translateY(60px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast.show { transform: translateY(0); opacity: 1; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 420px;
  max-width: 95vw;
  transform: scale(0.95);
  transition: transform 0.2s;
}
.modal-overlay.open .modal { transform: scale(1); }
.modal h2 {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 18px;
}
.modal h2 span { color: var(--yellow); }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; justify-content: flex-end; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ==========================================
   RESPONSIVE DESIGN (MOBIL UYUMLULUK) - 
   ========================================== */

/* Tablet ve Küçük Ekranlar İçin (Genişlik 1024px ve altı) */
@media (max-width: 1024px) {
  .week-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }
  
  .summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Telefonlar İçin (Genişlik 768px ve altı) */
@media (max-width: 768px) {
  /* HEADER DÜZENLEMESİ: Butonların sağa taşmasını engeller */
  header {
    padding: 12px 16px;
    flex-direction: column; /* Logo üstte, butonlar altta */
    gap: 12px;
    align-items: stretch;
  }
  
  .logo {
    font-size: 22px;
    text-align: center;
  }

  .header-actions {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* 4 butonu yan yana eşit böler */
    gap: 6px;
    width: 100%;
  }

  .header-actions .btn {
    padding: 8px 4px;
    font-size: 11px;  /* Yazı boyutunu mobilde küçülttük */
    flex-direction: column; /* İkon üstte, yazı altta */
    gap: 4px;
    text-align: center;
    justify-content: center;
    border-radius: 6px;
    white-space: normal; /* Yazıların alt satıra geçmesine izin verir */
    height: auto;
  }
  
  .header-actions .btn-icon {
    width: 100%; /* İkon butonunu da grid'e uydurur */
  }

  /* LAYOUT DÜZENLEMESİ: Sol paneli ve sağ paneli alt alta getirir */
  .app-layout {
    display: flex;
    flex-direction: column;
    min-height: auto;
  }

  .sidebar {
    width: 100%;
    position: static; /* Mobilde yapışkanlığı kaldırır */
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 20px 16px;
    gap: 20px;
  }
  
  .exercise-list {
    max-height: 220px;
  }

  /* ANA İÇERİK ALANI (Haftalık Program) */
  .main {
    width: 100%;
    padding: 20px 16px;
  }

  .main-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .stats-bar {
    width: 100%;
    justify-content: space-between;
  }

  /* Antrenman günlerini alt alta tek sütun yapar */
  .week-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .day-col {
    min-height: auto;
  }

  /* Özet Paneli Yapısı */
  .summary-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .summary-day {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .sum-day-name {
    width: auto;
  }

  .export-actions {
    flex-direction: column;
  }
  
  .export-actions .btn {
    width: 100%;
    justify-content: center;
  }
  
  .modal {
    padding: 20px;
    width: 90vw;
  }
}