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

:root {
    --primary-color: #000080;
    --primary-dark: #000060;
    --primary-light: #0000a0;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --bg-color: #f5f5f5;
    --text-color: #333;
    --border-radius: 12px;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Sarabun', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--bg-color) 0%, #e0e0e0 100%);
    color: var(--text-color);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--primary-color);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    color: white;
    transition: opacity 0.3s ease;
}

.loading-screen.hide {
    opacity: 0;
    pointer-events: none;
}

.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); }
}

/* Page Container */
.page {
    display: none;
    min-height: 100vh;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

.page.active {
    display: block;
}

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

/* Header */
.header {
    text-align: center;
    margin-bottom: 30px;
    position: relative;
}

.header h1 {
    color: var(--primary-color);
    font-size: 2em;
    font-weight: bold;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.header .subtitle {
    color: #666;
    font-size: 1.1em;
}

.back-btn {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 1em;
    transition: background 0.3s ease;
}

.back-btn:hover {
    background: var(--primary-dark);
}

/* Scanner Container */
.scanner-container {
    max-width: 500px;
    margin: 0 auto;
    background: white;
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

#qr-reader {
    width: 100%;
    border-radius: var(--border-radius);
}

#qr-reader video {
    width: 100% !important;
    height: auto !important;
    border-radius: var(--border-radius);
}

/* Info Box */
.info-box {
    max-width: 500px;
    margin: 20px auto;
    background: white;
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    text-align: center;
    border-left: 5px solid var(--primary-color);
}

.info-box p {
    font-size: 1.1em;
    color: #666;
}

/* Form Container */
.form-container {
    max-width: 600px;
    margin: 0 auto;
}

.checkpoint-info {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 25px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.checkpoint-info h2 {
    font-size: 1.5em;
    font-weight: bold;
    text-align: center;
}

/* Location Section */
.location-section {
    background: white;
    padding: 20px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.location-section h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 1.3em;
}

.location-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.location-item {
    padding: 15px;
    background: var(--bg-color);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
}

.location-item.full-width {
    grid-column: 1 / -1;
}

.location-item label {
    font-weight: bold;
    color: #666;
    margin-bottom: 5px;
    font-size: 0.9em;
}

.location-item span {
    color: var(--primary-color);
    font-size: 1.1em;
    font-weight: bold;
}

#distanceIcon {
    display: inline-block;
    margin-left: 10px;
    font-size: 1.5em;
}

/* Photo Section */
.photo-section {
    background: white;
    padding: 20px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.photo-section h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 1.3em;
}

.photo-preview {
    width: 100%;
    height: 300px;
    background: var(--bg-color);
    border-radius: var(--border-radius);
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 15px;
    overflow: hidden;
    border: 2px dashed #ccc;
}

.photo-preview img {
    max-width: 100%;
    max-height: 100%;
    border-radius: var(--border-radius);
}

.photo-preview p {
    color: #999;
    font-size: 1.1em;
}

/* Buttons */
.btn {
    width: 100%;
    padding: 15px;
    font-size: 1.2em;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(0, 0, 128, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 128, 0.4);
}

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

.btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
    box-shadow: none;
}

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

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

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

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: var(--border-radius);
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

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

.modal-content p {
    font-size: 1.2em;
    margin-bottom: 20px;
    color: var(--text-color);
}

.modal-content .btn {
    max-width: 200px;
    margin: 0 auto;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header h1 {
        font-size: 1.5em;
    }

    .location-grid {
        grid-template-columns: 1fr;
    }

    .back-btn {
        position: static;
        transform: none;
        margin-bottom: 15px;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .page {
        padding: 15px;
    }

    .header h1 {
        font-size: 1.3em;
    }

    .photo-preview {
        height: 250px;
    }

    .btn {
        padding: 12px;
        font-size: 1em;
    }
}

/* PWA Install Prompt */
.install-prompt {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary-color);
    color: white;
    padding: 15px 25px;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 20px rgba(0, 0, 128, 0.4);
    z-index: 9998;
    display: none;
    animation: slideUp 0.3s ease;
}

.install-prompt.show {
    display: block;
}

.install-prompt button {
    margin-left: 15px;
    padding: 8px 15px;
    background: white;
    color: var(--primary-color);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
}
