
/* =========================================================
   DYNASTY — CLIENTS
   Premium client management interface
   ========================================================= */

.clients-page {
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
  animation: dynasty-clients-enter 220ms ease-out;
}

@keyframes dynasty-clients-enter {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.clients-page .clients-header {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--dynasty-border);
}

.clients-page .clients-header h1 {
  font-size: clamp(25px, 5vw, 32px);
  font-weight: 650;
  letter-spacing: -0.035em;
  margin-bottom: 7px;
}

.clients-page .clients-header p {
  font-size: 13px;
  line-height: 1.6;
}

.clients-page .eyebrow {
  color: var(--dynasty-gold);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.17em;
}

.clients-page .dashboard-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.clients-page .btn {
  min-height: 40px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 650;
  transition:
    background 180ms ease,
    border-color 180ms ease,
    color 180ms ease,
    transform 180ms ease;
}

.clients-page .btn-primary {
  background: var(--dynasty-gold);
  color: var(--dynasty-black);
  border: 1px solid var(--dynasty-gold);
}

.clients-page .btn-primary:hover:not(:disabled) {
  background: #e0bd4c;
  border-color: #e0bd4c;
  transform: translateY(-1px);
}

.clients-page .btn-secondary {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--dynasty-white);
}

.clients-page .btn-secondary:hover:not(:disabled) {
  border-color: var(--dynasty-gold);
  background: rgba(201, 162, 39, 0.07);
}

.clients-page .btn-ghost {
  border: 1px solid transparent;
  color: var(--dynasty-muted);
}

.clients-page .btn-ghost:hover:not(:disabled) {
  color: var(--dynasty-white);
  border-color: var(--dynasty-border);
}

.clients-page button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* ---------- Statistics ---------- */

.clients-page .card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.clients-page .dashboard-card {
  position: relative;
  gap: 9px;
  padding: 18px;
  overflow: hidden;
  background:
    linear-gradient(145deg, rgba(201, 162, 39, 0.045), transparent 65%),
    var(--dynasty-panel);
  border: 1px solid var(--dynasty-border);
  border-radius: 12px;
  transition: border-color 180ms ease, transform 180ms ease;
}

.clients-page .dashboard-card:hover {
  border-color: rgba(201, 162, 39, 0.45);
  transform: translateY(-2px);
}

.clients-page .dashboard-card span {
  color: var(--dynasty-muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.clients-page .dashboard-card strong {
  color: var(--dynasty-white);
  font-size: clamp(23px, 5vw, 30px);
  font-weight: 650;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.clients-page .dashboard-card small {
  color: var(--dynasty-muted);
  font-size: 11px;
  line-height: 1.5;
}

/* ---------- Panels ---------- */

.clients-page .dashboard-panel {
  min-width: 0;
  padding: 20px;
  background: var(--dynasty-panel);
  border: 1px solid var(--dynasty-border);
  border-radius: 12px;
}

.clients-page .dashboard-panel h2 {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.015em;
}

.clients-page .dashboard-panel > p {
  font-size: 12px;
}

/* ---------- Search and filters ---------- */

.clients-page .clients-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.clients-page .clients-search {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 12px 14px;
  background: #101010;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 8px;
  color: var(--dynasty-white);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.clients-page .clients-search::placeholder {
  color: #77776f;
}

.clients-page .clients-search:focus {
  outline: none;
  border-color: var(--dynasty-gold);
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.09);
}

.clients-page select.clients-search {
  cursor: pointer;
}

.clients-page textarea.clients-search {
  min-height: 110px;
}

/* ---------- Client cards ---------- */

.clients-page .clients-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.clients-page .client-card {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  padding: 17px;
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid rgba(255, 255, 255, 0.085);
  border-radius: 11px;
  transition:
    background 180ms ease,
    border-color 180ms ease,
    transform 180ms ease;
}

.clients-page .client-card:hover {
  background: rgba(201, 162, 39, 0.035);
  border-color: rgba(201, 162, 39, 0.38);
  transform: translateY(-1px);
}

.clients-page .client-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(201, 162, 39, 0.65);
  border-radius: 12px;
  background: linear-gradient(
    145deg,
    rgba(201, 162, 39, 0.15),
    rgba(201, 162, 39, 0.025)
  );
  color: var(--dynasty-gold);
  font-size: 13px;
  font-weight: 750;
  letter-spacing: 0.04em;
}

.clients-page .client-info {
  flex: 1;
  min-width: 0;
}

.clients-page .client-info h2,
.clients-page .client-info h3 {
  margin-bottom: 5px;
  color: var(--dynasty-white);
  font-size: 14px;
  font-weight: 650;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.clients-page .client-info p {
  margin-top: 3px;
  color: var(--dynasty-muted);
  font-size: 11px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.clients-page .client-info .status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border: 1px solid var(--dynasty-border);
  border-radius: 20px;
  color: var(--dynasty-gold);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.clients-page .client-info .status-paid {
  border-color: rgba(87, 190, 133, 0.3);
  background: rgba(87, 190, 133, 0.07);
  color: #75d6a0;
}

.clients-page .client-info .status-overdue {
  border-color: rgba(230, 100, 100, 0.3);
  background: rgba(230, 100, 100, 0.07);
  color: #ff9292;
}

.clients-page .client-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 7px;
}

.clients-page .client-actions .btn {
  min-height: 34px;
  padding: 7px 11px;
  font-size: 11px;
}

/* ---------- Empty states ---------- */

.clients-page .clients-empty {
  padding: 38px 20px;
  background: rgba(255, 255, 255, 0.012);
  border: 1px dashed rgba(201, 162, 39, 0.28);
  border-radius: 10px;
  text-align: center;
}

.clients-page .clients-empty h2 {
  margin-bottom: 8px;
  font-size: 16px;
}

.clients-page .clients-empty p {
  max-width: 420px;
  margin: 0 auto 17px;
  font-size: 12px;
  line-height: 1.7;
}

/* ---------- Forms ---------- */

.clients-page #client-form-panel {
  border-color: rgba(201, 162, 39, 0.32);
  background:
    linear-gradient(145deg, rgba(201, 162, 39, 0.035), transparent 50%),
    var(--dynasty-panel);
}

.clients-page #dynasty-client-form {
  margin-top: 20px;
}

.clients-page #dynasty-client-form label {
  display: block;
  margin-bottom: 7px;
  color: #d6d6cd;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.025em;
}

