/* ================================================================
   OWO Academy — Program Search Widget CSS
   Inspired by Askuni UX, branded for OWO Academy
   ================================================================ */

:root {
  /* Brand */
  --owo-blue: #1E40AF;
  --owo-blue-hover: #1E3A8A;
  --owo-blue-light: #DBEAFE;
  --owo-gradient-start: #0F172A;
  --owo-gradient-mid: #1E3A8A;
  --owo-gradient-end: #3730A3;

  /* Neutrals */
  --ink-900: #0F172A;
  --ink-700: #334155;
  --ink-500: #64748B;
  --ink-400: #94A3B8;
  --ink-300: #CBD5E1;
  --ink-200: #E2E8F0;
  --ink-100: #F1F5F9;
  --ink-50:  #F8FAFC;
  --white: #FFFFFF;

  /* Chip palettes (pastel) */
  --chip-cyan-bg: #E0F7FA;
  --chip-cyan-text: #006064;
  --chip-orange-bg: #FFF3E0;
  --chip-orange-text: #E65100;
  --chip-blue-bg: #E3F2FD;
  --chip-blue-text: #0D47A1;
  --chip-gray-bg: #F1F5F9;
  --chip-gray-text: #475569;
  --chip-purple-bg: #F3E8FF;
  --chip-purple-text: #6B21A8;
  --chip-green-bg: #DCFCE7;
  --chip-green-text: #14532D;
  --chip-red: #DC2626;

  /* Typography */
  --font-heading: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, sans-serif;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.03), 0 4px 6px rgba(0,0,0,0.02);
  --shadow-md: 0 4px 12px rgba(30,64,175,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 40px rgba(15,23,42,0.12);
  --shadow-hero: 0 30px 60px -15px rgba(15,23,42,0.3);

  /* Radii */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 24px;

  /* Spacing */
  --space-xs: 6px;
  --space-sm: 10px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
}

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

body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink-900);
  background: var(--ink-50);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 { font-family: var(--font-heading); margin: 0; color: var(--ink-900); }
button { font-family: inherit; cursor: pointer; border: none; background: transparent; }
a { color: inherit; text-decoration: none; }
input, select, button { font-family: inherit; font-size: inherit; }

/* ============ HERO ============ */
.hero {
  position: relative;
  padding: 80px 20px 120px;
  color: var(--white);
  overflow: hidden;
  isolation: isolate;
}
.hero-bg {
  position: absolute; inset: 0; z-index: -1;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(99,102,241,0.3), transparent 60%),
    linear-gradient(135deg, var(--owo-gradient-start) 0%, var(--owo-gradient-mid) 55%, var(--owo-gradient-end) 100%);
}
.hero-bg::after {
  content: '';
  position: absolute; inset: 0;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(255,255,255,0.06) 1px, transparent 1px),
    radial-gradient(circle at 80% 80%, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 40px 40px, 60px 60px;
  opacity: 0.7;
}
.hero-content { max-width: 1200px; margin: 0 auto; text-align: center; }
.hero h1 {
  font-size: clamp(36px, 6vw, 56px);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 12px;
  color: var(--white);
  text-shadow: 0 2px 20px rgba(0,0,0,0.2);
}
.hero p {
  font-size: clamp(14px, 2vw, 18px);
  color: rgba(255,255,255,0.8);
  margin: 0;
  font-weight: 400;
}
.hero p span { color: var(--white); font-weight: 600; }

/* ============ STICKY SEARCH BAR ============ */
.search-wrap {
  position: sticky; top: 0; z-index: 50;
  padding: 0 20px;
  margin-top: -60px;
  margin-bottom: 32px;
}
.search-card {
  max-width: 1200px;
  margin: 0 auto;
  background: var(--white);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  border: 1px solid var(--ink-200);
}
.search-input-wrap {
  flex: 1 1 auto;
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute; left: 14px;
  color: var(--ink-400);
  pointer-events: none;
}
#searchInput {
  flex: 1;
  width: 100%;
  padding: 12px 40px 12px 44px;
  border: 1px solid var(--ink-200);
  border-radius: var(--r-lg);
  background: var(--ink-50);
  color: var(--ink-900);
  font-size: 15px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
#searchInput:focus {
  outline: none;
  border-color: var(--owo-blue);
  background: var(--white);
  box-shadow: 0 0 0 4px rgba(30,64,175,0.1);
}
.clear-btn {
  position: absolute; right: 10px;
  padding: 6px;
  color: var(--ink-400);
  border-radius: 50%;
  transition: background .15s, color .15s;
}
.clear-btn:hover { background: var(--ink-100); color: var(--ink-700); }

.search-meta {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-shrink: 0;
}
.result-count {
  color: var(--ink-500);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}
.result-count strong { color: var(--ink-900); font-weight: 700; }

