/* ===============================
   FINANCE PAGE STYLES
================================ */

/* KPI row: responsive columns — avoids 6× col-xl-2 squeezing long TRY amounts */
.finance-kpi-grid {
  display: grid;
  gap: 1rem;
  /* Wider minimum track = fewer columns when main area is narrow (sidebar layout) */
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 12.75rem), 1fr));
}

@media (min-width: 1500px) {
  .finance-kpi-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

@media (min-width: 1100px) and (max-width: 1499.98px) {
  .finance-kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Stats Cards */
.stats-card {
  background: white;
  border-radius: 0.75rem;
  padding: 0.875rem 1rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  border: 1px solid var(--border-light);
  transition: all 0.2s ease;
  text-align: center;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}
.stats-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.stats-label {
  font-size: 0.75rem;
  line-height: 1.3;
  color: var(--text-light);
  margin-bottom: 0.35rem;
  max-width: 100%;
  padding: 0 0.125rem;
  hyphens: auto;
  overflow-wrap: break-word;
}
.stats-value {
  font-size: clamp(0.95rem, 0.55rem + 1.1vw, 1.45rem);
  font-weight: 700;
  color: var(--ossi-navy);
  line-height: 1.25;
  max-width: 100%;
  min-width: 0;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Table */
.table th {
  background-color: var(--gray-100);
  font-weight: 600;
  color: var(--text-medium);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.75rem;
  border-bottom: 1px solid var(--border-light);
}
.table td {
  padding: 0.75rem;
  vertical-align: middle;
  font-size: 0.875rem;
  color: var(--ossi-navy);
}
.table tbody tr:hover {
  background-color: rgba(67, 97, 238, 0.03);
}

/* HR: drill-down rows in Personel Listesi */
.staff-dir-cat-row {
  cursor: pointer;
}
.staff-dir-cat-row:hover {
  background-color: rgba(13, 110, 253, 0.06);
}

/* Amount colors */
.amount-pos {
  color: var(--success);
  font-weight: 700;
}
.amount-neg {
  color: var(--danger);
  font-weight: 700;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1050;
}

/* Signature boxes */
.signature-box {
  border: 1px dashed var(--border-light);
  padding: 14px;
  border-radius: 10px;
}
.sig-title {
  font-size: 12px;
  opacity: 0.75;
  margin-bottom: 24px;
}
.sig-line {
  border-bottom: 2px solid #cbd5e1;
  height: 42px;
}

.role-preview-box {
  padding: 0.85rem 1rem;
  border: 1px solid var(--border-light, #e5e7eb);
  border-radius: 0.75rem;
  background: #f8fafc;
}

.ltr {
  direction: ltr;
  text-align: left;
}

.staff-image-upload-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.staff-image-upload-row .form-control {
  flex: 1;
}

.staff-image-preview {
  min-height: 60px;
}

.staff-image-preview img {
  width: 84px;
  height: 84px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--border-light, #e5e7eb);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.finance-chart-frame {
  position: relative;
  height: 320px;
  min-height: 320px;
  max-height: 320px;
  overflow: hidden;
}

.finance-chart-frame-sm {
  height: 300px;
  min-height: 300px;
  max-height: 300px;
}

.finance-chart-frame canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

#dashboard {
  overflow-x: hidden;
}

.dashboard-scroll-panel {
  height: 500px;
  max-height: 500px;
  overflow-y: auto;
  overflow-x: hidden;
}

.dashboard-scroll-panel .table-responsive {
  min-height: 100%;
}

.dashboard-payout-panel {
  height: 300px;
  max-height: 300px;
  overflow-y: auto;
  overflow-x: auto;
}

.payroll-table-panel,
.personnel-payment-table {
  max-height: 560px;
  overflow: auto;
}

.payroll-table-panel table {
  min-width: 1180px;
}

.personnel-payment-table table {
  min-width: 940px;
}

.field-payout-request-panel {
  max-height: 420px;
  overflow: auto;
}

.payroll-summary-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.payroll-number-input {
  width: 92px;
  min-width: 92px;
}

.flow-action-group {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.35rem;
}

.flow-status-note {
  max-width: 220px;
  white-space: normal;
  line-height: 1.25;
}

.payment-overdue {
  color: #b91c1c;
  font-weight: 700;
}

.commission-side-table {
  height: 320px;
  max-height: 320px;
  overflow: auto;
}

.commission-orders-panel {
  height: 560px;
  max-height: 560px;
  overflow-y: auto;
  overflow-x: auto;
}

.commission-orders-panel .table,
.commission-side-table .table {
  min-width: 760px;
}

.finance-ledger-shell {
  min-width: 0;
}

.seller-finance-list {
  max-height: 720px;
  overflow: auto;
  padding: 12px;
}

.seller-finance-card {
  width: 100%;
  border: 1px solid rgba(148, 163, 184, 0.26);
  background: #fff;
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 10px;
  text-align: left;
  display: grid;
  gap: 10px;
  transition: border-color .18s ease, box-shadow .18s ease;
}

.seller-finance-card:hover,
.seller-finance-card.active {
  border-color: rgba(219, 39, 119, 0.42);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
}

.seller-card-main,
.seller-card-money,
.seller-card-meta {
  display: grid;
  gap: 2px;
}

.seller-card-main strong,
.seller-card-money b {
  color: #111827;
}

.seller-card-main small,
.seller-card-money small,
.seller-card-meta small {
  color: #64748b;
}

.seller-card-due.ready {
  color: #15803d;
  font-weight: 700;
}

.seller-card-due.waiting {
  color: #a16207;
  font-weight: 700;
}

.seller-finance-profile {
  min-height: 420px;
}

.seller-finance-profile.empty,
.seller-finance-profile.loading {
  border: 1px dashed rgba(148, 163, 184, 0.4);
  border-radius: 8px;
  background: #fff;
}

.seller-profile-empty {
  min-height: 420px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  color: #64748b;
  text-align: center;
}

.seller-profile-empty i {
  font-size: 38px;
  color: #db2777;
}

.seller-profile-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.seller-profile-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.seller-ledger-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.seller-ledger-kpi {
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  min-width: 0;
}

.seller-ledger-kpi span {
  display: block;
  color: #64748b;
  font-size: 12px;
  margin-bottom: 4px;
}

.seller-ledger-kpi strong {
  color: #111827;
  font-size: 17px;
  word-break: break-word;
}

.seller-ledger-kpi.good strong { color: #15803d; }
.seller-ledger-kpi.warn strong { color: #a16207; }
.seller-ledger-kpi.bad strong { color: #b91c1c; }
.seller-ledger-kpi.hold strong { color: #2563eb; }
.seller-ledger-kpi.ready strong { color: #15803d; }
.seller-ledger-kpi.waiting strong { color: #a16207; }

.seller-ledger-kpi-text strong {
  font-size: 14px;
  line-height: 1.35;
}

.seller-due-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.seller-due-chip.ready {
  background: rgba(34, 197, 94, 0.12);
  color: #15803d;
}

.seller-due-chip.waiting {
  background: rgba(245, 158, 11, 0.14);
  color: #a16207;
}

.seller-adjustment-card {
  display: grid;
  grid-template-columns: minmax(180px, 1.5fr) 120px 130px minmax(180px, 1fr) auto;
  gap: 10px;
  align-items: end;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  margin-bottom: 16px;
}

.seller-ledger-table {
  max-height: 560px;
  overflow: auto;
}

.seller-ledger-table table {
  min-width: 980px;
}

.seller-payout-list {
  max-height: 560px;
  overflow: auto;
}

.seller-payout-row {
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.seller-payout-row strong {
  color: #111827;
}

.seller-payout-row span {
  color: #334155;
  font-size: 13px;
}

.seller-payout-row small {
  color: #64748b;
}

@media (max-width: 768px) {
  .stats-card {
    padding: 0.85rem 1rem;
  }

  .stats-value {
    font-size: clamp(0.9rem, 3.5vw, 1.2rem);
  }

  .finance-chart-frame,
  .finance-chart-frame-sm {
    height: 240px;
    min-height: 240px;
    max-height: 240px;
  }

  .dashboard-scroll-panel,
  .dashboard-payout-panel {
    height: auto;
    max-height: none;
  }

  .payroll-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .staff-image-upload-row {
    flex-direction: column;
    align-items: stretch;
  }

  .staff-image-preview img {
    width: 72px;
    height: 72px;
  }

  .table th,
  .table td {
    white-space: nowrap;
  }

  .seller-profile-head,
  .seller-adjustment-card {
    grid-template-columns: 1fr;
    display: grid;
  }

  .seller-profile-actions {
    justify-content: stretch;
  }
}

/* Print styles */
@media print {
  body * {
    visibility: hidden;
  }
  #txModal, #txModal * {
    visibility: visible;
  }
  #txModal {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
  }
  .modal {
    position: static;
  }
  .modal-dialog {
    max-width: 840px;
    margin: 0 auto;
  }
  .modal-header .btn, .btn-close, .modal-footer {
    display: none !important;
  }
  input, textarea {
    border: none !important;
    background: transparent !important;
    padding: 0;
  }
}
