/* BrokerTrack UI primitives (shared across auth + app pages)
   - Keep page-specific visuals in their own css files.
   - This file provides consistent base components: buttons, fields, inputs, alerts, etc.
*/

/* ===== Page Shell ===== */
.bt-pages {
  padding: var(--bt-padding3);
}

.bt-pages .bt-card {
  max-width: 100%;
  margin: 0 auto;
  background: var(--bt-surface);
  border: 1px solid var(--bt-line);
  border-radius: 16px;
  padding: var(--bt-padding);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.06);
}

.bt-pages__head {
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.bt-pages__title {
  font-size: var(--bt-h2);
  font-weight: 700;
  padding-left: 12px;
}

.bt-pages__title2 {
  font-size: var(--bt-h3);
  font-weight: 500;
  padding-left: 12px;
}

.bt-pages__section-title {
  margin: 0 0 0.75rem;
  font-size: var(--bt-h4);
  font-weight: 600;
}

/* ===== Form fields ===== */
.bt-field {
  margin: 14px 0;
  min-width: 0;
}

.bt-field__short {
  width: 35%;
}

.bt-field__short-fix {
  width: 15%;
}

.bt-label {
  display: block;
  font-size: var(--bt-p);
  font-weight: 400;
  color: var(--bt-muted);
  margin-bottom: 6px;
}

.bt-pages .bt-field label {
  color: var(--bt-label);
  font-size: var(--bt-p);
}

.bt-input {
  width: 100%;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--bt-input-border, var(--bt-line, var(--bt-border)));
  padding: 0 12px;
  outline: none;
  background: var(--bt-input-bg, var(--bt-surface));
  transition: 0.15s ease;
}

.bt-pages .bt-field input,
.bt-pages .bt-field select,
.bt-pages .bt-field textarea {
  font-family: var(--bt-font);
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid #d7dbe7;
  border-radius: 12px;
  font-size: var(--bt-p2);
  font-weight: 400;
}

.bt-input:focus {
  border-color: var(--bt-accent, var(--bt-primary));
  box-shadow: var(
    --bt-input-shadow,
    0 0 0 4px var(--bt-accent-soft, rgba(91, 108, 255, 0.16))
  );
}

.bt-pages .bt-field textarea {
  min-height: 60px;
  resize: vertical;
}

/* Checkbox line */
.bt-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: var(--bt-p2);
  font-weight: 400;
  color: var(--bt-muted);
}
.bt-link {
  font-size: var(--bt-p2);
  font-weight: 400;
  color: var(--bt-primary);
  text-decoration: none;
}
.bt-link:hover {
  text-decoration: underline;
}

/* ===== Readonly & Stat ===== */
.bt-readonly {
  width: 100%;
  min-height: 42px;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid #d7dbe7;
  border-radius: 12px;
  background: #f8fafc;
  color: #0f172a;
  font-size: var(--bt-p2);
  display: flex;
  align-items: center;
}

.bt-readonly--textarea {
  min-height: 72px;
  display: block;
  white-space: normal;
  line-height: 1.5;
}

.bt-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.bt-stats-grid-5 {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

.bt-stat {
  border: 1px solid var(--bt-line);
  border-radius: 14px;
  padding: 14px;
  background: var(--bt-surface-2, #f8fafc);
}

.bt-stat strong {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: #64748b;
}

.bt-stat span {
  display: block;
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
}

/* ===== Table Fields ===== */
.bt-pages__tablewrap {
  width: 100%;
  border: 1px solid var(--bt-line);
  border-radius: 14px;
  overflow: hidden;
}

.bt-pages__table-scroller {
  width: 100%;
  overflow-x: auto;
  overflow-y: visible;
}

.bt-pages__table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  min-width: 680px;
  position: relative;
}

.bt-pages__table th,
.bt-pages__table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--bt-line);
  text-align: left;
  vertical-align: middle;
  font-size: 14px;
}

.bt-pages__table th {
  background: #f3f4f6;
  color: #111827;
  font-weight: 700;
  font-size: 13px;
}

/* İçeriği kadar yer kaplayan dar sütunlar */
.bt-col-fit,
.bt-cell-fit {
  width: 1%;
  white-space: nowrap;
}

.bt-col-actions,
.bt-cell-actions {
  width: 1%;
  white-space: nowrap;
}

/* Aksiyon içeriği tek satır kalsın */
.bt-cell-actions,
.bt-cell-fit {
  vertical-align: middle;
}

.bt-actions-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.bt-actions-inline form,
.bt-actions-inline a,
.bt-actions-inline button {
  margin: 0;
}

.bt-actions-inline form {
  display: inline-flex;
}

