:root {
  --navy: #1a3a5c;
  --navy-dark: #14304e;
  --navy-light: #2c5f8a;
  --red: #c42a2a;
  --blue-accent: #2980b9;
  --bg: #f5f7fa;
  --white: #ffffff;
  --border: #dce3ec;
  --text: #333333;
  --muted: #6c757d;
  --success: #27ae60;
  --radius: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.page-wrapper {
  max-width: 100%;
  width: 100%;
  margin: 0 auto;
  padding: 16px max(0px, env(safe-area-inset-left)) 40px max(0px, env(safe-area-inset-right));
  padding-top: max(12px, env(safe-area-inset-top));
  box-sizing: border-box;
}

/* Mavi blok kaldirildi, sadece baslik metni gosteriliyor */
.page-header {
  display: none;
}

.page-header h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.page-header p {
  font-size: 13px;
  opacity: 0.8;
  margin-top: 4px;
}

.content-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 10px 28px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.inst-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.inst-switch-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  background: #001f4d;
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(41, 128, 185, 0.25);
}

.inst-switch-btn:hover {
  background: #2471a3;
  box-shadow: 0 4px 12px rgba(41, 128, 185, 0.35);
}

.inst-switch-btn svg {
  flex-shrink: 0;
}

.inst-hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
  max-width: 220px;
  text-align: right;
  margin: 0;
}

/* Ust satir: program + sagda buton; ipucu sadece butonun altinda (inst-block icinde) */
.selector-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto;
  column-gap: 16px;
  align-items: start;
  margin-bottom: 4px;
}

@media (min-width: 769px) {
  .selector-left {
    grid-column: 1;
    grid-row: 1;
  }
  .inst-block {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    min-width: 0;
  }
  .inst-hint {
    max-width: min(100%, 300px);
    text-align: right;
  }
}

.selector-left {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  flex: 1;
}

.selector-left label {
  font-weight: 600;
  font-size: 18px;
  color: var(--navy);
  white-space: nowrap;
}

.selector-left select {
  flex: 1;
  min-width: 200px;
  max-width: min(100%, 560px);
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 18px;
  font-family: inherit;
  background: var(--white);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.2s;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7' viewBox='0 0 12 7'%3E%3Cpath fill='%23666' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.selector-left select:focus {
  outline: none;
  border-color: var(--navy-light);
  box-shadow: 0 0 0 3px rgba(44, 95, 138, 0.12);
}

.btn-show {
  padding: 12px 24px;
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.btn-show:hover { background: var(--navy-dark); }

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-top: 2px;
  margin-bottom: 16px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

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

.tabs button {
  padding: 12px 14px;
  font-size: 20px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  position: relative;
  white-space: nowrap;
  transition: color 0.2s;
}

.tabs button:hover { color: var(--navy); }

.tabs button.active {
  color: var(--navy);
}

.tabs button.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--navy);
  border-radius: 2px 2px 0 0;
}

.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 9px;
  border-radius: 15px;
  background: var(--border);
  color: var(--muted);
  font-size: 16px;
  font-weight: 700;
  margin-left: 6px;
  transition: background 0.2s, color 0.2s;
}

.tabs button.active .tab-badge {
  background: var(--navy);
  color: #fff;
}

.note-box {
  background: #fffbf0;
  border-left: 3px solid #e6a817;
  padding: 12px 18px;
  font-size: 16px;
  color: #7a6520;
  border-radius: 0 4px 4px 0;
  margin-bottom: 16px;
  line-height: 1.55;
}

.note-box b { color: #5a4a10; }

.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -4px;
  padding: 0 4px;
}

.mobile-cards { display: none; }

.course-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 16px;
}

.course-table thead th {
  background: var(--navy);
  color: #fff;
  padding: 12px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

.course-table thead th:first-child { border-radius: 6px 0 0 0; }
.course-table thead th:last-child  { border-radius: 0 6px 0 0; }

.course-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid #eef1f5;
  vertical-align: top;
}

