/* ========================================
   สถาบันพระปกเกล้า - Official Theme
   King Prajadhipok's Institute
   ======================================== */

:root {
    /* สีหลักจากโลโก้สถาบันพระปกเกล้า */
    --kpi-green: #0f5132;           /* เขียวเข้ม - สีหลัก */
    --kpi-green-light: #198754;     /* เขียวสว่าง */
    --kpi-gold: #b8922a;            /* ทอง - สีเสริม */
    --kpi-gold-light: #d4af37;      /* ทองสว่าง */
    
    /* สีเสริม */
    --white: #ffffff;
    --gray-50: #f8f9fa;
    --gray-100: #f1f3f5;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-600: #6c757d;
    --gray-700: #495057;
    --gray-800: #343a40;
    --gray-900: #212529;
    
    /* สีสถานะ */
    --success: #198754;
    --warning: #ffc107;
    --danger: #dc3545;
    --info: #0dcaf0;
    
    /* เงา */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    
    /* Border radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

/* ========================================
   Base Styles
   ======================================== */

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

body {
    font-family: 'Sarabun', 'Noto Sans Thai', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
    padding: 1.5rem 0;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* ========================================
   Header Section
   ======================================== */

.header-section {
    background: var(--white);
    padding: 2rem;
    margin-bottom: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    text-align: center;
    border-top: 4px solid var(--kpi-green);
}

.logo-container {
    display: block;
    margin-bottom: 1.5rem;
}

.org-logo {
    max-width: 120px;
    max-height: 120px;
    object-fit: contain;
    margin: 0 auto;
    display: block;
}

.main-title {
    font-size: 1.875rem;
    font-weight: 600;
    color: var(--kpi-green);
    margin-bottom: 0.5rem;
    letter-spacing: -0.025em;
}

.subtitle {
    font-size: 1.125rem;
    color: var(--gray-600);
    margin: 0;
    font-weight: 400;
}

/* ========================================
   Consent Card
   ======================================== */

.consent-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    margin-bottom: 1.5rem;
    border: 1px solid var(--gray-200);
}

.consent-header {
    background: linear-gradient(135deg, var(--kpi-green) 0%, var(--kpi-green-light) 100%);
    color: var(--white);
    padding: 1.75rem 2rem;
    border-bottom: 3px solid var(--kpi-gold);
}

.consent-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
    text-align: center;
    line-height: 1.4;
}

.consent-body {
    padding: 2rem;
}

.consent-content {
    margin-bottom: 1.5rem;
}

.consent-intro {
    background: var(--gray-50);
    padding: 1.25rem;
    border-left: 4px solid var(--kpi-green);
    border-radius: var(--radius-sm);
    margin-bottom: 1.5rem;
    font-size: 1rem;
    line-height: 1.8;
    color: var(--gray-700);
}

/* Consent Details */
.consent-details {
    margin-top: 1.5rem;
}

.section {
    margin-bottom: 1.25rem;
    padding: 1.25rem;
    background: var(--gray-50);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--kpi-gold);
}

.section-number {
    display: inline-block;
    min-width: 32px;
    height: 32px;
    line-height: 32px;
    text-align: center;
    background: var(--kpi-green);
    color: var(--white);
    border-radius: 50%;
    font-weight: 600;
    margin-right: 0.75rem;
    font-size: 1rem;
}

.section-content {
    color: var(--gray-700);
    font-size: 0.95rem;
    line-height: 1.7;
    margin-left: 2.5rem;
}

.subsection {
    margin-top: 0.75rem;
    padding-left: 1rem;
    border-left: 2px solid var(--gray-300);
}