/* İçerik uzunsa geri kalan sütunlar daralsın ama fit sütunlar büyümesin */
.bt-pages__table th,
.bt-pages__table td {
  min-width: 0;
}

/* Uzun metinler gerektiğinde kırılabilsin */
.bt-pages__table td {
  overflow-wrap: anywhere;
}

/* Ama dar aksiyon sütunları kırılmasın */
.bt-cell-actions,
.bt-cell-fit,
.bt-cell-actions *,
.bt-cell-fit * {
  overflow-wrap: normal;
}

/* Sadece içerik kaydır, thead sabit kalsın */
.bt-pages__max-height {
  max-height: 30rem;
  overflow: auto;
}

.bt-pages__max-height .bt-pages__table {
  border-collapse: separate;
  border-spacing: 0;
}

.bt-pages__max-height .bt-pages__table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f8fafc;
  box-shadow: 0 1px 0 var(--bt-line);
}
/* İçerik tablosu: bitiş */

/* Detail Action */
.bt-detail-actions {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding-left: 1rem;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.bt-detail-actions form {
  margin: 0;
  display: inline-flex;
}

.bt-cell-actions {
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
}

.bt-table-actions {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.bt-table-actions form {
  margin: 0;
  display: inline-flex;
}

.bt-table-actions .button {
  line-height: normal;
}

/* ===== Table Fields Bitiş ===== */

/* ===== Buttons ===== */
.bt-btn,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid;
  cursor: pointer;
  transition: 0.15s ease;
  text-decoration: none;
}

.bt-btn:hover,
.button:hover {
  filter: brightness(0.98);
  transform: translateY(-1px);
}

.bt-btn:disabled,
.bt-btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.bt-detail-actions .bt-btn,
.bt-detail-actions .button {
  width: 88px;
  min-width: 88px;
  height: 32px;
  padding: 0 10px;
  margin: 0;
  border-radius: 10px;
  font-size: var(--bt-p2);
  line-height: 34px;
}

.bt-table-actions .bt-btn,
.bt-table-actions .button {
  width: 77px;
  min-width: 77px;
  height: 24px;
  padding: 0 10px;
  margin: 0;
  border-radius: 10px;
  font-size: var(--bt-p2);
  line-height: 34px;
}

/* Button Colors */
.bt-btn--s {
  font-size: var(--bt-p);
  font-weight: 600;
}

.bt-btn--xs {
  font-size: var(--bt-p2);
  font-weight: 600;
}

.bt-btn--primary,
.bt-btn--info {
  background: var(--bt-primary);
  border-color: var(--bt-primary);
  color: var(--bt-surface);
}

.bt-btn--ghost {
  background: transparent;
  border-color: var(--bt-border);
  color: var(--bt-text);
}

.bt-btn.is-update,
.bt-btn--update,
.resend {
  background: var(--bt-primary-2);
  border-color: var(--bt-primary-2);
  color: var(--bt-surface);
}

.bt-btn--accent {
  background: #0f766e;
  border-color: #0f766e;
  color: var(--bt-surface);
}

.bt-btn--warn {
  background: var(--bt-warn);
  border-color: var(--bt-warn);
  color: var(--bt-surface);
}

.bt-btn--success,
.bt-btn.is-success,
.save {
  background: var(--bt-save);
  border-color: var(--bt-save);
  color: var(--bt-surface);
}

.bt-btn--danger,
.bt-btn.is-danger,
.cancel {
  background: var(--bt-danger);
  border-color: var(--bt-danger);
  color: var(--bt-surface);
}

.bt-btn--details {
  background: var(--bt-accent);
  border-color: var(--bt-accent);
  color: var(--bt-surface);
}

.bt-btn--muted {
  background: #e5e7eb;
  border-color: #d1d5db;
  color: #6b7280;
  cursor: default;
}

.bt-btn--muted:hover {
  transform: none;
  filter: none;
}

/* ===== Alerts ===== */
.bt-alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  margin: 2px 0;
  border: 1px solid transparent;
  transition:
    opacity 0.28s ease,
    transform 0.28s ease,
    max-height 0.28s ease,
    margin 0.28s ease,
    padding 0.28s ease;
  max-height: 120px;
  overflow: hidden;
}
.bt-alert--ok {
  border-color: var(--bt-alert-ok-border);
  background: var(--bt-alert-ok-bg);
}
.bt-alert--err {
  border-color: var(--bt-alert-err-border);
  background: var(--bt-alert-err-bg);
}
.bt-alert--success {
  background: #065f46;
  color: #fff;
}
.bt-alert--info {
  background: #1e40af;
  color: #fff;
}
.bt-alert--alert {
  background: firebrick;
  color: #fff;
}

