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

:root {
    --primary-color: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #818cf8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/*body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    padding: 2rem 1rem;
}*/
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;

    background-image:
        linear-gradient(
            rgba(200, 230, 255, 0.75),   /* ฟ้าอ่อน โปร่ง */
            rgba(200, 230, 255, 0.75)
        ),
        url('img/bghospital.jpg');

    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;

    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    padding: 2rem 1rem;
}


.page-container {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 2rem;
    align-items: start;
}

.container {
    background: var(--surface);
    border-radius: 16px;
    box-shadow: var(--shadow-xl);
    overflow: hidden;
}

/* Header */
.header {
/*    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);*/
background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
    color: white;
    padding: 3rem 2rem;
    text-align: center;
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.header p {
    font-size: 1.1rem;
    opacity: 0.95;
}

/* Form Sections */
form {
    padding: 2rem;
}

.section {
    margin-bottom: 2.5rem;
    padding: 1.5rem;
    background: var(--background);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.section h2 {
    color: var(--text-primary);
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Form Groups */
.form-group {
    margin-bottom: 1.5rem;
}


.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.required {
    color: var(--danger-color);
    margin-left: 2px;
}

/* Input Styles */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="date"],
input[type="number"],
input[type="password"],
select,
textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.3s ease;
    background: var(--surface);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

input:invalid:focus,
select:invalid:focus,
textarea:invalid:focus {
    border-color: var(--danger-color);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

textarea {
    resize: vertical;
}

/* File Upload Styles */
.file-upload-wrapper {
    position: relative;
}

.file-input {
    opacity: 0;
    position: absolute;
    z-index: -1;
}

.file-label {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--surface);
}

.file-label:hover {
    border-color: var(--primary-color);
    background: rgba(79, 70, 229, 0.05);
}

.file-icon {
    font-size: 2rem;
}

.file-text {
    color: var(--text-secondary);
    font-weight: 500;
}

.file-input:focus + .file-label {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* File Preview */
.file-preview {
    margin-top: 1rem;
}

.preview-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 0.5rem;
}

.preview-image {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    border: 2px solid var(--border-color);
}

.preview-info {
    flex: 1;
}

.preview-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.preview-size {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.preview-remove {
    background: var(--danger-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s ease;
}

.preview-remove:hover {
    background: #dc2626;
    transform: scale(1.05);
}

/* Help Text */
.help-text {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Checkbox */
.checkbox-group {
    margin-top: 1.5rem;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
    cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.link {
    color: var(--primary-color);
    text-decoration: none;
    margin: 0 0.25rem;
}

.link:hover {
    text-decoration: underline;
}

/* Buttons */
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 2px solid var(--border-color);
}

.btn {
    padding: 0.875rem 2rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--background);
    border-color: var(--text-secondary);
}

.btn-icon {
    font-size: 1.2rem;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    z-index: 9999;
}

.loading-overlay.active {
    display: flex;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-overlay p {
    color: white;
    margin-top: 1rem;
    font-size: 1.1rem;
}

/* Success Message */
.success-message {
    background: var(--success-color);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    display: none;
}

.success-message.show {
    display: block;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Error Message */
.error-message {
    background: var(--danger-color);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    display: none;
}

.error-message.show {
    display: block;
    animation: slideDown 0.3s ease;
}

/* Status Check Container */
.status-container {
    background: var(--surface);
    border-radius: 16px;
    box-shadow: var(--shadow-xl);
    position: sticky;
    top: 2rem;
}

.status-header {
/*    background: linear-gradient(135deg, #10b981 0%, #059669 100%);*/
    background: linear-gradient(135deg, #facc15 0%, #ca8a04 100%);
    color: white;
    padding: 2rem 1.5rem;
    text-align: center;
    border-radius: 16px 16px 0 0;
}

.status-header h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    border: none;
    padding: 0;
}

.status-header p {
    font-size: 0.95rem;
    opacity: 0.95;
    margin: 0;
}

.status-form {
    padding: 2rem 1.5rem;
}

.divider {
    text-align: center;
    margin: 1.5rem 0;
    position: relative;
}

.divider::before,
.divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background: var(--border-color);
}

.divider::before {
    left: 0;
}

.divider::after {
    right: 0;
}

.divider span {
    background: var(--surface);
    padding: 0 1rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.btn-search {
    width: 100%;
    justify-content: center;
/*    background: linear-gradient(135deg, #10b981 0%, #059669 100%);*/
    background: linear-gradient(135deg, #facc15 0%, #ca8a04 100%);
}

.btn-search:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.status-result {
    margin-top: 2rem;
}

.status-card {
    background: var(--background);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    animation: slideDown 0.3s ease;
}

.status-badge {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.status-pending {
    background: #fef3c7;
    color: #92400e;
}

.status-reviewing {
    background: #dbeafe;
    color: #1e40af;
}

.status-approved {
    background: #d1fae5;
    color: #065f46;
}

.status-rejected {
    background: #fee2e2;
    color: #991b1b;
}

.status-info {
    margin-top: 1rem;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    font-weight: 600;
    color: var(--text-secondary);
}

.info-value {
    color: var(--text-primary);
    text-align: right;
}

.btn-view-card {
    width: 100%;
    margin-top: 1rem;
    justify-content: center;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    animation: fadeIn 0.3s ease;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background: var(--surface);
    border-radius: 16px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    text-align: center;
    padding: 2rem;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border-radius: 16px 16px 0 0;
}

.success-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    background: white;
    color: #10b981;
    border-radius: 50%;
    font-size: 3rem;
    font-weight: bold;
    margin-bottom: 1rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.75rem;
}

.modal-body {
    padding: 2rem;
}

.success-info {
    text-align: center;
    margin-bottom: 2rem;
}

.success-info .success-message {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    background: none;
    padding: 0;
    display: block;
}

.application-number {
    background: var(--background);
    padding: 1.5rem;
    border-radius: 12px;
    border: 2px dashed var(--primary-color);
    margin: 1rem 0;
}

.application-number label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.app-id {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    font-family: 'Courier New', monospace;
}

.note {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 1rem;
}

.modal-footer {
    padding: 1.5rem 2rem;
    background: var(--background);
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-print {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
}

.btn-print:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-download {
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
    color: white;
}

.btn-download:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* ID Card Styles */
/*.id-card-preview {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    border-radius: 16px;
    padding: 2rem;
    color: white;
    box-shadow: var(--shadow-xl);
    position: relative;
    overflow: hidden;
}*/
.id-card-preview {
    background: linear-gradient(135deg, #bae6fd 0%, #93c5fd 50%, #bfdbfe 100%);
    border-radius: 16px;
    padding: 2rem;
    color: #0f172a; /* เปลี่ยนเป็นน้ำเงินเข้ม อ่านง่าย */
    box-shadow: var(--shadow-xl);
    position: relative;
    overflow: hidden;
}


.id-card-preview::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    animation: rotate 20s linear infinite;
}

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

.id-card-content {
    position: relative;
    z-index: 1;
}

/*.id-card-header {
    text-align: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid rgba(255,255,255,0.3);
}

.id-card-logo {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.id-card-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
}

.id-card-subtitle {
    font-size: 0.9rem;
    opacity: 0.9;
    margin: 0.25rem 0 0 0;
}*/

.id-card-header {
    display: flex;
    align-items: center;   /* จัดให้อยู่กึ่งกลางแนวตั้ง */
    gap: 12px;             /* ระยะห่างรูปกับข้อความ */
}


.id-card-logo img {
    width: 50px;
    height: 60px;
    border-radius: 50%;
    object-fit: contain;
}

.id-card-title {
    margin: 0;
}

.id-card-subtitle {
    margin: 0;
    font-size: 14px;
/*    color: #666;*/
}


.id-card-photo {
    text-align: center;
    margin: 1.5rem 0;
}

.id-card-photo img {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 4px solid white;
    object-fit: cover;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.id-card-photo-placeholder {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 4px solid white;
    background: rgba(255,255,255,0.2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
}

.id-card-info {
    margin-top: 1.5rem;
}

.id-info-row {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.2);
}

.id-info-row:last-child {
    border-bottom: none;
}

.id-info-label {
    font-size: 0.85rem;
    opacity: 0.8;
}

.id-info-value {
    font-weight: 600;
    text-align: right;
}

.id-card-footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 2px solid rgba(255,255,255,0.3);
}

.id-card-number {
    font-family: 'Courier New', monospace;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 1px;
}

.id-card-date {
    font-size: 0.8rem;
    opacity: 0.8;
    margin-top: 0.5rem;
}

/* Printable ID Card */
.printable-id-card {
    display: none;
}

@media print {
    body * {
        visibility: hidden;
    }
    
    .printable-id-card,
    .printable-id-card * {
        visibility: visible;
    }
    
    .printable-id-card {
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        width: 85.6mm;
        height: 53.98mm;
    }
}

/* Responsive */
@media (max-width: 768px) {
    body {
        padding: 1rem 0.5rem;
    }

    .page-container {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .status-container {
        order: 2;
    }

    .header {
        padding: 2rem 1rem;
    }

    .header h1 {
        font-size: 1.75rem;
    }

    .header p {
        font-size: 0.95rem;
    }

    form {
        padding: 1rem;
    }

    .section {
        padding: 1rem;
    }

    .section h2 {
        font-size: 1.25rem;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .form-actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.5rem;
    }

    .file-label {
        flex-direction: column;
        text-align: center;
        padding: 1rem;
    }

    .preview-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .preview-remove {
        width: 100%;
    }
}
