/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: #f0f0f3;
  color: #1a1a2e;
  min-height: 100vh;
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

/* ===== Header ===== */
header {
  text-align: center;
  margin-bottom: 24px;
}

header h1 {
  font-size: 2rem;
  font-weight: 800;
  color: #1a1a2e;
}

.subtitle {
  color: #6b7280;
  font-size: 0.95rem;
  margin-top: 4px;
}

/* ===== Tabs ===== */
.tabs {
  display: flex;
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e0e0e0;
  overflow: hidden;
  margin-bottom: 24px;
}

.tab {
  flex: 1;
  padding: 12px 16px;
  border: none;
  background: transparent;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  color: #6b7280;
  transition: all 0.2s;
}

.tab:hover {
  background: #f5f5f7;
}

.tab.active {
  background: #1a1a2e;
  color: #fff;
  border-radius: 10px;
  margin: 3px;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ===== Cards ===== */
.card {
  background: #fff;
  border-radius: 14px;
  border: 1px solid #e5e5ea;
  padding: 28px;
}

.card-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 20px;
}

.card-header .icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  margin-top: 2px;
}

.card-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
}

.card-subtitle {
  color: #6b7280;
  font-size: 0.85rem;
  margin-top: 2px;
}

/* ===== Layout ===== */
.create-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

@media (max-width: 768px) {
  .create-layout {
    grid-template-columns: 1fr;
  }
}

/* ===== Form Elements ===== */
.form-section {
  margin-bottom: 16px;
}

.form-section h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 12px;
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: #1a1a2e;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="month"],
select,
textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #e5e5ea;
  border-radius: 8px;
  font-size: 0.9rem;
  background: #f5f5f7;
  color: #1a1a2e;
  font-family: inherit;
  margin-bottom: 12px;
  transition: border-color 0.2s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #1a1a2e;
  background: #fff;
}

select {
  cursor: pointer;
  appearance: auto;
}

textarea {
  resize: vertical;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
}

.form-group label {
  margin-bottom: 6px;
}

hr {
  border: none;
  border-top: 1px solid #e5e5ea;
  margin: 20px 0;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-primary {
  background: #1a1a2e;
  color: #fff;
}

.btn-primary:hover {
  background: #2d2d48;
}

.btn-secondary {
  background: #f5f5f7;
  color: #1a1a2e;
  border: 1px solid #e5e5ea;
}

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

.btn-generate {
  width: 100%;
  padding: 14px;
  background: #1a1a2e;
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  margin-top: 20px;
  border-radius: 10px;
}

.btn-generate:hover {
  background: #2d2d48;
}

.btn-add-charge {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #1a1a2e;
  color: #fff;
  font-size: 1.2rem;
  padding: 0;
  margin-top: 8px;
}

.btn-add-charge:hover {
  background: #2d2d48;
}

/* ===== Students List ===== */
.students-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.student-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #f5f5f7;
  border-radius: 10px;
  border: 1px solid #e5e5ea;
}

.student-item span {
  font-size: 0.9rem;
  font-weight: 500;
}

.btn-delete {
  background: none;
  border: none;
  cursor: pointer;
  color: #9ca3af;
  padding: 4px;
  transition: color 0.2s;
}

.btn-delete:hover {
  color: #ef4444;
}

.btn-delete svg {
  width: 18px;
  height: 18px;
}

.empty-msg {
  color: #9ca3af;
  font-size: 0.85rem;
  text-align: center;
  padding: 12px;
}

/* ===== Calendar / Class Dates ===== */
.class-dates-container {
  margin-bottom: 8px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 4px;
}

.calendar-header {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: #6b7280;
  padding: 4px;
}

.calendar-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  border: 1px solid #e5e5ea;
  background: #f5f5f7;
  transition: all 0.15s;
  font-weight: 500;
}

.calendar-day:hover {
  border-color: #1a1a2e;
}