.bt-notice-stack {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.bt-alert.is-hiding {
  opacity: 0;
  transform: translateY(-6px);
  max-height: 0;
  margin: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-width: 0;
}

.bt-alert__content {
  flex: 1 1 auto;
  font-size: var(--bt-p2);
}

.bt-alert__close {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  opacity: 0.8;
}

.bt-alert__close:hover {
  opacity: 1;
}

.bt-pages .bt-help {
  font-size: 12px;
  color: #64748b;
  margin-top: 6px;
}

/* ===== Brand (logo + title) ===== */
.bt-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 24px;
}
.bt-brand__logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #3b82f6, #22c55e);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.bt-logo {
  width: inherit;
  height: inherit;
}
.bt-brand__title {
  font-weight: 700;
  letter-spacing: 0.2px;
}

/* ===== Date field ===== */
.bt-date-field {
  position: relative;
  display: block;
  width: 100%;
}

.bt-date-field > input[type="date"] {
  position: relative;
  z-index: 1;
  padding-right: 46px !important;
  cursor: pointer;
  min-width: 0;
}

.bt-date-field > input[type="date"]::-webkit-calendar-picker-indicator {
  position: absolute;
  top: 0;
  right: 0;
  width: 46px;
  height: 100%;
  margin: 0;
  cursor: pointer;
  opacity: 0;
}

.bt-date-trigger {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border: 0;
  padding: 0;
  border-radius: 8px;
  background: transparent;
  pointer-events: auto;
  cursor: pointer;
  z-index: 2;
}

.bt-date-trigger::before {
  content: "";
  display: block;
  width: 100%;
  height: 100%;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 18px 18px;
  opacity: 0.72;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364758b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E");
}

.bt-date-field:focus-within .bt-date-trigger::before,
.bt-date-trigger:hover::before {
  opacity: 1;
}

.bt-date-field.is-disabled,
.bt-date-field.is-readonly {
  opacity: 0.72;
}

.bt-date-field.is-disabled .bt-date-trigger,
.bt-date-field.is-readonly .bt-date-trigger {
  cursor: not-allowed;
}

/* ===== RESPONSIVE ===== */

@media (max-width: 2170px) {
  .bt-field__short {
    width: 50%;
  }
}

@media (max-width: 1650px) {
  .bt-field__short {
    width: 65%;
  }
}

@media (max-width: 1366px) {
  .bt-field__short {
    width: 75%;
  }
}

@media (max-width: 968px) {
  .bt-field__short {
    width: 100%;
  }
}

@media (max-width: 840px) {
  /* Küçük ekranlarda tablo scroll etsin, aksiyon sütunu dağılmasın */
  .bt-pages__table-scroller {
    overflow-x: auto;
    overflow-y: visible;
  }

  .bt-actions-inline {
    gap: 6px;
  }
}

@media (max-width: 552px) {
  .bt-pages__tools {
    justify-content: flex-end;
  }

  .bt-pdf .bt-btn--info {
    margin-bottom: 3px;
  }
}

:root[data-bt-theme="dark"] .bt-readonly {
  border-color: var(--bt-border);
  background: var(--bt-surface);
  color: var(--bt-text);
}
:root[data-bt-theme="dark"] .bt-stat {
  background: var(--bt-surface);
  border-color: var(--bt-border);
}
:root[data-bt-theme="dark"] .bt-stat strong,
:root[data-bt-theme="dark"] .bt-pages .bt-field label,
:root[data-bt-theme="dark"] .bt-btn,
:root[data-bt-theme="dark"] .button,
:root[data-bt-theme="dark"] .bt-stat span {
  color: var(--bt-text);
}
:root[data-bt-theme="dark"] .bt-pages__table {
  background: var(--bt-card);
}
:root[data-bt-theme="dark"] .bt-pages__table th {
  background: var(--bt-surface);
  color: var(--bt-text);
}
:root[data-bt-theme="dark"] .bt-field select,
:root[data-bt-theme="dark"] .bt-field input[type="text"],
:root[data-bt-theme="dark"] .bt-field input[type="tel"],
:root[data-bt-theme="dark"] .bt-field input[type="email"],
:root[data-bt-theme="dark"] .bt-field input[type="number"],
:root[data-bt-theme="dark"] .bt-field input[type="date"],
:root[data-bt-theme="dark"] .bt-field input[type="password"],
:root[data-bt-theme="dark"] .bt-field textarea,
:root[data-bt-theme="dark"] .bt-field input[type="file"] {
  background: var(--bt-surface);
  color: var(--bt-text);
  border-color: var(--bt-border);
}

:root[data-bt-theme="dark"] .bt-field [disabled] {
  background: var(--bt-input-bg) !important;
}

:root[data-bt-theme="dark"] .bt-stat {
  background: var(--bt-surface);
  color: var(--bt-text);
}
