/* ─────────────────────────────────────────────────────────────
   Pazaryerlerin UI System v2 — Premium Components
   Toast / Skeleton / Empty / Modal / Print / a11y
   ───────────────────────────────────────────────────────────── */

/* ═══════════════════════════════════════════════════════════════
   1. TOAST NOTIFICATION SYSTEM
   ─────────────────────────────────────────────────────────────── */

.ks-toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: 380px;
  width: calc(100% - 48px);
}

.ks-toast {
  pointer-events: auto;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-left-width: 4px;
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 14px 40px rgba(15, 15, 15, 0.10), 0 2px 8px rgba(15, 15, 15, 0.04);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  animation: ks-toast-in 320ms cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.ks-toast--success { border-left-color: #10b981; }
.ks-toast--error   { border-left-color: #dc2626; }
.ks-toast--warning { border-left-color: #f59e0b; }
.ks-toast--info    { border-left-color: #0066ff; }

.ks-toast--exiting {
  animation: ks-toast-out 240ms cubic-bezier(0.4, 0, 1, 1) forwards;
}

.ks-toast__icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}
.ks-toast--success .ks-toast__icon { color: #10b981; }
.ks-toast--error .ks-toast__icon   { color: #dc2626; }
.ks-toast--warning .ks-toast__icon { color: #f59e0b; }
.ks-toast--info .ks-toast__icon    { color: #0066ff; }

.ks-toast__body {
  flex: 1;
  min-width: 0;
}

.ks-toast__title {
  font-size: 14px;
  font-weight: 600;
  color: #0a0a0a;
  letter-spacing: -0.01em;
  margin: 0 0 2px;
  line-height: 1.4;
}

.ks-toast__msg {
  font-size: 13px;
  color: #525252;
  line-height: 1.5;
  margin: 0;
}

.ks-toast__close {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  color: #a1a1aa;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  transition: background 160ms ease, color 160ms ease;
  margin-top: -2px;
}
.ks-toast__close:hover {
  background: #f4f4f5;
  color: #0a0a0a;
}

.ks-toast__progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  background: currentColor;
  opacity: 0.3;
  animation: ks-toast-progress linear forwards;
}
.ks-toast--success .ks-toast__progress { background: #10b981; }
.ks-toast--error .ks-toast__progress   { background: #dc2626; }
.ks-toast--warning .ks-toast__progress { background: #f59e0b; }
.ks-toast--info .ks-toast__progress    { background: #0066ff; }

@keyframes ks-toast-in {
  from { transform: translateX(420px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
@keyframes ks-toast-out {
  from { transform: translateX(0); opacity: 1; }
  to   { transform: translateX(420px); opacity: 0; max-height: 0; padding: 0; margin: 0; }
}
@keyframes ks-toast-progress {
  from { width: 100%; }
  to   { width: 0%; }
}

/* ═══════════════════════════════════════════════════════════════
   2. SKELETON LOADER
   ─────────────────────────────────────────────────────────────── */

.ks-skeleton {
  display: block;
  background: linear-gradient(90deg, #f4f4f5 25%, #ebebed 50%, #f4f4f5 75%);
  background-size: 200% 100%;
  animation: ks-skeleton-shimmer 1.6s linear infinite;
  border-radius: 6px;
  height: 14px;
  width: 100%;
}
.ks-skeleton--circle { border-radius: 50%; }
.ks-skeleton--text { height: 12px; margin-bottom: 8px; }
.ks-skeleton--text-lg { height: 18px; margin-bottom: 10px; }
.ks-skeleton--card { height: 120px; border-radius: 14px; }
.ks-skeleton--btn { height: 38px; width: 120px; border-radius: 8px; }
.ks-skeleton--row { height: 56px; border-radius: 8px; margin-bottom: 8px; }

@keyframes ks-skeleton-shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* ═══════════════════════════════════════════════════════════════
   3. EMPTY STATE
   ─────────────────────────────────────────────────────────────── */

.ks-empty {
  text-align: center;
  padding: clamp(40px, 6vw, 80px) 24px;
  background: #fafafa;
  border: 2px dashed #e5e7eb;
  border-radius: 16px;
  max-width: 520px;
  margin: 0 auto;
}

.ks-empty__icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
  background: #f4f4f5;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: #71717a;
}

.ks-empty__title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: #0a0a0a;
  margin: 0 0 8px;
  font-family: 'Inter', system-ui, sans-serif;
}

.ks-empty__sub {
  font-size: 14px;
  color: #525252;
  line-height: 1.6;
  margin: 0 0 24px;
  max-width: 380px;
  margin-left: auto;
  margin-right: auto;
}

.ks-empty__cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  background: #0a0a0a;
  color: #fff;
  border-radius: 10px;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
  transition: all 200ms cubic-bezier(0.16, 1, 0.3, 1);
  border: none;
  cursor: pointer;
}
.ks-empty__cta:hover {
  background: #2a2a2c;
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  color: #fff;
}
.ks-empty__cta--primary {
  background: linear-gradient(135deg, #0066ff, #0052cc);
  box-shadow: 0 8px 24px rgba(0, 102, 255, 0.3);
}
.ks-empty__cta--primary:hover {
  box-shadow: 0 12px 32px rgba(0, 102, 255, 0.45);
}

.ks-empty__hint {
  margin-top: 16px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  color: #71717a;
  letter-spacing: 0.06em;
}

/* ═══════════════════════════════════════════════════════════════
   4. MODAL (animated, accessible)
   ─────────────────────────────────────────────────────────────── */

dialog.ks-modal {
  border: none;
  border-radius: 18px;
  padding: 0;
  background: #fff;
  max-width: min(90vw, 600px);
  width: 100%;
  box-shadow: 0 30px 80px rgba(15, 15, 15, 0.18);
}
dialog.ks-modal[open] {
  animation: ks-modal-in 280ms cubic-bezier(0.16, 1, 0.3, 1);
}
dialog.ks-modal::backdrop {
  background: rgba(10, 10, 11, 0.45);
  backdrop-filter: blur(2px);
  animation: ks-backdrop-in 240ms ease-out;
}
.ks-modal__head {
  padding: 20px 24px;
  border-bottom: 1px solid #f4f4f5;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ks-modal__title { font-size: 18px; font-weight: 700; color: #0a0a0a; margin: 0; letter-spacing: -0.02em; }
.ks-modal__close {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: #71717a;
  font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  transition: background 160ms ease;
}
.ks-modal__close:hover { background: #f4f4f5; color: #0a0a0a; }
.ks-modal__body { padding: 24px; }
.ks-modal__foot {
  padding: 16px 24px;
  border-top: 1px solid #f4f4f5;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

@keyframes ks-modal-in {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes ks-backdrop-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@media (max-width: 600px) {
  dialog.ks-modal {
    margin: 0 auto auto;
    max-width: 100%;
    max-height: 90vh;
    border-radius: 16px 16px 0 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    overflow-y: auto;
  }
  dialog.ks-modal[open] {
    animation: ks-modal-sheet-in 320ms cubic-bezier(0.16, 1, 0.3, 1);
  }
  @keyframes ks-modal-sheet-in {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }
}

/* ═══════════════════════════════════════════════════════════════
   5. SKIP-TO-CONTENT (a11y)
   ─────────────────────────────────────────────────────────────── */

.ks-skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 99999;
  background: #0a0a0a;
  color: #fff;
  padding: 12px 18px;
  border-radius: 0 0 8px 0;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
  letter-spacing: 0.02em;
}
.ks-skip-link:focus {
  left: 0;
  outline: 2px solid #0066ff;
  outline-offset: 2px;
}

/* Visually hidden but available for screen readers */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ═══════════════════════════════════════════════════════════════
   6. STICKY TABLE HEADERS + ROW HOVER
   ─────────────────────────────────────────────────────────────── */

.ks-table-sticky thead th {
  position: sticky;
  top: 0;
  background: #fafafa;
  z-index: 5;
  box-shadow: 0 1px 0 #e5e7eb;
}
.ks-table-sticky tbody tr {
  transition: background-color 140ms ease;
}
.ks-table-sticky tbody tr:hover {
  background: rgba(0, 102, 255, 0.03);
}

/* ═══════════════════════════════════════════════════════════════
   7. FORM ENHANCEMENTS (required, error, focus)
   ─────────────────────────────────────────────────────────────── */

label.ks-required::after {
  content: " *";
  color: #dc2626;
  font-weight: 700;
}

.ks-input--error,
input[aria-invalid="true"],
textarea[aria-invalid="true"],
select[aria-invalid="true"] {
  border-color: #dc2626 !important;
  background: #fef2f2;
}
.ks-input--error:focus,
input[aria-invalid="true"]:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15);
}

.ks-error-text {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: #dc2626;
  font-weight: 500;
}
.ks-error-text::before {
  content: "⚠ ";
  font-weight: 600;
}

.ks-help-text {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: #71717a;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.04em;
}

/* ═══════════════════════════════════════════════════════════════
   8. PRINT STYLESHEET
   ─────────────────────────────────────────────────────────────── */

@media print {
  body {
    background: #fff !important;
    color: #000 !important;
    font-family: Georgia, 'Times New Roman', serif !important;
  }

  /* Hide chrome */
  .ks-sidebar, .ks-topbar, .ks-mobile-tabbar,
  .ks-toast-container, .ks-skip-link,
  nav, footer, button, .ks-btn,
  [data-no-print] {
    display: none !important;
  }

  .ks-app__viewport, .ks-app__main {
    margin-left: 0 !important;
    padding: 0 !important;
  }

  /* Tables */
  table {
    page-break-inside: auto;
    width: 100%;
    border-collapse: collapse;
  }
  thead { display: table-header-group; }
  tr { page-break-inside: avoid; page-break-after: auto; }
  th, td { border: 1px solid #ccc; padding: 8px; }

  /* Color-independent indicators */
  .dv4-profit::before, .ks-table__num--profit::before { content: "↑ "; font-weight: bold; }
  .dv4-loss::before, .ks-table__num--loss::before { content: "↓ "; font-weight: bold; }

  /* Headings */
  h1, h2, h3 { font-family: Georgia, serif !important; page-break-after: avoid; }
  h1 { font-size: 22pt; }
  h2 { font-size: 18pt; }

  /* Page break helpers */
  .ks-page-break { page-break-before: always; }
  .ks-page-break-avoid { page-break-inside: avoid; }

  /* Links — show URL */
  a[href]:after {
    content: " (" attr(href) ")";
    font-size: 9pt;
    color: #555;
  }
  a[href^="#"]:after, a[href^="javascript:"]:after { content: ""; }
}

/* ═══════════════════════════════════════════════════════════════
   9. REDUCED MOTION
   ─────────────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .ks-skeleton { animation: none; opacity: 0.6; }
}
