/* FILE: /css/components.css
   Purpose: Reusable UI components (buttons, inputs, toggles, menus, badges, forms, alerts).
   Notes:
   - No page-specific rules here.
   - No layout/grid positioning (that belongs in layout.css).
*/

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  height: var(--input-h);
  padding: 0 var(--s-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  transition: background var(--dur-1) var(--ease),
              border-color var(--dur-1) var(--ease),
              box-shadow var(--dur-1) var(--ease),
              transform var(--dur-1) var(--ease);
}

.btn:hover {
  background: var(--surface-2);
}

.btn:active {
  transform: translateY(1px);
}

.btn--primary {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
}

.btn--primary:hover {
  background: #000;
}

.btn--ghost {
  background: transparent;
  border-color: transparent;
}

.btn--ghost:hover {
  background: var(--surface-2);
}

.btn--sm {
  height: 34px;
  padding: 0 var(--s-3);
  font-size: 12px;
}

/* ========== Icon Buttons ========== */
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text); /* icons inherit from currentColor */
}

.icon-btn:hover {
  background: var(--surface-2);
  border-color: var(--line);
}

.icon-btn:active {
  transform: translateY(1px);
}

/* SVG inside icon buttons */
.icon-btn svg {
  width: 18px;
  height: 18px;
  display: block;
  color: currentColor;
}

/* If SVG uses stroke-based icons, keep them crisp */
.icon-btn svg [stroke] {
  stroke: currentColor;
}

/* ========== Inline Icon Standard ==========
   We use inline SVG in HTML.
   - .icon is a wrapper (span or svg can carry this class)
   - icons should use currentColor in SVG attributes (stroke/fill)
*/
.icon {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  color: currentColor;
}

/* If the SVG itself has .icon class */
svg.icon {
  width: 16px;
  height: 16px;
  display: block;
}

/* If SVG is inside a .icon wrapper */
.icon svg {
  width: 16px;
  height: 16px;
  display: block;
  color: currentColor;
}

/* Optional: make stroke icons consistent */
.icon svg [stroke] {
  stroke: currentColor;
}

/* ========== Badges ========== */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.badge--dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--danger);
  margin-left: -8px;
  margin-top: -8px;
}

/* ========== Avatar / Profile ========== */
.profile-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-1);
  border-radius: 999px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
}

.profile-btn:hover {
  background: var(--surface-2);
  border-color: var(--line);
}

.profile-btn:active {
  transform: translateY(1px);
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--line);
}

/* Chevron icon inside profile button (use inline SVG in HTML) */
.profile-btn__chev {
  display: inline-grid;
  place-items: center;
  width: 14px;
  height: 14px;
  color: rgba(17, 17, 17, 0.72);
}

.profile-btn__chev svg {
  width: 14px;
  height: 14px;
  display: block;
}

/* ========== Menus ========== */
.menu {
  position: absolute;
  min-width: 180px;
  padding: var(--s-2);
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
}

.menu__item {
  width: 100%;
  text-align: left;
  padding: var(--s-2) var(--s-3);
  border-radius: var(--radius-sm);
  background: transparent;
  border: 0;
  font-size: 13px;
}

.menu__item:hover {
  background: var(--surface-2);
}

.menu__sep {
  height: 1px;
  margin: var(--s-2) 0;
  background: var(--line);
}

/* ========== Forms ========== */
.form {
  padding: var(--s-3) var(--s-4) var(--s-4);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.form__row {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
}

.form__row--two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-3);
}

.form__row--actions {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-top: var(--s-2);
}

.label {
  font-size: 12px;
  color: var(--muted);
}

.input,
.select {
  height: var(--input-h);
  padding: 0 var(--s-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 13px;
}

.input:focus,
.select:focus {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 2px rgba(17, 17, 17, 0.08);
}

.select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, rgba(0,0,0,0.5) 50%),
                    linear-gradient(135deg, rgba(0,0,0,0.5) 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% - 2px),
                       calc(100% - 12px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

/* ========== Toggle ========== */
.toggle {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}

.toggle__input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle__label {
  position: relative;
  padding-left: 44px;
  font-size: 13px;
  color: var(--text-2);
}

.toggle__label::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  transition: background var(--dur-1) var(--ease);
}

.toggle__label::after {
  content: "";
  position: absolute;
  left: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  transition: left var(--dur-1) var(--ease);
}

.toggle__input:checked + .toggle__label::before {
  background: var(--accent);
}

.toggle__input:checked + .toggle__label::after {
  left: 18px;
}