.sort-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sort-wrap label { color: var(--ink-500); font-size: 14px; }
#sortSelect {
  padding: 8px 12px;
  border: 1px solid var(--ink-200);
  border-radius: var(--r-md);
  background: var(--white);
  color: var(--ink-900);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .15s;
}
#sortSelect:focus { outline: none; border-color: var(--owo-blue); }

/* ============ MAIN LAYOUT ============ */
.main-layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px 60px;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 28px;
}

.filter-toggle { display: none; }

/* ============ SIDEBAR ============ */
.sidebar {
  background: var(--white);
  border-radius: var(--r-xl);
  padding: 20px;
  height: fit-content;
  position: sticky;
  top: 130px;
  max-height: calc(100vh - 160px);
  overflow-y: auto;
  border: 1px solid var(--ink-200);
  box-shadow: var(--shadow-sm);
}
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--ink-100);
  margin-bottom: 12px;
}
.sidebar-header h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink-900);
}
.clear-filters-btn {
  color: var(--owo-blue);
  font-size: 13px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--r-sm);
  transition: background .15s;
}
.clear-filters-btn:hover { background: var(--owo-blue-light); }
.close-filters-btn { display: none; color: var(--ink-500); padding: 4px; }

.filter-section {
  border-bottom: 1px solid var(--ink-100);
  padding: 12px 0;
}
.filter-section:last-child { border-bottom: none; }

.filter-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-900);
  text-align: left;
  transition: color .15s;
}
.filter-heading:hover { color: var(--owo-blue); }
.chevron { transition: transform .2s; color: var(--ink-500); flex-shrink: 0; }
.filter-section.collapsed .chevron { transform: rotate(-90deg); }

.filter-body {
  max-height: 500px;
  overflow: hidden;
  transition: max-height .25s ease;
}
.filter-section.collapsed .filter-body { max-height: 0; }

.filter-search {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--ink-200);
  border-radius: var(--r-sm);
  background: var(--ink-50);
  margin: 8px 0;
  font-size: 13px;
}
.filter-search:focus { outline: none; border-color: var(--owo-blue); background: var(--white); }

.filter-options {
  max-height: 220px;
  overflow-y: auto;
  padding: 4px 0;
}
.filter-options::-webkit-scrollbar { width: 6px; }
.filter-options::-webkit-scrollbar-thumb { background: var(--ink-300); border-radius: 3px; }

.filter-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 4px;
  font-size: 13px;
  color: var(--ink-700);
  cursor: pointer;
  border-radius: var(--r-sm);
  transition: background .15s;
  user-select: none;
}
.filter-option:hover { background: var(--ink-50); }
.filter-option input[type="checkbox"] {
  appearance: none;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--ink-300);
  border-radius: 4px;
  background: var(--white);
  cursor: pointer;
  transition: all .15s;
  position: relative;
  flex-shrink: 0;
}
.filter-option input[type="checkbox"]:checked {
  background: var(--owo-blue);
  border-color: var(--owo-blue);
}
.filter-option input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.filter-option .count {
  margin-left: auto;
  font-size: 11px;
  color: var(--ink-400);
  padding: 2px 6px;
  background: var(--ink-100);
  border-radius: 10px;
}

.price-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
}
.price-inputs span { color: var(--ink-400); }
.price-inputs input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--ink-200);
  border-radius: var(--r-sm);
  background: var(--ink-50);
  font-size: 13px;
}
.price-inputs input:focus { outline: none; border-color: var(--owo-blue); background: var(--white); }

/* ============ RESULTS GRID ============ */
.results { min-width: 0; }
.results-grid { display: flex; flex-direction: column; gap: 14px; }

.card {
  background: var(--white);
  border: 1px solid var(--ink-200);
  border-radius: var(--r-xl);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: transform .2s, box-shadow .2s, border-color .2s;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  position: relative;
  overflow: hidden;
}
.card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(circle at top left, rgba(30,64,175,0.04), transparent 60%);
  opacity: 0;
  transition: opacity .25s;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--owo-blue-light);
}
.card:hover::before { opacity: 1; }

.card-main { display: flex; flex-direction: column; gap: 10px; min-width: 0; }

.card-top {
  display: flex;
  align-items: center;
  gap: 10px;
}
.uni-type-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--ink-500);
  text-transform: uppercase;
}
.can-apply-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: #065F46;
  background: var(--chip-green-bg);
  padding: 3px 10px;
  border-radius: 99px;
}
.can-apply-badge::before {
  content: '';
  width: 6px; height: 6px;
  background: #10B981;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(16,185,129,0.2);
}

.uni-name {
  font-size: 13px;
  color: var(--ink-500);
  font-weight: 500;
  margin: 0;
}

