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

html, body {
    height: 100%;
    background-color: #000000;
    color: #ffffff;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 16px;
    line-height: 1.4;
    overflow-x: hidden;
    touch-action: manipulation;
}

/* Screen Management */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000000;
    z-index: 10;
    display: flex;
    flex-direction: column;
}

.screen.hidden {
    display: none;
}

/* Loading Screen */
.loading-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    text-align: center;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #333333;
    border-top: 3px solid #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

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

/* PIN Screen */
.pin-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    padding: 40px 20px;
    text-align: center;
}

.pin-content h1 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 60px;
    color: #ffffff;
}

.pin-form {
    width: 100%;
    max-width: 300px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.pin-form input {
    padding: 16px;
    font-size: 18px;
    border: 2px solid #333333;
    border-radius: 12px;
    background-color: #111111;
    color: #ffffff;
    text-align: center;
    letter-spacing: 4px;
    font-weight: 600;
}

.pin-form input:focus {
    outline: none;
    border-color: #ffffff;
}

/* Buttons */
.btn-primary, .btn-secondary {
    padding: 16px 24px;
    font-size: 18px;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 56px; /* Large touch target */
    touch-action: manipulation;
}

.btn-primary {
    background-color: #ffffff;
    color: #000000;
}

.btn-primary:hover, .btn-primary:focus {
    background-color: #e0e0e0;
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: #333333;
    color: #ffffff;
}

.btn-secondary:hover, .btn-secondary:focus {
    background-color: #444444;
    transform: translateY(-1px);
}

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

/* Event Screen */
.event-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background-color: #111111;
    border-bottom: 1px solid #333333;
}

.event-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.search-container {
    padding: 20px;
    background-color: #111111;
}

.search-input {
    width: 100%;
    padding: 16px;
    font-size: 16px;
    border: 2px solid #333333;
    border-radius: 12px;
    background-color: #000000;
    color: #ffffff;
}

.search-input:focus {
    outline: none;
    border-color: #666666;
}

.event-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 20px;
}

.event-card {
    background-color: #111111;
    border: 1px solid #333333;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.event-card:hover {
    background-color: #222222;
    border-color: #666666;
}

.event-card:active {
    transform: scale(0.98);
}

.event-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #ffffff;
}

.event-venue {
    font-size: 16px;
    color: #cccccc;
    margin-bottom: 4px;
}

.event-date {
    font-size: 14px;
    color: #999999;
}

/* Scanner Screen */
.scanner-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background-color: #111111;
    border-bottom: 1px solid #333333;
    position: relative;
}

.scanner-header h2 {
    font-size: 20px;
    font-weight: 600;
    flex: 1;
    text-align: center;
}

.offline-banner {
    background-color: #ff4444;
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: absolute;
    top: -60px;
    right: 20px;
    z-index: 100;
    animation: slideDown 0.3s ease;
}

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

.scanner-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

.camera-view {
    position: relative;
    flex: 1;
    background-color: #000000;
    overflow: hidden;
}

#camera-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scan-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
}

.scan-frame {
    width: 280px;
    height: 280px;
    border: 3px solid #ffffff;
    border-radius: 16px;
    position: relative;
    opacity: 0.8;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 0.4; }
}

.scan-frame::before,
.scan-frame::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 4px solid #00ff00;
}

.scan-frame::before {
    top: -4px;
    left: -4px;
    border-right: none;
    border-bottom: none;
}

.scan-frame::after {
    bottom: -4px;
    right: -4px;
    border-left: none;
    border-top: none;
}

.scanner-controls {
    padding: 20px;
    background-color: #111111;
    text-align: center;
}

.scan-instruction {
    font-size: 16px;
    color: #cccccc;
    margin-bottom: 20px;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background-color: #111111;
    border: 1px solid #333333;
    border-radius: 16px;
    padding: 30px;
    width: 90%;
    max-width: 400px;
    text-align: center;
}

.modal-content h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 20px;
    color: #ffffff;
}

.modal-content input {
    width: 100%;
    padding: 16px;
    font-size: 16px;
    border: 2px solid #333333;
    border-radius: 12px;
    background-color: #000000;
    color: #ffffff;
    margin-bottom: 20px;
}

.modal-content input:focus {
    outline: none;
    border-color: #666666;
}

.modal-buttons {
    display: flex;
    gap: 12px;
}

.modal-buttons button {
    flex: 1;
}

/* Result Overlay */
.result-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.result-overlay.hidden {
    display: none;
}

.result-content {
    background-color: #111111;
    border-radius: 20px;
    padding: 40px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    animation: resultSlide 0.3s ease;
}

@keyframes resultSlide {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.result-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.result-icon.success {
    color: #00ff00;
}

.result-icon.error {
    color: #ff4444;
}

.result-title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 16px;
}

.result-title.success {
    color: #00ff00;
}

.result-title.error {
    color: #ff4444;
}

.result-message {
    font-size: 18px;
    color: #cccccc;
    margin-bottom: 20px;
    line-height: 1.4;
}

.result-details {
    font-size: 16px;
    color: #999999;
    background-color: #000000;
    padding: 16px;
    border-radius: 12px;
    border: 1px solid #333333;
}

/* Error States */
.error-message {
    background-color: #ff4444;
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    margin-top: 16px;
}

.error-message.hidden {
    display: none;
}

.no-events {
    text-align: center;
    padding: 60px 20px;
    color: #999999;
    font-size: 16px;
}

.no-events.hidden {
    display: none;
}

/* Responsive Design */
@media (max-width: 480px) {
    .pin-content {
        padding: 30px 15px;
    }
    
    .pin-content h1 {
        font-size: 20px;
        margin-bottom: 40px;
    }
    
    .event-header, .search-container, .scanner-controls {
        padding: 15px;
    }
    
    .event-card {
        padding: 16px;
    }
    
    .result-content {
        padding: 30px 20px;
    }
    
    .result-title {
        font-size: 24px;
    }
    
    .result-icon {
        font-size: 48px;
    }
}

/* High contrast accessibility */
@media (prefers-contrast: high) {
    .scan-frame {
        border-color: #ffffff;
        opacity: 1;
    }
    
    .event-card {
        border-color: #666666;
    }
    
    .event-card:hover {
        border-color: #ffffff;
    }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    .loading-spinner,
    .scan-frame,
    .result-content {
        animation: none;
    }
    
    .btn-primary:hover,
    .btn-secondary:hover,
    .btn-primary:active,
    .btn-secondary:active {
        transform: none;
    }
    
    .event-card:active {
        transform: none;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .btn-primary, .btn-secondary {
        min-height: 60px;
        font-size: 18px;
    }
    
    .event-card {
        min-height: 80px;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
    
    .modal-content {
        padding: 25px 20px;
    }
    
    .modal-content input {
        min-height: 50px;
        font-size: 18px;
    }
}