.subsection-title {
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.highlight {
    background: linear-gradient(120deg, var(--kpi-gold) 0%, var(--kpi-gold-light) 100%);
    color: var(--white);
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    white-space: nowrap;
}

/* ========================================
   Consent Checkbox
   ======================================== */

.consent-checkbox-section {
    background: #f0f9ff;
    border: 2px solid var(--kpi-green);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin: 1.5rem 0;
}

.form-check {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.form-check-input {
    width: 1.5rem;
    height: 1.5rem;
    margin-top: 0.125rem;
    cursor: pointer;
    border: 2px solid var(--kpi-green);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.form-check-input:checked {
    background-color: var(--kpi-green);
    border-color: var(--kpi-green);
}

.form-check-input:focus {
    border-color: var(--kpi-green);
    box-shadow: 0 0 0 0.2rem rgba(15, 81, 50, 0.25);
}

.consent-label {
    font-size: 1rem;
    color: var(--gray-800);
    cursor: pointer;
    line-height: 1.6;
    user-select: none;
}

.consent-label strong {
    color: var(--kpi-green);
}

/* ========================================
   Buttons
   ======================================== */

.consent-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--gray-200);
}

.btn {
    padding: 0.75rem 2rem;
    font-size: 1rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    border: 2px solid transparent;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

.btn-primary,
.btn-lg {
    background: var(--kpi-green);
    border-color: var(--kpi-green);
    color: var(--white);
}

.btn-primary:hover:not(:disabled) {
    background: var(--kpi-green-light);
    border-color: var(--kpi-green-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

.btn-outline-secondary {
    border-color: var(--gray-300);
    color: var(--gray-700);
    background: var(--white);
}

.btn-outline-secondary:hover {
    background: var(--gray-50);
    border-color: var(--gray-600);
}

/* ========================================
   Application Form
   ======================================== */

.form-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    margin-bottom: 1.5rem;
    overflow: hidden;
    border: 1px solid var(--gray-200);
}

.form-header {
    background: linear-gradient(135deg, var(--kpi-green) 0%, var(--kpi-green-light) 100%);
    color: var(--white);
    padding: 1.5rem 2rem;
    border-bottom: 3px solid var(--kpi-gold);
}

.form-header h3 {
    font-size: 1.375rem;
    font-weight: 600;
    margin: 0;
}

.form-body {
    padding: 2rem;
}

.form-section {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--gray-200);
}

.form-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.section-title {
    color: var(--kpi-green);
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--kpi-gold);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-title::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 1.25rem;
    background: var(--kpi-green);
    border-radius: 2px;
}

/* Form Controls */
.form-label {
    font-weight: 500;
    color: var(--gray-800);
    margin-bottom: 0.5rem;
    display: block;
    font-size: 0.95rem;
}

.form-label.required::after {
    content: ' *';
    color: var(--danger);
}

.form-control,
.form-select {
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    padding: 0.625rem 0.875rem;
    font-size: 1rem;
    transition: all 0.2s ease;
    background: var(--white);
    width: 100%;
}

/* สำหรับ Chrome, Safari, Edge, Opera */
.no-spin::-webkit-outer-spin-button,
.no-spin::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}


.form-control:focus,
.form-select:focus {
    border-color: var(--kpi-green);
    box-shadow: 0 0 0 0.2rem rgba(15, 81, 50, 0.15);
    outline: none;
}

.form-control::placeholder {
    color: var(--gray-600);
}

.form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%230f5132' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px 12px;
    cursor: pointer;
}