.calendar-day.selected {
  background: #1a1a2e;
  color: #fff;
  border-color: #1a1a2e;
}

.calendar-day.empty {
  visibility: hidden;
  border: none;
}

.selected-count {
  font-size: 0.8rem;
  color: #6b7280;
  margin-top: 4px;
}

/* ===== Additional Charges ===== */
.charge-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: end;
  margin-bottom: 8px;
}

.charge-row input[type="text"] {
  margin-bottom: 0;
}

.charge-row input[type="number"] {
  width: 100px;
  margin-bottom: 0;
}

.btn-remove-charge {
  background: none;
  border: none;
  cursor: pointer;
  color: #9ca3af;
  padding: 8px 4px;
  font-size: 1.1rem;
  transition: color 0.2s;
}

.btn-remove-charge:hover {
  color: #ef4444;
}

/* ===== Invoice Form Disabled State ===== */
.invoice-form-disabled {
  opacity: 0.5;
  pointer-events: none;
}

.invoice-form-enabled {
  opacity: 1;
  pointer-events: all;
}

/* ===== Preview ===== */
.preview-card {
  min-height: 400px;
}

.preview-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  color: #9ca3af;
}

.preview-actions {
  display: flex;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 12px;
}

.preview-content .btn-primary {
  margin-left: auto;
}

/* ===== Invoice Render (Preview & PDF) ===== */
.invoice-render {
  background: #fff;
  padding: 48px;
  max-width: 800px;
  margin: 0 auto;
  font-size: 14px;
  color: #1a1a2e;
}

.invoice-render .invoice-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 36px;
  padding-bottom: 20px;
  border-bottom: 2px solid #1a1a2e;
}

.invoice-render .invoice-header h2 {
  font-size: 28px;
  font-weight: 800;
  color: #1a1a2e;
}

.invoice-render .invoice-meta {
  text-align: right;
  font-size: 13px;
  color: #4b5563;
  line-height: 1.6;
}

.invoice-render .invoice-meta strong {
  color: #1a1a2e;
}

.invoice-render .invoice-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  margin-bottom: 32px;
}

.invoice-render .party h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #6b7280;
  margin-bottom: 6px;
}

.invoice-render .party p {
  font-size: 14px;
  line-height: 1.5;
}

.invoice-render table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
}

.invoice-render thead th {
  background: #f5f5f7;
  padding: 10px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #4b5563;
  border-bottom: 2px solid #e5e5ea;
}

.invoice-render thead th:last-child {
  text-align: right;
}

.invoice-render tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid #f0f0f3;
  font-size: 13px;
}

.invoice-render tbody td:last-child {
  text-align: right;
  font-weight: 600;
}

.invoice-render .totals {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 32px;
}

.invoice-render .totals-table {
  width: 280px;
}

.invoice-render .totals-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 13px;
}

.invoice-render .totals-row.discount {
  color: #16a34a;
}

.invoice-render .totals-row.charge {
  color: #6b7280;
}

.invoice-render .totals-row.total {
  font-size: 16px;
  font-weight: 800;
  border-top: 2px solid #1a1a2e;
  padding-top: 12px;
  margin-top: 4px;
}

.invoice-render .payment-terms {
  background: #f5f5f7;
  border-radius: 8px;
  padding: 16px 20px;
  margin-top: 32px;
}

.invoice-render .payment-terms h4 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6b7280;
  margin-bottom: 6px;
}

.invoice-render .payment-terms p {
  font-size: 13px;
  line-height: 1.6;
  color: #4b5563;
  white-space: pre-line;
}

/* ===== Settings ===== */
.settings-card {
  max-width: 800px;
  margin: 0 auto;
}

.data-actions {
  display: flex;
  gap: 12px;
  margin-top: 12px;
}

/* ===== Toast Notification ===== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1a1a2e;
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 1000;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s;
  max-width: 350px;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  background: #dc2626;
}

.toast.success {
  background: #16a34a;
}