.clients-page #dynasty-client-form .clients-search {
  margin: 0;
}

.clients-page #dynasty-client-form .dashboard-actions {
  padding-top: 15px;
  border-top: 1px solid var(--dynasty-border);
}

.clients-page #client-form-error {
  font-size: 12px;
  line-height: 1.6;
}

/* ---------- Client profile and balances ---------- */

.clients-page .detail-stat {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 12px;
}

.clients-page .detail-stat:last-child {
  border-bottom: none;
}

.clients-page .detail-stat span {
  color: var(--dynasty-muted);
}

.clients-page .detail-stat strong {
  max-width: 65%;
  color: var(--dynasty-white);
  text-align: right;
  overflow-wrap: anywhere;
  font-weight: 600;
}

/* ---------- Invoice history ---------- */

.clients-page .invoices-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.clients-page .invoice-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  min-width: 0;
  padding: 14px;
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid rgba(255, 255, 255, 0.075);
  border-radius: 9px;
}

.clients-page .invoice-card-main {
  flex: 1;
  min-width: 0;
}

.clients-page .invoice-card-main h2,
.clients-page .invoice-card-main h3 {
  margin-bottom: 6px;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.clients-page .invoice-card-main p {
  margin-top: 3px;
  font-size: 10px;
  line-height: 1.6;
}

.clients-page .invoice-card-amount {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.clients-page .invoice-card .status {
  display: inline-block;
  margin-top: 6px;
  color: var(--dynasty-muted);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ---------- Keyboard accessibility ---------- */

.clients-page button:focus-visible,
.clients-page input:focus-visible,
.clients-page select:focus-visible,
.clients-page textarea:focus-visible {
  outline: 2px solid var(--dynasty-gold);
  outline-offset: 3px;
}

/* ---------- Responsive layout ---------- */

@media (min-width: 520px) {
  .clients-page .clients-toolbar {
    grid-template-columns: minmax(0, 1fr) minmax(150px, 190px);
  }
}

@media (min-width: 700px) {
  .clients-page {
    gap: 26px;
  }

  .clients-page .clients-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .clients-page .card-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .clients-page {
    gap: 18px;
  }

  .clients-page .dashboard-panel {
    padding: 15px;
  }

  .clients-page .dashboard-card {
    padding: 14px;
  }

  .clients-page .client-card {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 11px;
    padding: 13px;
  }

  .clients-page .client-avatar {
    flex-basis: 38px;
    width: 38px;
    height: 38px;
    border-radius: 10px;
  }

  .clients-page .client-info {
    flex: 1 1 calc(100% - 52px);
  }

  .clients-page .client-actions {
    flex: 1 1 100%;
    justify-content: flex-start;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
  }

  .clients-page .client-actions .btn {
    flex: 1;
  }

  .clients-page .invoice-card {
    align-items: flex-start;
    flex-direction: column;
  }

  .clients-page .invoice-card-meta {
    width: 100%;
    justify-content: flex-start;
  }

  .clients-page .detail-stat {
    gap: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .clients-page,
  .clients-page * {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