.form-text {
    color: var(--gray-600);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* File Upload */
.file-upload-area {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    text-align: center;
    transition: all 0.2s ease;
    background: var(--gray-50);
}

.file-upload-area:hover {
    border-color: var(--kpi-green);
    background: #f0f9ff;
}

.file-upload-area input[type="file"] {
    display: none;
}

.file-upload-label {
    cursor: pointer;
    color: var(--kpi-green);
    font-weight: 500;
}

.file-upload-label:hover {
    color: var(--kpi-green-light);
}

/* Photo Preview */
.photo-preview {
    margin-top: 1rem;
    text-align: center;
}

.photo-preview img {
    max-width: 150px;
    max-height: 200px;
    border: 3px solid var(--gray-300);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

/* Progress Bar */
.progress-bar-container {
    background: var(--white);
    padding: 1.25rem 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: 1.5rem;
    border: 1px solid var(--gray-200);
}

.progress {
    height: 28px;
    border-radius: 14px;
    background: var(--gray-200);
    overflow: hidden;
}

.progress-bar {
    background: linear-gradient(90deg, var(--kpi-green) 0%, var(--kpi-green-light) 100%);
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: width 0.3s ease;
    color: var(--white);
    font-size: 0.875rem;
}

/* Navigation Buttons */
.form-navigation {
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--gray-200);
}

.btn-nav {
    flex: 1;
    max-width: 200px;
}

/* Alert Messages */
.alert {
    border-radius: var(--radius-md);
    border: none;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border-left: 4px solid var(--info);
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
    border-left: 4px solid var(--warning);
}

.alert-danger {
    background: #f8d7da;
    color: #721c24;
    border-left: 4px solid var(--danger);
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border-left: 4px solid var(--success);
}

/* Hidden Elements */
.hidden {
    display: none !important;
}

/* Same Address Checkbox */
.same-address-check {
    background: var(--gray-50);
    padding: 1rem;
    border-radius: var(--radius-sm);
    margin: 1rem 0;
    border-left: 4px solid var(--kpi-green);
}

/* Footer */
.footer-section {
    text-align: center;
    padding: 1.5rem;
    margin-top: 2rem;
    color: var(--gray-600);
    font-size: 0.875rem;
}

.footer-section p {
    margin: 0.25rem 0;
}

/* ========================================
   Loading Spinner
   ======================================== */

.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.spinner-border {
    width: 3rem;
    height: 3rem;
    border: 4px solid var(--gray-300);
    border-top-color: var(--kpi-green);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.spinner-text {
    margin-top: 1rem;
    color: var(--kpi-green);
    font-weight: 500;
}

/* ========================================
   Responsive Design
   ======================================== */

@media (max-width: 768px) {
    body {
        padding: 1rem 0;
    }

    .container {
        padding: 0 0.75rem;
    }

    .header-section {
        padding: 1.5rem;
        margin-bottom: 1rem;
    }

    .main-title {
        font-size: 1.5rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .consent-header h2,
    .form-header h3 {
        font-size: 1.25rem;
    }

    .consent-body,
    .form-body {
        padding: 1.5rem;
    }

    .consent-actions,
    .form-navigation {
        flex-direction: column;
    }

    .btn-nav {
        max-width: 100%;
    }

    .btn {
        width: 100%;
    }

    .section-content {
        margin-left: 0;
        margin-top: 0.75rem;
    }
}

@media (max-width: 480px) {
    .org-logo {
        max-width: 80px;
        max-height: 80px;
    }

    .main-title {
        font-size: 1.25rem;
    }

    .consent-body,
    .form-body {
        padding: 1.25rem;
    }
}

/* ========================================
   Print Styles
   ======================================== */

@media print {
    body {
        background: white;
        padding: 0;
    }

    .consent-card,
    .form-card {
        box-shadow: none;
        border: 1px solid var(--gray-300);
    }

    .btn,
    .form-navigation,
    .progress-bar-container {
        display: none;
    }

    .consent-header,
    .form-header {
        background: var(--kpi-green) !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* ========================================
   Additional Utilities
   ======================================== */

.text-kpi-green {
    color: var(--kpi-green);
}

.text-kpi-gold {
    color: var(--kpi-gold);
}

.bg-kpi-green {
    background-color: var(--kpi-green);
}

.bg-kpi-gold {
    background-color: var(--kpi-gold);
}

.border-kpi-green {
    border-color: var(--kpi-green);
}

.border-kpi-gold {
    border-color: var(--kpi-gold);
}

/* เพิ่มใน style.css */
input[type="number"]::placeholder,
input[type="text"]::placeholder {
    color: #999;
    font-style: italic;
}

/* แสดงข้อความช่วยเหลือ */
.form-help-text {
    font-size: 0.875rem;
    color: #6c757d;
    margin-top: 0.25rem;
    font-style: italic;
}