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

body {
    font-family: 'Prompt', Arial, sans-serif;
    line-height: 1.6;
    color: #374151;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    min-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
    color: white;
    padding: 30px 20px;
    text-align: center;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.header h2 {
    font-size: 1.1rem;
    font-weight: 400;
    opacity: 0.9;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 40px 30px;
}

.form-container {
    width: 100%;
}

.form-header {
    text-align: center;
    margin-bottom: 30px;
}

.form-header h3 {
    font-size: 1.4rem;
    font-weight: 600;
    color: #1e40af;
    margin-bottom: 8px;
}

.form-header p {
    color: #6b7280;
    font-size: 0.9rem;
}

/* Form Styles */
.citizen-form {
    margin-bottom: 30px;
}

.form-group {
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #374151;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-group input.error,
.form-group select.error,
.form-group textarea.error {
    border-color: #ef4444;
}

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

.form-row {
    display: flex;
    gap: 15px;
}

.form-row .form-group {
    flex: 1;
}

/* Representative Fields */
.representative-fields {
    background: #f8fafc;
    padding: 20px;
    border-radius: 8px;
    margin-top: 15px;
    border-left: 4px solid #3b82f6;
}

.representative-fields h4 {
    color: #1e40af;
    margin-bottom: 15px;
    font-size: 1.1rem;
}

/* License Plate Field */
.license-plate-field {
    background: #f0f9ff;
    padding: 15px;
    border-radius: 8px;
    margin-top: 10px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    font-family: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 48px;
    gap: 8px;
}

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

.btn-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #1e40af 100%);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(59, 130, 246, 0.3);
}

.btn-secondary {
    background: #6b7280;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #4b5563;
    transform: translateY(-2px);
}

.btn-outline {
    background: transparent;
    color: #3b82f6;
    border: 2px solid #3b82f6;
}

.btn-outline:hover:not(:disabled) {
    background: #3b82f6;
    color: white;
}

.btn-success {
    background: #10b981;
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #059669;
    transform: translateY(-2px);
}

.btn-danger {
    background: #ef4444;
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
    transform: translateY(-2px);
}

/* Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Messages */
.message {
    padding: 15px;
    border-radius: 8px;
    margin: 20px 0;
    font-weight: 500;
}

.message.success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.message.error {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.message.warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fed7aa;
}

.message.info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* Info Box */
.info-box {
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 25px;
    margin: 20px 0;
}

.info-box h4 {
    color: #1e40af;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.info-box .detail-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #e2e8f0;
}

.info-box .detail-item:last-child {
    border-bottom: none;
}

.info-box .detail-label {
    font-weight: 500;
    color: #4b5563;
}

.info-box .detail-value {
    color: #1f2937;
    text-align: right;
}

.action-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

/* Registration Success */
.registration-success {
    text-align: center;
    padding: 30px;
    background: #f0f9ff;
    border-radius: 12px;
    margin: 20px 0;
}

.registration-success h3 {
    color: #1e40af;
    margin-bottom: 15px;
}

/* QR Code Container - แก้ไขสำหรับ Mobile Responsive */
/* QR Code Container - Override ทุก styling เดิม */
.qr-code-container {
    margin: 20px 0 !important;
    padding: 25px !important;
    background: white !important;
    border-radius: 12px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
    text-align: center !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
}

.qr-code-container h4 {
    margin-bottom: 20px !important;
    color: #1e40af !important;
    font-size: 1.2rem !important;
    font-weight: 600 !important;
}

.qr-code-container img {
    max-width: 200px !important;
    width: 90% !important;
    height: auto !important;
    border: 3px solid #3b82f6 !important; /* กรอบสีฟ้าหนา */
    border-radius: 12px !important;
    padding: 12px !important;
    background: white !important;
    display: block !important;
    margin: 0 auto 25px auto !important; /* เพิ่มระยะห่างจากข้อความ */
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.2) !important;
    -webkit-transform: translateZ(0) !important;
    transform: translateZ(0) !important;
}

.qr-code-container p {
    margin: 0 !important;
    color: #4b5563 !important;
    font-size: 0.95rem !important;
    line-height: 1.6 !important;
    font-weight: 500 !important;
    padding: 0 15px !important;
}

/* Mobile Responsive - ชัดเจน */
@media (max-width: 768px) {
    .qr-code-container {
        margin: 20px 0 !important;
        padding: 30px 20px !important;
    }
    
    .qr-code-container img {
        max-width: 180px !important;
        width: 85% !important;
        border: 3px solid #3b82f6 !important;
        padding: 10px !important;
        margin-bottom: 25px !important;
    }
    
    .qr-code-container p {
        font-size: 1rem !important;
        padding: 0 10px !important;
    }
}

@media (max-width: 480px) {
    .qr-code-container {
        margin: 20px -5px !important;
        padding: 25px 15px !important;
    }
    
    .qr-code-container img {
        max-width: 160px !important;
        width: 80% !important;
        min-width: 150px !important;
        border: 3px solid #3b82f6 !important;
        border-radius: 10px !important;
        padding: 8px !important;
        margin-bottom: 30px !important;
    }
    
    .qr-code-container p {
        font-size: 0.95rem !important;
        line-height: 1.7 !important;
        color: #374151 !important;
        font-weight: 500 !important;
        padding: 0 10px !important;
    }
}
.important-links {
    display: grid;
    gap: 15px;
    margin: 20px 0;
}

