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

:root {
    --primary-color: #424242;
    --secondary-color: #616161;
    --background: #000000;
    --surface: #1a1a1a;
    --surface-light: #2a2a2a;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --success: #4caf50;
    --error: #f44336;
    --warning: #ff9800;
    --info: #2196f3;
    --border: #424242;
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

/* Screen Management */
.screen {
    display: none;
    height: 100vh;
    width: 100vw;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* Login Screen */
.login-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 24px;
    max-width: 400px;
    width: 100%;
    margin: 0 auto;
}

.logo-container {
    margin-bottom: 40px;
    text-align: center;
}

.logo {
    height: 80px;
    width: auto;
    max-width: 200px;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

.logo-text {
    font-size: 32px;
    font-weight: bold;
    color: var(--text-primary);
}

.screen-title {
    font-size: 28px;
    font-weight: bold;
    text-align: center;
    margin-bottom: 8px;
}

.screen-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 40px;
}

.form-group {
    width: 100%;
    margin-bottom: 16px;
}

/* Buttons */
.btn {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

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

.btn-primary {
    background-color: #1976d2;
    color: white;
}

.btn-primary:not(:disabled):hover {
    background-color: #1565c0;
}

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

.btn-secondary:not(:disabled):hover {
    background-color: var(--secondary-color);
}

.btn-success {
    background-color: var(--success);
    color: white;
}

.btn-success:not(:disabled):hover {
    background-color: #45a049;
}

.btn-outline {
    background-color: transparent;
    color: white;
    border: 1px solid var(--border);
}

.btn-outline:not(:disabled):hover {
    background-color: var(--surface-light);
}

/* Input */
.input {
    width: 100%;
    padding: 16px;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 16px;
}

.input:focus {
    outline: none;
    border-color: var(--text-primary);
}

.input::placeholder {
    color: var(--text-secondary);
}

/* Info Boxes */
.info-box {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.info-box.success {
    background-color: rgba(76, 175, 80, 0.3);
    border: 1px solid #4caf50;
    color: #81c784;
}

.info-box.info {
    background-color: rgba(33, 150, 243, 0.3);
    border: 1px solid #2196f3;
    color: #64b5f6;
}

.error-box {
    width: 100%;
    padding: 12px;
    background-color: rgba(244, 67, 54, 0.3);
    border: 1px solid var(--error);
    border-radius: 8px;
    color: #ef5350;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

/* Check-in Screen */
.checkin-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.app-header {
    background-color: var(--background);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.header-logo {
    height: 40px;
    width: auto;
    object-fit: contain;
    display: block;
}

.header-logo-text {
    font-size: 20px;
    font-weight: bold;
    color: var(--text-primary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.switch {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.switch input {
    display: none;
}

.slider {
    width: 44px;
    height: 24px;
    background-color: var(--surface-light);
    border-radius: 24px;
    position: relative;
    transition: background-color 0.3s;
}

.slider:before {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background-color: white;
    top: 3px;
    left: 3px;
    transition: transform 0.3s;
}

.switch input:checked + .slider {
    background-color: var(--success);
}

.switch input:checked + .slider:before {
    transform: translateX(20px);
}

.switch-label {
    font-size: 14px;
    color: var(--text-primary);
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    opacity: 0.7;
}

.view-toggle {
    padding: 16px;
}

.view-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Camera/Scanner */
.camera-container {
    flex: 1;
    position: relative;
    background-color: var(--background);
    overflow: hidden;
}

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

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

.scanner-frame {
    width: 250px;
    height: 250px;
    border: 2px solid var(--success);
    border-radius: 12px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
}

.camera-error {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: var(--background);
    padding: 24px;
    text-align: center;
}

.error-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.processing-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

/* Search */
.search-container {
    padding: 16px;
}

.search-input-group {
    display: flex;
    gap: 8px;
}

.search-input-group .input {
    flex: 1;
}

.search-btn {
    min-width: 48px;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.search-results {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
}

.result-card {
    background-color: var(--surface);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.result-card:hover {
    background-color: var(--surface-light);
}

.result-title {
    font-weight: bold;
    font-size: 16px;
    margin-bottom: 8px;
}

.result-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.result-checked {
    color: var(--success);
    font-weight: 500;
    margin-top: 8px;
}

/* Ticket Details */
.ticket-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 24px;
}

.ticket-header {
    width: 100%;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.ticket-header.checked-in {
    background-color: #ff9800;
}

.ticket-header.new {
    background-color: #1976d2;
}

.ticket-header h3 {
    font-size: 24px;
    font-weight: bold;
    color: white;
}

.ticket-content {
    flex: 1;
}

.info-card {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    display: flex;
}

.info-label {
    width: 120px;
    color: var(--text-secondary);
    font-size: 16px;
    font-weight: 500;
}

.info-value {
    flex: 1;
    color: var(--text-primary);
    font-size: 16px;
    font-weight: bold;
}

.ticket-actions {
    margin-top: 32px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: var(--surface);
    border-radius: 16px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 22px;
    font-weight: bold;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    opacity: 0.7;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 12px;
}

.ticket-modal-header {
    border-radius: 16px 16px 0 0;
    color: white;
    border: none;
}

.ticket-modal-header.checked-in {
    background-color: #ff9800;
}

.ticket-modal-header.new {
    background-color: #1976d2;
}

.ticket-modal-body {
    max-height: 400px;
}

.events-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.event-card {
    background-color: var(--surface);
    border-radius: 8px;
    padding: 16px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.event-card:hover {
    background-color: var(--surface-light);
}

.event-title {
    font-weight: bold;
    font-size: 16px;
    margin-bottom: 8px;
}

.event-meta {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
}

/* Loading */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    gap: 16px;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--text-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background-color: var(--surface);
    color: var(--text-primary);
    padding: 16px 24px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 2000;
    opacity: 0;
    transition: all 0.3s;
    max-width: 90%;
    text-align: center;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    background-color: var(--success);
    color: white;
}

.toast.error {
    background-color: var(--error);
    color: white;
}

.toast.warning {
    background-color: var(--warning);
    color: white;
}

/* App Footer */
.app-footer {
    padding: 12px 16px;
    text-align: center;
    border-top: 1px solid var(--border);
    background-color: var(--surface);
    font-size: 14px;
    color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 480px) {
    .login-container {
        padding: 16px;
    }
    
    .modal-content {
        max-height: 95vh;
    }
}
