@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800&family=JetBrains+Mono:wght@400;700&display=swap');

:root {
  --primary: #1e293b;
  --accent: #2563eb;
  --bg: #f1f5f9;
  --card-bg: #ffffff;
  --border: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Roboto Mono', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg);
  color: var(--text-main);
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

/* Login Styles */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.login-card {
  background: var(--card-bg);
  padding: 48px 40px;
  border-radius: 24px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.05);
  width: 100%;
  max-width: 420px;
  border: 1px solid rgba(255,255,255,0.5);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.login-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 6px;
  background: linear-gradient(90deg, var(--accent), #60a5fa);
}

.login-logo {
  width: 64px;
  height: 64px;
  background: #eff6ff;
  color: var(--accent);
  border-radius: 16px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0 auto 20px;
}

.login-card h2 {
  color: var(--primary);
  margin-bottom: 6px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.login-card p {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 32px;
  font-weight: 500;
}

.login-form {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-icon svg {
  position: absolute;
  left: 14px;
  color: #94a3b8;
  pointer-events: none;
}

.input-with-icon input {
  width: 100%;
  padding: 12px 14px 12px 42px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  font-size: 14px;
  background: #f8fafc;
  transition: all 0.2s;
}

.input-with-icon input:focus {
  outline: none;
  border-color: var(--accent);
  background: white;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.login-error {
  color: #ef4444;
  font-size: 13px;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 600;
  background: #fef2f2;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #fecaca;
}

.login-btn {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  font-size: 15px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  background: var(--primary);
}

.login-btn:hover {
  background: #0f172a;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15);
}

/* Header */
header {
  background: var(--primary);
  color: white;
  padding: 16px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

header h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.badge {
  background: rgba(255,255,255,0.1);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Main Layout */
main {
  display: grid;
  grid-template-columns: 420px 1fr;
  flex: 1;
  height: calc(100vh - 60px);
}

/* Left Column: Form Controls */
.controls {
  background: var(--card-bg);
  border-right: 1px solid var(--border);
  padding: 24px;
  padding-bottom: 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: scroll;
  overflow-x: hidden;
}

.section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  display: block;
}

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

label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-main);
}

input, select {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: #f8fafc;
  font-family: var(--font-sans);
}

.fee-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.actions {
  margin-top: 20px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.btn {
  padding: 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.btn:hover {
  opacity: 0.9;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-outline {
  background: white;
  border: 1px solid var(--border);
  color: var(--text-main);
}

.right-panel {
  display: flex;
  flex-direction: column;
  background: #e2e8f0;
  height: 100%;
}

.panel-tabs {
  display: flex;
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
}

.tab-btn {
  padding: 16px 24px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn:hover {
  color: var(--primary);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--accent);
}

.tab-content {
  flex: 1;
  overflow-y: auto;
  display: none;
}

.tab-content.active {
  display: flex;
  flex-direction: column;
}

/* Records View Styling */
.records-container {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
}

.filters-row {
  display: flex;
  gap: 16px;
  background: white;
  padding: 16px;
  border-radius: 12px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.filter-item {
  flex: 1;
}

.table-responsive {
  background: white;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
  overflow-x: auto;
}

.records-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.records-table th {
  background: #f8fafc;
  padding: 12px;
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.records-table td {
  padding: 12px;
  border-bottom: 1px solid #f1f5f9;
}

.records-table tr:last-child td {
  border-bottom: none;
}

.action-btns {
  display: flex;
  gap: 8px;
}

.btn-icon {
  padding: 6px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon.edit {
  background: #eff6ff;
  color: #3b82f6;
}

.btn-icon.delete {
  background: #fef2f2;
  color: #ef4444;
}

/* Right Column: Challan Preview */
.preview-container {
  padding: 24px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100%;
}

.a4-page {
  width: 794px;
  height: 561px;
  max-width: none;
  background: white;
  box-shadow: 0 10px 25px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: 30px;
  transform-origin: top center;
}

/* Responsive Design */
@media (max-width: 1400px) {
  .a4-page {
    transform: scale(0.8);
    margin-bottom: calc(-561px * 0.2);
  }
}
@media (max-width: 1100px) {
  .a4-page {
    transform: scale(0.65);
    margin-bottom: calc(-561px * 0.35);
  }
}
@media (max-width: 900px) {
  body {
    overflow-y: auto;
  }
  .app-container {
    height: auto;
    min-height: 100vh;
  }
  main {
    display: flex;
    flex-direction: column;
    height: auto;
  }
  .controls {
    border-right: none;
    border-bottom: 1px solid var(--border);
    height: auto;
    overflow: visible;
    padding-bottom: 30px;
  }
  .preview-container {
    padding: 40px 20px;
    overflow: hidden;
    display: flex;
    justify-content: center;
  }
  .a4-page {
    transform: scale(0.6);
    margin-bottom: calc(-561px * 0.4);
  }
}
@media (max-width: 600px) {
  header {
    flex-direction: column;
    text-align: center;
    gap: 12px;
    padding: 16px;
  }
  header h1 {
    font-size: 16px;
  }
  .fee-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .controls {
    padding: 24px 16px;
  }
  .a4-page {
    transform: scale(0.42);
    margin-bottom: calc(-561px * 0.58);
  }
  .login-card {
    margin: 20px;
    padding: 32px 24px;
    width: calc(100% - 40px);
  }
}
@media (max-width: 400px) {
  .a4-page {
    transform: scale(0.36);
    margin-bottom: calc(-561px * 0.64);
  }
}

.print-wrapper {
  display: flex;
  flex-direction: row;
  gap: 20px;
  width: 100%;
  height: 100%;
}

@media screen {
  #schoolCopy {
    display: none;
  }
}

.challan-copy {
  flex: 1;
  height: 100%;
  border: 1.5px dashed #cbd5e1;
  padding: 20px;
  margin: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.paid-stamp {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-30deg);
  font-size: 70px;
  font-weight: 900;
  color: rgba(34, 197, 94, 0.12);
  border: 8px solid rgba(34, 197, 94, 0.12);
  border-radius: 16px;
  padding: 10px 40px;
  pointer-events: none;
  z-index: 0;
  text-transform: uppercase;
  letter-spacing: 12px;
}

.challan-header, .challan-details, .fee-table, .signature-section {
  position: relative;
  z-index: 1;
}

.challan-copy:last-child {
  margin-bottom: 0;
  margin-top: 10px;
}

.copy-label {
  position: absolute;
  top: 0;
  right: 0;
  background: #f1f5f9;
  font-size: 10px;
  font-weight: 800;
  padding: 4px 12px;
  border-bottom-left-radius: 8px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.challan-header {
  text-align: center;
  margin-bottom: 15px;
}

.school-name {
  font-size: 18px;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 2px;
}

.challan-details {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 15px;
  margin-bottom: 15px;
}

.info-row {
  font-size: 12px;
  margin-bottom: 4px;
}

.info-row span {
  font-weight: 600;
  border-bottom: 1px solid #e2e8f0;
  display: inline-block;
  min-width: 100px;
}

.fee-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 15px;
}

.fee-table th {
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  padding: 4px 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

.fee-table td {
  padding: 6px 8px;
  font-size: 12px;
  border: 1px solid #e2e8f0;
}

.total-row {
  font-weight: 800;
  background: #f1f5f9;
}

.signature-section {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  font-size: 11px;
}

.sig-line {
  width: 120px;
  border-top: 1px solid #000;
  margin-bottom: 5px;
}



/* Print Styles */
@media print {
  body {
    background: white;
  }
  header, .controls, .panel-tabs, #viewRecords {
    display: none !important;
  }
  #viewPreview {
    display: block !important;
  }
  main {
    display: block;
    height: auto;
  }
  .preview-container {
    padding: 0;
    background: white;
    display: block;
    overflow: visible;
  }
  .a4-page {
    width: 794px;
    height: 1123px !important;
    margin: 0;
    padding: 30px;
    box-shadow: none;
    transform: none !important;
    justify-content: flex-start;
  }
  .print-wrapper {
    height: 50% !important;
  }
  #schoolCopy {
    display: flex;
  }
  @page {
    size: A4;
    margin: 0;
  }
}
