@import "tokens.css";

/* ==========================================================================
   portal.css — Uniplaner Home / Landing Portal
   Projekt: Redesign wg PROMPT.md (ekrany 01-06)
   ========================================================================== */

/* ---------- Reset & Baza ---------- */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background-color: var(--app-bg);
  color: var(--app-text);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Wymuszenie tła motywu w dark/light */
body {
  position: relative;
  overflow-x: hidden;
}

/* Tło z motywami ikon / siatką */
.portal-bg-pattern {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

/* ---------- Główny Kontener ---------- */
.portal-container {
  position: relative;
  z-index: 1;
  max-width: 720px;
  width: 100%;
  min-height: 100vh;
  margin: 0 auto;
  box-sizing: border-box;
  padding: 32px 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

@media (max-width: 640px) {
  html body .portal-container {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 16px 16px 24px;
    gap: 16px;
    box-sizing: border-box;
  }
}

/* ---------- Nagłówek ---------- */
.portal-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

@media (max-width: 640px) {
  .portal-header {
    gap: 10px;
  }
}

.logo-tile {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 20%;
  overflow: hidden;
  background: transparent;
  border: 1px solid var(--app-card-border);
  flex: none;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 640px) {
  .logo-tile {
    width: 44px;
    height: 44px;
  }
}

.portal-logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 20%;
  display: block;
}

.header-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.portal-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 30px;
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-optical-sizing: auto;
  font-variation-settings: 'opsz' 96, 'wdth' 90;
  color: var(--app-text);
}

@media (max-width: 640px) {
  .portal-title {
    font-size: 24px;
  }
}

.portal-tagline {
  margin: 0;
  font-size: var(--fs-small);
  line-height: 1.35;
  color: var(--app-text-muted);
}

@media (max-width: 480px) {
  .portal-tagline {
    font-size: 13px;
  }
}

/* ---------- Przełącznik motywu (3-stanowy) ---------- */
.header-actions {
  flex: none;
  position: relative;
}

/* Desktop: Segmented Control */
.theme-segmented-control {
  display: inline-flex;
  align-items: center;
  background: var(--app-field-bg);
  border: 1.5px solid var(--app-border);
  border-radius: var(--r-btn);
  padding: 3px;
  gap: 3px;
  height: 44px;
  box-sizing: border-box;
}

.theme-segment-btn {
  height: 34px;
  padding: 0 12px;
  border: none;
  background: transparent;
  color: var(--app-text-muted);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.theme-segment-btn:hover {
  color: var(--app-text);
}

.theme-segment-btn[aria-checked="true"],
.theme-segment-btn.is-active {
  background: var(--app-surface);
  color: var(--app-text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.theme-segment-btn:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
}

/* Mobile: Dropdown Control */
.theme-dropdown-control {
  display: none;
  position: relative;
}

.theme-dropdown-btn {
  height: 44px;
  min-width: 44px;
  padding: 0 10px;
  border-radius: var(--r-btn);
  border: 1.5px solid var(--app-border);
  background: var(--app-surface);
  color: var(--app-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  box-sizing: border-box;
}

.theme-dropdown-btn:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
}

.theme-menu-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 140px;
  background: var(--app-surface);
  border: 1.5px solid var(--app-card-border);
  border-radius: var(--r-btn);
  box-shadow: var(--app-shadow);
  padding: 4px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.theme-menu-dropdown[hidden] {
  display: none !important;
}

.theme-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 12px;
  border: none;
  background: transparent;
  color: var(--app-text);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  width: 100%;
  text-align: left;
}

.theme-dropdown-item:hover {
  background: var(--app-field-bg);
}

.theme-dropdown-item[aria-checked="true"],
.theme-dropdown-item.is-active {
  background: rgba(232, 112, 26, 0.14);
  color: var(--app-accent-ink);
  font-weight: 600;
}

.theme-dropdown-item:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
}

@media (max-width: 640px) {
  .theme-segmented-control {
    display: none !important;
  }
  .theme-dropdown-control {
    display: block !important;
  }
}

/* ---------- Ostatnio przeglądany plan ---------- */
.last-visited-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-radius: 14px;
  background: var(--app-last-visited-bg);
  box-sizing: border-box;
  margin-bottom: var(--sp-4, 16px);
}

