/* ============================================================
   UI component library
   Extracted from app.css — components loadable globally:
     .btn, .card, .sidebar-overlay,
     toast region/stack/items,
     flatpickr calendar overrides
   ============================================================ */

/* ============================================================
   Button component  (components/button/button.html)
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: var(--radius-btn);
  transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
  white-space: nowrap;
  text-decoration: none;
  -webkit-user-select: none;
  user-select: none;
}

.btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ── Sizes ── */
.btn--sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn--md { height: 40px; padding: 0 18px; font-size: 14px; }
.btn--lg { height: 48px; padding: 0 24px; font-size: 15px; }

/* ── Variants ── */
.btn--primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.btn--primary:hover:not(:disabled) {
  background: #2450cc;
  border-color: #2450cc;
}

.btn--secondary {
  background: var(--color-card);
  color: var(--color-text);
  border-color: var(--color-border);
}
.btn--secondary:hover:not(:disabled) {
  background: var(--color-hover-bg);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.btn--danger {
  background: #DC2626;
  color: #fff;
  border-color: #DC2626;
}
.btn--danger:hover:not(:disabled) {
  background: #b91c1c;
  border-color: #b91c1c;
}

/* ── Icon button ── */
.btn--icon {
  padding: 0;
}

/* ── Disabled / Loading ── */
.btn:disabled,
.btn--loading {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ── Spinner ── */
.btn__spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
  flex-shrink: 0;
}

.btn--secondary .btn__spinner,
.btn--danger .btn__spinner {
  border-color: rgba(0, 0, 0, 0.15);
  border-top-color: currentColor;
}

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

/* ============================================================
   Card
   ============================================================ */
.card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: 24px;
}

/* ============================================================
   Sidebar overlay (mobile)
   ============================================================ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 199;
}

.sidebar-overlay.is-visible { display: block; }

/* ============================================================
   Flatpickr overrides
   ============================================================ */
@media (max-width: 380px) {
  .flatpickr-calendar {
    width: calc(100vw - 16px) !important;
  }

  .flatpickr-days,
  .dayContainer {
    width: 100% !important;
    min-width: unset !important;
    max-width: unset !important;
  }

  .flatpickr-day {
    max-width: unset;
  }
}

/* ============================================================
   Toasts  (components/toast/toast_container.html)
   ============================================================ */
.toast-region {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1400;
  pointer-events: none;
}

.toast-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(480px, calc(100vw - 40px));
}

.toast {
  display: flex;
  align-items: center;
  gap: 14px;
  pointer-events: auto;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  padding: 18px 16px 18px 20px;
  min-height: 64px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.14), 0 2px 6px rgba(15, 23, 42, 0.06);
  transform: translateY(10px);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  position: relative;
  overflow: hidden;
}

/* Colored left accent bar */
.toast::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  border-radius: 12px 0 0 12px;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.is-leaving {
  opacity: 0;
  transform: translateY(8px);
}

.toast--success::before { background: #10B981; }
.toast--error::before   { background: #DC2626; }

.toast__icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast--success .toast__icon { color: #10B981; }
.toast--error   .toast__icon { color: #DC2626; }

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

.toast__title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--color-text);
}

.toast__message {
  font-size: 14px;
  line-height: 1.5;
  color: var(--color-text-muted);
}

.toast__message:only-child {
  color: var(--color-text);
  font-weight: 500;
}

.toast__close {
  flex-shrink: 0;
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text-muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}

.toast__close svg {
  width: 13px;
  height: 13px;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
}

.toast__close:hover {
  background: var(--color-hover-bg);
  color: var(--color-text);
  border-color: color-mix(in srgb, var(--color-border) 60%, var(--color-text) 40%);
}

.toast__close:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ── Responsive ── */
@media (max-width: 639px) {
  .toast-region {
    right: 12px;
    left: 12px;
    bottom: 16px;
  }

  .toast-stack {
    max-width: none;
  }
}