.course-table tbody tr:hover { background: #f8fafc; }
.course-table tbody tr:last-child td { border-bottom: none; }

.course-table .code-cell a {
  font-weight: 700;
  text-decoration: none;
  transition: opacity 0.2s;
}

.course-table .code-cell a:hover { opacity: 0.8; }

.open-new-tab::after {
  content: "↗";
  display: inline-block;
  margin-left: 4px;
  font-size: 0.85em;
  opacity: 0.7;
  vertical-align: super;
}

.code-mandatory { color: var(--red); }
.code-elective  { color: var(--text); }

.course-table .name-cell {
  min-width: 200px;
  line-height: 1.4;
}

.course-table .name-tr { font-weight: 500; }
.course-table .name-en { color: var(--muted); font-size: 14px; }

.course-table .col-semester,
.course-table .col-lang,
.course-table .col-type { white-space: nowrap; }

.badge-degree {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-yl   { background: #e8f4fd; color: #1a6fb0; }
.badge-dr   { background: #fce8e8; color: #a82020; }

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  stroke: var(--border);
  margin-bottom: 12px;
}

.empty-state p { font-size: 16px; line-height: 1.5; }

.note-row td {
  background: #f8fafc !important;
  font-style: italic;
  color: var(--muted);
  font-size: 13px;
}

.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px;
  color: var(--muted);
  font-size: 14px;
}

.loading-spinner .spin {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.footer-info {
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.footer-info svg { width: 14px; height: 14px; stroke: var(--muted); flex-shrink: 0; }

/* ── TABLET (max 1024px) ── */
@media (max-width: 1024px) {
  .page-wrapper { padding: 14px max(6px, env(safe-area-inset-left)) 32px max(6px, env(safe-area-inset-right)); }
  .page-header  { padding: 0 4px 10px; }
  .content-card { padding: 16px 8px 24px; }
  .course-table .name-cell { min-width: 160px; }
  .selector-left label { font-size: 17px; }
  .selector-left select { font-size: 17px; padding: 12px 14px; }
  .tabs button { padding: 11px 12px; font-size: 18px; }
  .tab-badge { min-width: 26px; height: 26px; font-size: 14px; }
}

/* ── MOBILE (max 768px) ── */
@media (max-width: 768px) {
  .page-wrapper { padding: 8px max(4px, env(safe-area-inset-left)) 24px max(4px, env(safe-area-inset-right)); }
  .page-header  { padding: 0 2px 8px; border-radius: 0; }
  .page-header h1 { font-size: 17px; }
  .page-header p  { font-size: 12px; }
  .content-card { padding: 12px 8px 18px; border-radius: 6px; }

  .selector-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 8px;
  }
  .selector-left { flex-direction: column; align-items: stretch; gap: 8px; }
  .inst-block { display: flex; align-items: stretch; }
  .inst-switch-btn { width: 100%; justify-content: center; padding: 12px 16px; font-size: 15px; }
  .inst-hint { text-align: center; max-width: none; }
  .selector-left label { font-size: 16px; }
  .selector-left select { min-width: 100%; font-size: 16px; padding: 11px 12px; }
  .btn-show { width: 100%; text-align: center; padding: 11px; }

  .tabs { gap: 0; -ms-overflow-style: none; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { padding: 10px 12px; font-size: 16px; }
  .tab-badge { min-width: 24px; height: 24px; font-size: 13px; margin-left: 6px; }

  .note-box { font-size: 14px; padding: 10px 14px; }

  .course-table { display: none; }

  .mobile-cards { display: flex; flex-direction: column; gap: 10px; }

  .mobile-card {
    background: #fafbfc;
    border: 1px solid #eef1f5;
    border-radius: 8px;
    padding: 12px 14px;
    transition: border-color 0.2s;
  }
  .mobile-card:active { border-color: var(--navy-light); }

  .mobile-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
  }

  .mobile-card-code a {
    font-weight: 700;
    font-size: 14px;
    text-decoration: none;
  }

  .mobile-card-name {
    font-size: 13px;
    line-height: 1.4;
    margin-bottom: 8px;
  }
  .mobile-card-name .name-tr { font-weight: 500; }
  .mobile-card-name .name-en { color: var(--muted); font-size: 12px; }

  .mobile-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  .mobile-card-tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    background: #f0f2f5;
    color: var(--muted);
  }

  .mobile-card-tag.tag-type-z { background: #fce8e8; color: #a82020; }
  .mobile-card-tag.tag-type-s { background: #e8f4fd; color: #1a6fb0; }
}

/* ── VERY SMALL (max 380px) ── */
@media (max-width: 380px) {
  .page-header h1 { font-size: 15px; }
  .tabs button { padding: 9px 8px; font-size: 14px; }
  .mobile-card { padding: 10px 12px; }
  .mobile-card-code a { font-size: 13px; }
  .mobile-card-name { font-size: 12px; }
}