.last-visited-card[hidden] {
  display: none !important;
}

.last-visited-content {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}

.last-visited-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--app-last-visited-label);
}

.last-visited-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 17px;
  line-height: 1.25;
  color: var(--app-text);
}

.btn-fast-forward {
  height: 44px;
  padding: 0 18px;
  border-radius: var(--r-btn);
  border: none;
  background: var(--app-accent);
  color: var(--app-accent-text);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  text-decoration: none;
  flex: none;
  box-sizing: border-box;
  transition: opacity 0.15s ease, transform 0.1s ease;
}

.btn-fast-forward:hover {
  opacity: 0.94;
}

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

.btn-fast-forward:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
}

@media (max-width: 640px) {
  .last-visited-card {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 14px;
  }
  .btn-fast-forward {
    height: 46px;
    justify-content: center;
    width: 100%;
  }
}

/* ---------- Główna karta wyboru ---------- */
.portal-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px 26px 26px;
  border-radius: 16px;
  background: var(--app-surface);
  border: 1.5px solid var(--app-card-border);
  box-shadow: var(--app-shadow);
  box-sizing: border-box;
}

@media (max-width: 640px) {
  .portal-card {
    padding: 18px 16px 20px;
    gap: 12px;
  }
}

.step-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.step-label {
  display: block;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  color: var(--app-text);
}

/* ---------- Pole Select / Combobox ---------- */
.combobox-container {
  position: relative;
  width: 100%;
}

.combobox-field {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 52px;
  padding: 0 16px;
  border-radius: var(--r-field);
  background: var(--app-field-bg);
  border-bottom: 2px solid var(--app-field-line);
  box-sizing: border-box;
  transition: border-bottom-color 0.15s ease, outline 0.15s ease;
}

.combobox-field:hover {
  border-bottom-color: var(--app-text);
}

.combobox-field:focus-within {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
  border-bottom-color: var(--app-accent);
}

.combobox-field.combobox-field.has-error {
  border-bottom-color: #DC2626;
  outline: 2px solid #DC2626;
  outline-offset: 2px;
}

.combobox-icon {
  display: flex;
  align-items: center;
  color: var(--app-text-muted);
  flex: none;
}

.combobox-input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--app-text);
  padding: 0;
}

.combobox-input::placeholder {
  color: var(--app-text-muted);
  opacity: 0.85;
}

.combobox-arrow-btn {
  background: transparent;
  border: none;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--app-text-muted);
  cursor: pointer;
  border-radius: 4px;
  transition: color 0.15s ease;
}

.combobox-arrow-btn:hover {
  color: var(--app-text);
}

.combobox-arrow-btn:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
}

/* ---------- Lista rozwijana uczelni (05) ---------- */
.combobox-listbox {
  position: absolute;
  left: 0;
  right: 0;
  top: 58px;
  z-index: 50;
  border-radius: 8px;
  background: var(--app-surface);
  border: 1.5px solid var(--app-card-border);
  box-shadow: var(--app-shadow);
  overflow: hidden;
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 280px;
  overflow-y: auto;
}

.combobox-listbox[hidden] {
  display: none !important;
}

.combobox-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 52px;
  padding: 8px 18px;
  border-bottom: 1px solid var(--app-border);
  font-size: 15px;
  font-weight: 500;
  color: var(--app-text);
  cursor: pointer;
  box-sizing: border-box;
  transition: background 0.1s ease;
}

.combobox-option:last-child {
  border-bottom: none;
}

.combobox-option:hover,
.combobox-option.is-active,
.combobox-option[aria-selected="true"] {
  background: rgba(232, 112, 26, 0.14);
  font-weight: 600;
}

.combobox-option .option-primary {
  flex: 1;
  min-width: 0;
}

.combobox-option .option-secondary {
  font-size: 13px;
  font-weight: 400;
  color: var(--app-text-muted);
  flex: none;
}

.combobox-empty {
  padding: 16px 18px;
  text-align: center;
  font-size: 14px;
  color: var(--app-text-muted);
}

/* ---------- Stan błędu pobierania uczelni ---------- */
.portal-error-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  margin-top: 10px;
  border-radius: 8px;
  background: rgba(220, 38, 38, 0.1);
  border: 1.5px solid rgba(220, 38, 38, 0.35);
  color: var(--app-text);
  font-size: 14px;
  box-sizing: border-box;
}

