/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f7fa;
    color: #333;
    line-height: 1.6;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.container {
    max-width: 100%;
    height: 100%;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

/* Header styles */
header {
    display: flex;
    align-items: center;
    padding-bottom: 20px;
    border-bottom: 1px solid #e1e4e8;
    position: relative;
}

header h1 {
    font-size: 28px;
    color: #2c3e50;
    text-align: center;
    width: 100%;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
}

.status-container {
    display: flex;
    align-items: center;
}

.settings-button {
    background: none;
    border: none;
    font-size: 20px;
    color: #2c3e50;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s;
}

.settings-button:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 8px;
}

.online {
    background-color: #4caf50;
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.6);
}

.offline {
    background-color: #f44336;
    box-shadow: 0 0 8px rgba(244, 67, 54, 0.6);
}

.syncing {
    background-color: #ff9800;
    box-shadow: 0 0 8px rgba(255, 152, 0, 0.6);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
    100% {
        opacity: 1;
    }
}

/* Main content styles */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 40px 0;
}

.qr-container {
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    padding: 30px;
    text-align: center;
    margin: 0 auto 40px auto;
    max-width: 90%;
    width: min(1000px, 95vw);
    overflow: hidden; /* ensure inner content doesn't spill outside rounded corners */
}

#qrcode {
    margin: 0 auto;
    padding: 0; /* remove padding to avoid width overflow when we set intrinsic size */
    background-color: transparent; /* let container's background show, avoids visible edge */
    display: block;
    max-width: calc(100% - 8px); /* extra guard for subpixel/DPR rounding */
    height: auto;
    max-height: 75vh;
}

#qrcode img {
    display: block;
    margin: 0 auto;
    max-width: 100%;
    height: auto;
}

.qr-info {
    margin-top: 20px;
    text-align: center;
    color: #7f8c8d;
}

.server-clock {
    margin-top: 10px;
    font-size: 28px;
    line-height: 1.2;
    font-weight: 700;
    letter-spacing: 0.6px;
    color: #2c3e50;
}

#qr-expiry {
    margin-top: 10px;
    font-weight: bold;
    color: #e74c3c;
}

/* Hide the secondary clock to avoid duplication; keep server clock inside QR info */
.time-container { display: none; }

.current-time h2 {
    font-size: 48px;
    font-weight: 300;
    color: #2c3e50;
}

.current-time p {
    font-size: 18px;
    color: #7f8c8d;
}

/* Footer styles */
footer {
    text-align: center;
    padding: 20px 0;
    color: #95a5a6;
    font-size: 14px;
    border-top: 1px solid #e1e4e8;
}

/* Responsive styles */
@media (max-width: 768px) {
    header h1 {
        font-size: 24px;
    }
    
    .current-time h2 {
        font-size: 36px;
    }
    
    .qr-container {
        padding: 20px;
    }
    .server-clock {
        font-size: 24px;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 20px;
    }
    
    .current-time h2 {
        font-size: 30px;
    }
    
    .qr-container {
        padding: 15px;
    }
    .server-clock {
        font-size: 22px;
    }
}

/* Fullscreen mode styles */
.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #f5f7fa;
    z-index: 9999;
}

/* Enhanced fullscreen styles */
body.is-fullscreen {
    background-color: #f5f7fa;
    overflow: hidden;
}

body.is-fullscreen .container {
    height: 100vh;
    width: 100vw;
    max-width: 100%;
    padding: 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

body.is-fullscreen .qr-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin: 0 auto;
    max-width: 90%;
}

body.is-fullscreen #qrcode canvas {
    max-width: 100%;
    height: auto;
    max-height: 60vh;
}

/* Warning message styles */
.wake-lock-warning,
.fullscreen-warning {
    position: fixed;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(255, 152, 0, 0.9);
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    font-size: 14px;
    z-index: 10000;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    animation: fadeOut 5s forwards;
    animation-delay: 10s;
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; visibility: hidden; }
}

/* QR error message */
.qr-error {
    color: #e74c3c;
    font-weight: bold;
    padding: 20px;
    text-align: center;
    border: 2px solid #e74c3c;
    border-radius: 5px;
    margin: 20px auto;
    background-color: #fef5f5;
}

/* Loading spinner */
.loading-spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border-left-color: #09f;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

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

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: #fefefe;
    margin: 10% auto;
    padding: 0;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    width: 80%;
    max-width: 600px;
    animation: modalFadeIn 0.3s;
}

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

.modal-header {
    padding: 15px 20px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
    color: #2c3e50;
}

.close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #333;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 15px 20px;
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.settings-section {
    margin-bottom: 20px;
}

.settings-section h3 {
    margin-bottom: 15px;
    font-size: 18px;
    color: #2c3e50;
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 16px;
}

.form-group input[type="checkbox"] {
    margin-right: 5px;
}

.hidden {
    display: none;
}

.btn {
    padding: 8px 16px;
    border-radius: 4px;
    border: none;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.primary {
    background-color: #007bff;
    color: white;
}

.primary:hover {
    background-color: #0069d9;
}

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

.secondary:hover {
    background-color: #5a6268;
}

/* Expected location display */
.expected-location {
    margin-top: 10px;
    padding: 8px 12px;
    background-color: #e3f2fd;
    border-radius: 4px;
    font-size: 14px;
    color: #0d47a1;
    border-left: 4px solid #1976d2;
}