/* ========== Fieldset ========== */
.fieldset {
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  padding: var(--s-3);
}

.fieldset__legend {
  font-size: 12px;
  padding: 0 var(--s-2);
  color: var(--muted);
}

/* ========== Alerts & Hints ========== */
.hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.alert {
  font-size: 12px;
  padding: var(--s-2) var(--s-3);
  border-radius: var(--radius-sm);
}

.alert--warning {
  background: rgba(181, 71, 8, 0.08);
  color: var(--warning);
}

/* ========== Modal (structure only) ========== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: grid;
  place-items: center;
  z-index: 100;
}

.modal__panel {
  width: min(480px, 92vw);
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--line);
}

.modal__title {
  font-size: 14px;
  font-weight: 650;
}

.modal__body {
  padding: var(--s-4);
}

[hidden] { display: none !important; }

/* ========== Tıklanamıyor hissi ========== */
.task-row { cursor: pointer; }
.task-row button { cursor: pointer; }

/* ========== Accessibility / Focus states ========== */
.btn:focus-visible,
.icon-btn:focus-visible,
.profile-btn:focus-visible,
.menu__item:focus-visible,
.input:focus-visible,
.select:focus-visible {
  outline: 2px solid rgba(17, 17, 17, 0.22);
  outline-offset: 2px;
}

/* ========== Menus: stacking fix ========== */
/* Menü bazen modal/clock üstünde/altında garip kalabilir; garanti edelim */
.menu {
  z-index: 120; /* modal 100, menü 120 -> profil menüsü her zaman görünür */
}

/* ========== Modal: scroll & sizing polish ========== */
.modal__panel {
  max-height: min(720px, 86vh);
  overflow: hidden; /* header sabit, body scroll */
}

/* Header sabit kalırken içerik scroll alsın */
.modal__body {
  max-height: calc(min(720px, 86vh) - 64px); /* header yaklaşık yüksekliği */
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

/* Modal açıkken body scroll kilidi (UI.js body'e class eklerse hazır) */
body.is-modal-open {
  overflow: hidden;
}

/* ========== Modal action row: compact layout on small screens ========== */
@media (max-width: 560px) {
  .form__row--two {
    grid-template-columns: 1fr;
  }

  .form__row--actions {
    flex-direction: column;
    align-items: stretch;
  }

  .form__row--actions .btn,
  .form__row--actions .btn--ghost {
    width: 100%;
  }
}

/* ========== Task row click UX: button click feels separated ========== */
.task-row button {
  pointer-events: auto;
}

.task-row:active {
  transform: translateY(1px);
}

/* Hover highlight (optional, but improves “clickable” clarity) */
.task-row:hover {
  background: rgba(17, 17, 17, 0.03);
}

/* ========== My Page (Modal content components) ========== */
.mp {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}

.mp__header {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}

.mp__avatar {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--line);
}

.mp__title { min-width: 0; }

.mp__name {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.mp__meta {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  margin-top: 2px;
  min-width: 0;
}

.mp__sep {
  color: var(--muted);
}

.mp__sub {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mp__chip {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 var(--s-2);
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 12px;
  color: var(--text-2);
}

.mp__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-3);
}

.mp-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: var(--s-3);
}

.mp-card__label {
  font-size: 12px;
  color: var(--muted);
}

.mp-card__value {
  margin-top: 4px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.mp__section {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.mp__section-title {
  font-size: 13px;
  font-weight: 650;
}

.mp__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}

.mp-list {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
}

.mp-list__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-top: 1px solid var(--line);
}

.mp-list__row:first-child { border-top: 0; }

.mp-list__left {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mp-list__title {
  font-size: 13px;
  font-weight: 650;
}

.mp-list__sub {
  font-size: 12px;
  color: var(--muted);
}

.mp-list__right {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
}

/* Mobile: stack cards nicely */
@media (max-width: 560px) {
  .mp__grid { grid-template-columns: 1fr; }
  .mp-list__row { align-items: flex-start; }
  .mp-list__right { flex-wrap: wrap; justify-content: flex-end; }
}

.search-scope{
  display:flex;
  gap:10px;
  align-items:center;
  margin:10px 0 6px 0;
}

.search-scope__opt{
  display:flex;
  gap:8px;
  align-items:center;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid rgba(0,0,0,0.10);
  background:rgba(255,255,255,0.70);
  font-size:12px;
  cursor:pointer;
  user-select:none;
}

.search-scope__opt input{
  margin:0;
}
