/* billing.css */

:root {
  --color-bg: #f5f5f7;
  --color-surface: #ffffff;
  --color-border: #d0d0d5;
  --color-border-soft: #e3e3e9;
  --color-text: #1f1f23;
  --color-muted: #6b6b76;
  --color-primary: #990000; /* Crimson */
  --color-primary-soft: #f4e3e3;
  --color-success: #1b7f4d;
  --color-warning: #b88300;
  --color-error: #b00020;

  --radius-lg: 16px;
  --radius-sm: 8px;

  --shadow-soft: 0 6px 20px rgba(0, 0, 0, 0.06);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
}

/* Layout */

.page-container {
  max-width: 1100px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-header h1 {
  margin: 0;
  font-size: 1.8rem;
}

.page-subtitle {
  margin: 0.35rem 0 0;
  color: var(--color-muted);
  font-size: 0.95rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Cards */

.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--color-border-soft);
  margin-bottom: 1.25rem;
}

.card-header {
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--color-border-soft);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.card-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.card-subtitle {
  margin: 0;
  color: var(--color-muted);
  font-size: 0.9rem;
}

.card-body {
  padding: 1.1rem 1.25rem 1.2rem;
}

/* Buttons */

.btn {
  border-radius: 999px;
  padding: 0.45rem 1rem;
  border: 1px solid transparent;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  background: #e5e5ea;
  color: var(--color-text);
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.btn-primary:hover {
  background: #7a0000;
  border-color: #7a0000;
}

.btn-secondary {
  background: #ffffff;
  border-color: var(--color-border);
}

.btn-secondary:hover {
  background: #f3f3f6;
}

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

.btn-outline:hover {
  background: #f3f3f6;
}

.btn-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--color-primary);
  text-decoration: underline;
}

.btn-link:hover {
  color: #7a0000;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Forms */

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.form-row-end {
  justify-content: flex-end;
}

.form-group {
  flex: 1 1 230px;
  min-width: 0;
}

.form-group-sm {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

label {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.9rem;
  font-weight: 500;
}

input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  background: #fff;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 1px var(--color-primary-soft);
}

textarea {
  resize: vertical;
}

.hint {
  display: block;
  font-size: 0.8rem;
  color: var(--color-muted);
  margin-top: 0.2rem;
}

/* Cadet info */

.cadet-info {
  border-radius: var(--radius-sm);
  border: 1px dashed var(--color-border-soft);
  background: #fafafa;
  padding: 0.7rem 0.9rem;
  margin-bottom: 0.6rem;
}

.cadet-info--empty {
  text-align: left;
  color: var(--color-muted);
  font-size: 0.9rem;
}

.cadet-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cadet-summary--former {
  background: #fffaf0;
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.55rem;
}

.cadet-name {
  font-weight: 600;
  margin-bottom: 0.15rem;
}

.cadet-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  font-size: 0.8rem;
  color: var(--color-muted);
}

/* Add item row */

.add-item-row {
  display: flex;
  gap: 0.6rem;
}

/* Table */

.table-wrapper {
  width: 100%;
  overflow: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border-soft);
  margin-top: 0.6rem;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.table th,
.table td {
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--color-border-soft);
  text-align: left;
}

.table th {
  background: #fafafa;
  font-weight: 600;
  font-size: 0.86rem;
}

.table tbody tr:nth-child(even) {
  background: #fcfcfd;
}

.table tbody tr:hover {
  background: #f5f5fb;
}

.table .empty-row {
  text-align: center;
  color: var(--color-muted);
  font-style: italic;
}

.input-number {
  width: 4.5rem;
}

.summary-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  font-size: 0.95rem;
}

.summary-label {
  color: var(--color-muted);
}

.summary-value {
  font-weight: 600;
}

/* Status messages */

.status-message {
  margin-top: 0.4rem;
  font-size: 0.87rem;
}

.status-message--info {
  color: #00529b;
}

.status-message--success {
  color: var(--color-success);
}

.status-message--warning {
  color: var(--color-warning);
}

.status-message--error {
  color: var(--color-error);
}

/* Statement preview */

#statement-card {
  margin-top: 1.5rem;
}

.statement-header h3 {
  margin: 0 0 0.25rem;
  font-size: 1.1rem;
}

.statement-header p {
  margin: 0;
  color: var(--color-muted);
  font-size: 0.87rem;
}

.statement-section {
  margin-top: 0.9rem;
}

.statement-section h4 {
  margin: 0 0 0.3rem;
  font-size: 0.98rem;
}

.statement-total {
  margin-top: 0.6rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  font-weight: 600;
}

.table-statement th,
.table-statement td {
  font-size: 0.85rem;
}

.statement-footer {
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--color-muted);
}


/* Responsive */

@media (max-width: 768px) {
  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .add-item-row {
    flex-direction: column;
  }

  .input-number {
    width: 100%;
  }
}
/* Print-only layout: show just the billing statement, like a clean document */
@media print {
  @page {
    margin: 0.6in;
  }

  body {
    background: #ffffff;
  }

  /* Hide everything by default */
  body * {
    visibility: hidden;
  }

  /* Show only the statement card and its contents */
  #statementCard,
  #statementCard * {
    visibility: visible;
  }

  /* Position the statement like a standalone document */
  #statementCard {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    margin: 0;
    padding: 0;
    border: none;
    box-shadow: none;
  }

  /* Hide the preview header (buttons, etc.) inside the card */
  #statementCard .card-header {
    display: none !important;
  }

  #statementCard .card-body {
    padding: 0; /* use inner spacing from statementContent */
  }

  /* Statement typography / table tweaks for print */
  #statementContent {
    padding: 0;
  }

  #statementContent .statement-header h3 {
    font-size: 1.2rem;
  }

  #statementContent .statement-section h4 {
    font-size: 0.95rem;
    text-transform: none;
  }

  #statementContent .table-statement {
    width: 100%;
    border-collapse: collapse;
  }

  #statementContent .table-statement th,
  #statementContent .table-statement td {
    border: 1px solid #000;
    padding: 0.2rem 0.3rem;
    font-size: 0.75rem;
  }

  #statementContent .statement-total {
    margin-top: 0.4rem;
    font-size: 0.9rem;
  }

  #statementContent .statement-footer {
    margin-top: 0.8rem;
    font-size: 0.75rem;
  }
}