.program-title {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  color: var(--ink-900);
  margin: 0;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.faculty-hint {
  font-size: 12px;
  color: var(--ink-400);
  font-style: italic;
  margin: 0;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: var(--r-sm);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.3;
}
.chip svg { width: 12px; height: 12px; flex-shrink: 0; }
.chip--lang { background: var(--chip-cyan-bg); color: var(--chip-cyan-text); }
.chip--duration { background: var(--chip-orange-bg); color: var(--chip-orange-text); }
.chip--type { background: var(--chip-blue-bg); color: var(--chip-blue-text); }
.chip--degree { background: var(--chip-gray-bg); color: var(--chip-gray-text); }
.chip--city { background: var(--chip-purple-bg); color: var(--chip-purple-text); }

.card-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  min-width: 180px;
  border-left: 1px solid var(--ink-100);
  padding-left: 20px;
}
.price-box { text-align: right; }
.price-original {
  font-size: 13px;
  color: var(--ink-400);
  text-decoration: line-through;
  margin-bottom: 2px;
}
.price-main {
  font-family: var(--font-heading);
  font-size: 26px;
  font-weight: 800;
  color: var(--owo-blue);
  letter-spacing: -0.02em;
  line-height: 1;
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
}
.price-main .currency { font-size: 13px; color: var(--ink-500); font-weight: 600; }
.price-scope {
  display: inline-block;
  margin-top: 6px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  background: var(--owo-blue-light);
  color: var(--owo-blue);
  border-radius: 99px;
}

.apply-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--owo-blue);
  color: var(--white);
  padding: 10px 18px;
  border-radius: var(--r-lg);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  transition: background .15s, transform .15s;
  box-shadow: 0 4px 12px rgba(30,64,175,0.25);
}
.apply-btn:hover { background: var(--owo-blue-hover); transform: translateX(2px); }
.apply-btn svg { transition: transform .15s; }
.apply-btn:hover svg { transform: translateX(2px); }

/* ============ EMPTY / LOADING ============ */
.state-msg {
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-500);
}
.state-msg h3 { font-size: 20px; color: var(--ink-900); margin-bottom: 8px; }
.state-msg p { margin: 0 0 20px; }
.btn-primary {
  background: var(--owo-blue);
  color: var(--white);
  padding: 10px 20px;
  border-radius: var(--r-lg);
  font-size: 14px;
  font-weight: 600;
  transition: background .15s;
}
.btn-primary:hover { background: var(--owo-blue-hover); }

/* ============ PAGINATION ============ */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-top: 32px;
  flex-wrap: wrap;
}
.page-btn {
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--ink-200);
  border-radius: var(--r-md);
  background: var(--white);
  color: var(--ink-700);
  font-weight: 600;
  font-size: 14px;
  transition: all .15s;
}
.page-btn:hover:not(:disabled):not(.active) {
  border-color: var(--owo-blue);
  color: var(--owo-blue);
}
.page-btn.active {
  background: var(--owo-blue);
  color: var(--white);
  border-color: var(--owo-blue);
}
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.page-ellipsis { color: var(--ink-400); padding: 0 4px; }

/* ============ FOOTER ============ */
.footer {
  padding: 30px 20px;
  text-align: center;
  color: var(--ink-500);
  font-size: 13px;
  background: var(--white);
  border-top: 1px solid var(--ink-100);
}
.footer a { color: var(--owo-blue); font-weight: 600; }

/* ============ RESPONSIVE ============ */
@media (max-width: 960px) {
  .main-layout { grid-template-columns: 1fr; gap: 16px; }

  .filter-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: 1px solid var(--ink-200);
    background: var(--white);
    color: var(--ink-900);
    border-radius: var(--r-lg);
    font-weight: 600;
    font-size: 14px;
    box-shadow: var(--shadow-sm);
  }
  .filter-count {
    background: var(--owo-blue);
    color: var(--white);
    font-size: 11px;
    padding: 1px 7px;
    border-radius: 99px;
    font-weight: 700;
  }

  .sidebar {
    position: fixed;
    top: 0; left: 0;
    width: 85%;
    max-width: 340px;
    height: 100dvh;
    max-height: 100dvh;
    z-index: 100;
    border-radius: 0;
    transform: translateX(-100%);
    transition: transform .25s ease;
    overflow-y: auto;
  }
  .sidebar.open { transform: translateX(0); }
  .close-filters-btn { display: block; }
  .filter-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99;
    opacity: 0;
    transition: opacity .2s;
  }
  .filter-backdrop.open { opacity: 1; }

  .search-card {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .search-meta { justify-content: space-between; width: 100%; }
  .search-wrap { margin-top: -40px; padding: 0 12px; }
  .hero { padding: 60px 20px 80px; }
}

@media (max-width: 640px) {
  .card {
    grid-template-columns: 1fr;
    padding: 16px;
  }
  .card-side {
    border-left: none;
    border-top: 1px solid var(--ink-100);
    padding-left: 0;
    padding-top: 14px;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: 100%;
  }
  .price-box { text-align: left; }
  .main-layout { padding: 0 12px 40px; }
  .hero h1 { font-size: 32px; }
  .sort-wrap label { display: none; }
}
