/* =============================================
   ระบบใบแจ้งหนี้โรงเรียน - Main Stylesheet
   ============================================= */

:root {
    --primary: #1a56db;
    --primary-dark: #1e429f;
    --secondary: #6b7280;
    --success: #059669;
    --danger: #dc2626;
    --warning: #d97706;
    --light: #f3f4f6;
    --dark: #1f2937;
    --white: #ffffff;
    --border: #e5e7eb;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --font-thai: 'Sarabun', 'Noto Sans Thai', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-thai);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: var(--dark);
}

/* Container */
.container {
    max-width: 900px;
    margin: 0 auto;
}

/* Card */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 20px;
}

.card-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    padding: 20px 24px;
    text-align: center;
}

.card-header h1 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 4px;
}

.card-header p {
    opacity: 0.9;
    font-size: 14px;
}

.card-body {
    padding: 24px;
}

/* School Header */
.school-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--border);
}

.school-logo {
    width: 80px;
    height: 80px;
    object-fit: contain;
}

.school-info h2 {
    font-size: 20px;
    color: var(--primary-dark);
}

/* Form Elements */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--dark);
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    font-size: 16px;
    font-family: inherit;
    border: 2px solid var(--border);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.1);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 500;
    font-family: inherit;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.4);
}

.btn-success {
    background: linear-gradient(135deg, var(--success) 0%, #047857 100%);
    color: var(--white);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.4);
}

.btn-secondary {
    background: var(--secondary);
    color: var(--white);
}

.btn-lg {
    padding: 16px 32px;
    font-size: 18px;
}

.btn-block {
    width: 100%;
}

/* Student Info Card */
.student-info {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 24px;
}

.student-info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.student-info-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.student-info-item .label {
    font-weight: 500;
    color: var(--secondary);
    min-width: 100px;
}

.student-info-item .value {
    font-weight: 600;
    color: var(--dark);
}

/* Fee Items Table */
.fee-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.fee-table th,
.fee-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.fee-table th {
    background: var(--light);
    font-weight: 600;
    color: var(--dark);
}

.fee-table tbody tr:hover {
    background: #fafafa;
}

.fee-table .amount {
    text-align: right;
    font-weight: 500;
}

.fee-table .checkbox-cell {
    width: 50px;
    text-align: center;
}

.fee-table input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* Total Amount */
.total-box {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-radius: 8px;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.total-box .label {
    font-size: 18px;
    font-weight: 500;
}

.total-box .amount {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary-dark);
}

/* Alert Messages */
.alert {
    padding: 16px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border-left: 4px solid #3b82f6;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border-left: 4px solid #22c55e;
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
    border-left: 4px solid #ef4444;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Loading Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .student-info-grid {
        grid-template-columns: 1fr;
    }

    .action-buttons {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
}

/* =============================================
   Print Invoice Styles
   ============================================= */
@media print {
    body {
        background: white;
        padding: 0;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .no-print {
        display: none !important;
    }
}

.invoice-page {
    background: white;
    width: 210mm;
    min-height: 148mm;
    margin: 0 auto;
    padding: 10mm;
    font-size: 11pt;
}

.invoice-section {
    border: 1px solid #333;
    padding: 8mm;
    margin-bottom: 5mm;
    page-break-inside: avoid;
}

.invoice-header {
    display: flex;
    align-items: flex-start;
    gap: 10mm;
    margin-bottom: 5mm;
    border-bottom: 1px solid #ccc;
    padding-bottom: 5mm;
}

.invoice-logo {
    width: 20mm;
    height: 20mm;
    object-fit: contain;
}

.invoice-title {
    flex: 1;
}

.invoice-title h1 {
    font-size: 14pt;
    font-weight: bold;
    margin-bottom: 2mm;
}

.invoice-title p {
    font-size: 10pt;
    color: #666;
}

.section-label {
    position: absolute;
    right: 8mm;
    top: 8mm;
    font-size: 9pt;
    color: #666;
    border: 1px solid #ccc;
    padding: 2mm 4mm;
}

.invoice-student-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2mm;
    margin-bottom: 5mm;
    font-size: 10pt;
}

.invoice-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 3mm;
}

.invoice-table th,
.invoice-table td {
    border: 1px solid #999;
    padding: 2mm 3mm;
    font-size: 10pt;
}

.invoice-table th {
    background: #f5f5f5;
    font-weight: bold;
}

.invoice-table .text-right {
    text-align: right;
}

.invoice-table .text-center {
    text-align: center;
}

.invoice-total {
    text-align: right;
    font-weight: bold;
    margin: 3mm 0;
}

.invoice-total-text {
    margin-bottom: 3mm;
}

.invoice-notes {
    font-size: 9pt;
    margin-top: 5mm;
    padding: 3mm;
    background: #f9f9f9;
    border: 1px solid #ddd;
}

.invoice-notes h4 {
    font-size: 10pt;
    margin-bottom: 2mm;
}

.invoice-notes ul {
    margin-left: 5mm;
}

/* Pay-In Slip Section */
.payin-slip {
    display: grid;
    grid-template-columns: 30mm 1fr;
    gap: 5mm;
    align-items: start;
}

.payin-qr {
    text-align: center;
}

.payin-qr img {
    width: 25mm;
    height: 25mm;
}

.payin-qr .bank-logo {
    width: 20mm;
    margin-top: 2mm;
}

.payin-details {
    font-size: 10pt;
}

.payin-details table {
    width: 100%;
}

.payin-details td {
    padding: 1mm 2mm;
}

.payin-details .label {
    width: 40%;
    color: #666;
}

.payin-amount {
    font-size: 14pt;
    font-weight: bold;
    margin: 3mm 0;
}

.payin-barcode {
    text-align: center;
    margin-top: 5mm;
    padding-top: 3mm;
    border-top: 1px dashed #ccc;
}

.payin-barcode img {
    height: 12mm;
}

.payin-barcode p {
    font-size: 8pt;
    font-family: monospace;
    margin-top: 1mm;
}

.payin-footer {
    font-size: 8pt;
    color: #666;
    text-align: center;
    margin-top: 3mm;
    padding-top: 3mm;
    border-top: 1px solid #ddd;
}