.link-item {
    display: flex;
    align-items: center;
    padding: 15px;
    background: white;
    border-radius: 8px;
    border: 2px solid #e5e7eb;
    text-decoration: none;
    color: #374151;
    transition: all 0.3s ease;
}

.link-item:hover {
    border-color: #3b82f6;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.link-item .icon {
    width: 24px;
    height: 24px;
    margin-right: 12px;
    color: #3b82f6;
}

/* Footer */
.footer {
    background: #f8fafc;
    padding: 25px 30px;
    border-top: 1px solid #e2e8f0;
}

.contact-info {
    text-align: center;
}

.contact-info h4 {
    color: #1e40af;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.contact-info p {
    margin: 5px 0;
    color: #4b5563;
}

/* Event Info */
.event-info {
    background: #1e40af;
    color: white;
    padding: 20px 30px;
    text-align: center;
}

.event-details h4 {
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.event-details p {
    margin: 5px 0;
    opacity: 0.9;
}

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

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid transparent;
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

/* Calendar Button */
.add-calendar-btn {
    background: #059669;
    color: white;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 10px 5px;
}

.add-calendar-btn:hover {
    background: #047857;
    transform: translateY(-2px);
}

.calendar-section {
    margin: 20px 0;
    padding: 20px;
    background: #f0f9ff;
    border-radius: 8px;
    text-align: center;
}

.calendar-section h4 {
    color: #1e40af;
    margin-bottom: 15px;
}

.edit-info {
    background: #fef3c7;
    padding: 15px;
    border-radius: 8px;
    margin: 20px 0;
    text-align: center;
}

.edit-info p {
    margin: 0;
    color: #92400e;
    font-size: 0.9rem;
}

/* Progress Bar */
.progress-bar {
    background: #e5e7eb;
    height: 6px;
    border-radius: 3px;
    margin: 20px 0;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(135deg, #3b82f6 0%, #1e40af 100%);
    transition: width 0.3s ease;
    border-radius: 3px;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .container {
        min-height: calc(100vh - 20px);
        border-radius: 12px;
    }
    
    .main-content {
        padding: 30px 20px;
    }
    
    .header {
        padding: 25px 20px;
    }
    
    .header h1 {
        font-size: 1.3rem;
    }
    
    .header h2 {
        font-size: 1rem;
    }
    
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .action-buttons .btn {
        width: 100%;
    }
    
    .footer,
    .event-info {
        padding: 20px;
    }
    
    /* QR Code Mobile Responsive */
    .qr-code-container {
        margin: 15px -10px;
        padding: 25px 20px;
        border-radius: 12px;
    }
    
    .qr-code-container h4 {
        font-size: 1.2rem;
        margin-bottom: 20px;
    }
    
    .qr-code-container img {
        max-width: 180px;
        width: 90%;
        margin-bottom: 25px;
        border: 2px solid #3b82f6;
        border-radius: 10px;
        padding: 8px;
        background: white;
    }
    
    .qr-code-container p {
        font-size: 1rem;
        padding: 0 10px;
        max-width: 300px;
        margin: 0 auto;
    }
    
    .registration-success {
        padding: 25px 15px;
        margin: 15px 0;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 20px 15px;
    }
    
    .info-box {
        padding: 20px;
    }
    
    .detail-item {
        flex-direction: column;
        gap: 5px;
    }
    
    .detail-value {
        text-align: left !important;
        font-weight: 500;
    }
    
    /* QR Code สำหรับ Mobile ขนาดเล็ก */
    .qr-code-container {
        margin: 15px -15px;
        padding: 30px 15px;
        border-radius: 8px;
    }
    
    .qr-code-container h4 {
        font-size: 1.1rem;
        margin-bottom: 20px;
        text-align: center;
    }
    
    .qr-code-container img {
        max-width: 160px;
        width: 80%;
        min-width: 150px;
        margin-bottom: 25px;
        border: 2px solid #3b82f6;
        border-radius: 8px;
        padding: 8px;
        background: white;
        -webkit-user-select: none;
        -moz-user-select: none;
        user-select: none;
        pointer-events: none;
    }
    
    .qr-code-container p {
        font-size: 0.95rem;
        line-height: 1.6;
        color: #4b5563;
        font-weight: 500;
        padding: 0 5px;
    }
    
    .registration-success {
        padding: 25px 10px;
        margin: 10px 0;
    }
    
    .registration-success h3 {
        font-size: 1.3rem;
        margin-bottom: 15px;
    }
    
    .registration-success p {
        font-size: 1rem;
        margin-bottom: 20px;
    }
}

/* เพิ่ม styling พิเศษสำหรับ QR Code ใน View Mode */
#viewMode .qr-code-container {
    margin: 25px 0;
}

#viewMode .qr-code-container img {
    border: 2px solid #3b82f6;
    padding: 8px;
}

@media (max-width: 480px) {
    #viewMode .qr-code-container img {
        border: 2px solid #3b82f6;
        padding: 8px;
    }
}

/* แก้ไขปัญหา Container ใน Chrome Mobile */
@supports (-webkit-appearance: none) {
    @media (max-width: 480px) {
        .qr-code-container {
            -webkit-transform: translateZ(0);
            transform: translateZ(0);
        }
    }
}

/* Animation */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

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

.slide-up {
    animation: slideUp 0.3s ease-out;
}

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