.portal-error-card[hidden] {
  display: none !important;
}

.portal-error-card .error-content {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.portal-error-card .error-icon {
  flex: none;
  color: #DC2626;
}

.btn-retry {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border: 1.5px solid #DC2626;
  border-radius: var(--r-btn);
  background: var(--app-surface);
  color: var(--app-text);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex: none;
  transition: all 0.15s ease;
}

.btn-retry:hover {
  background: rgba(220, 38, 38, 0.15);
}

.btn-retry:active {
  transform: scale(0.97);
}

.btn-retry:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
}

/* ---------- Pusty stan wydziałów / Popularne uczelnie ---------- */
.faculty-empty-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 6px 0 4px;
}

.placeholder-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 17px;
  color: var(--app-text);
}

.wavy-accent-line {
  margin-top: -6px;
  display: block;
}

.placeholder-hint {
  margin: 0;
  font-size: 14px;
  color: var(--app-text-muted);
}

.quick-chips-wrapper {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 4px;
}

.chip-btn {
  height: 42px;
  padding: 0 18px;
  border-radius: var(--r-pill);
  border: 1.5px solid var(--app-border);
  background: transparent;
  color: var(--app-text);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip-btn:hover {
  border-color: var(--app-text);
  background: var(--app-field-bg);
}

.chip-btn:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
}

/* ---------- Lista i karta wydziału (06) ---------- */
.faculty-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.faculty-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--r-card);
  background: var(--app-field-bg);
  border: 1px solid var(--app-border);
  cursor: pointer;
  box-sizing: border-box;
  transition: all 0.15s ease;
}

.faculty-card:hover {
  border-color: var(--app-text);
}

.faculty-card[aria-checked="true"] {
  border: 2px solid var(--app-accent);
}

.faculty-card:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
}

.faculty-logo-box {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: rgba(232, 112, 26, 0.14);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  overflow: hidden;
}

.faculty-logo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 20%;
}

.faculty-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.faculty-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  line-height: 1.25;
  color: var(--app-text);
}

.faculty-meta {
  font-size: 13px;
  color: var(--app-text-muted);
}

.faculty-radio {
  width: 20px;
  height: 20px;
  accent-color: var(--app-accent);
  margin: 0;
  flex: none;
  cursor: pointer;
}

.faculty-prompt-text {
  margin: 0 0 4px 0;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--app-text);
}

/* ---------- Przycisk Akcji CTA ---------- */
.form-step-action {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.action-helper {
  display: none !important;
}

.btn-launch {
  height: 48px;
  border-radius: var(--r-btn);
  border: none;
  background: var(--app-accent);
  color: var(--app-accent-text);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  text-decoration: none;
  box-sizing: border-box;
  transition: all 0.15s ease;
}

.btn-launch:hover:not(.is-disabled) {
  opacity: 0.94;
}

.btn-launch:active:not(.is-disabled) {
  transform: scale(0.99);
}

.btn-launch.is-disabled,
.btn-launch[aria-disabled="true"] {
  background: var(--app-border);
  color: var(--app-text-muted);
  cursor: not-allowed;
  pointer-events: none;
}

.btn-launch:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
}

/* ---------- Sekcja Społecznościowa (Wtyczki) ---------- */
.portal-community-card {
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 4px 0;
  box-sizing: border-box;
}

.community-badge {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--app-accent-ink);
}

.community-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 19px;
  color: var(--app-text);
}

.community-desc {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--app-text-muted);
  max-width: 620px;
}

.community-actions {
  display: flex;
  margin-top: 4px;
}

.btn-community {
  height: 42px;
  padding: 0 16px;
  border-radius: var(--r-btn);
  border: 1.5px solid var(--app-border);
  background: var(--app-surface);
  color: var(--app-text);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  box-sizing: border-box;
  transition: all 0.15s ease;
}

.btn-community:hover {
  border-color: var(--app-text);
  background: var(--app-field-bg);
}

.btn-community:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
}

/* ---------- Stopka ---------- */
.portal-footer {
  margin-top: auto;
  text-align: center;
  font-size: 13px;
  color: var(--app-text-muted);
  padding-top: 8px;
}

.portal-footer p {
  margin: 0;
}

/* Pomocnicze dla dostępności */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}
