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

:root {
    --primary-color: #2c394b;
    --primary-dark: #1e2832;
    --text-primary: #333;
    --text-secondary: #666;
    --text-light: #999;
    --border-color: #e0e0e0;
    --success-color: #4caf50;
    --warning-color: #ff9800;
    --error-color: #f44336;
    --info-color: #2196f3;
    --white: #ffffff;
    --grey-light: #f5f5f5;
    --grey-medium: #e0e0e0;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    color: var(--text-primary);
    background-color: var(--grey-light);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.screen {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

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

/* Splash Screen */
#splash-screen {
    background-color: var(--primary-color);
    justify-content: center;
    align-items: center;
}

.splash-content {
    text-align: center;
    color: var(--white);
}

.splash-logo, .login-logo {
    max-width: 200px;
    height: auto;
    margin-bottom: 30px;
}

/* Login Screen */
#login-screen {
    background-color: var(--primary-color);
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-form {
    margin-top: 30px;
}

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

.form-group input {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--white);
    transition: all 0.3s;
}

.form-group input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.form-group input:focus {
    outline: none;
    border-color: var(--white);
    background-color: rgba(255, 255, 255, 0.15);
}

.error-message {
    background-color: var(--error-color);
    color: var(--white);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
}

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

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

.btn-primary:hover:not(:disabled) {
    background-color: rgba(255, 255, 255, 0.9);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background-color: var(--grey-medium);
    color: var(--text-primary);
}

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

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

.btn-warning:hover:not(:disabled) {
    background-color: #e68900;
}

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

.btn-loader {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--white);
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.icon-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

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

/* Header */
.app-header {
    background-color: var(--primary-color);
    color: var(--white);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header h1 {
    font-size: 18px;
    font-weight: 600;
    flex: 1;
    text-align: center;
    margin: 0;
    text-transform: capitalize;
}

.app-header .back-btn {
    margin-right: auto;
}

/* Footer */
.app-footer {
    background-color: var(--primary-color);
    color: var(--white);
    padding: 16px 20px;
    text-align: center;
    font-size: 12px;
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.app-footer a {
    color: var(--white);
    text-decoration: underline;
}

.app-footer a:hover {
    opacity: 0.8;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* Loading and Error States */
.loading-container, .error-container, .empty-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.error-icon, .empty-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.error-container p, .empty-container p {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.empty-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px !important;
}

.empty-subtitle {
    font-size: 14px;
    color: var(--text-light);
}

/* Events List */
.events-list {
    display: grid;
    gap: 16px;
}

.event-card {
    background: var(--white);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
    transition: all 0.3s;
    cursor: pointer;
}

.event-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.event-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.event-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.event-date {
    font-size: 14px;
    color: var(--text-secondary);
}

.event-stats {
    background-color: var(--grey-light);
    border-radius: 8px;
    padding: 12px;
    margin-top: 12px;
}

.stats-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 8px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-value {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.stat-value.paid { color: var(--success-color); }
.stat-value.unpaid { color: var(--warning-color); }
.stat-value.collected { color: var(--info-color); }
.stat-value.uncollected { color: var(--error-color); }

.event-total {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
}

.event-categories {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.event-categories-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.category-item {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.category-more {
    font-size: 11px;
    color: var(--text-light);
    font-style: italic;
    margin-top: 4px;
}

/* Search Container */
.search-container {
    margin-bottom: 20px;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--white);
    border-radius: 12px;
    padding: 12px 16px;
    box-shadow: var(--shadow);
}

.search-icon {
    color: var(--text-light);
    margin-right: 12px;
    flex-shrink: 0;
}

.search-box input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 16px;
    color: var(--text-primary);
    background: transparent;
}

.search-box input::placeholder {
    color: var(--text-light);
}

.clear-btn, .qr-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    margin-left: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: color 0.2s;
}

.clear-btn:hover, .qr-btn:hover {
    color: var(--text-primary);
}

/* Results Container */
.results-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.registration-card {
    background: var(--white);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.registration-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.registration-info h3 {
    font-size: 18px;
    font-weight: 600;
    color: #000;
    margin-bottom: 4px;
}

.registration-info p {
    font-size: 14px;
    color: #000;
    margin-bottom: 2px;
}

.status-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.status-badge {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--white);
}

.status-badge.paid { background-color: var(--success-color); }
.status-badge.pending { background-color: var(--warning-color); }
.status-badge.failed, .status-badge.cancelled { background-color: var(--error-color); }
.status-badge.collected { background-color: var(--info-color); }

.participants-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.participants-section h4 {
    font-size: 16px;
    font-weight: 600;
    color: #000;
    margin-bottom: 12px;
}

.participant-item {
    background: var(--grey-light);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
}

.participant-item:last-child {
    margin-bottom: 0;
}

.participant-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.participant-name {
    font-size: 16px;
    font-weight: 600;
    color: #000;
    margin-bottom: 4px;
}

.participant-details {
    font-size: 14px;
    color: #000;
    margin-bottom: 2px;
}

.participant-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.participant-actions .btn {
    width: 100%;
    padding: 10px 16px;
    font-size: 14px;
}

/* Button colors for collection actions */
.participant-actions .btn.btn-collected {
    background-color: var(--success-color);
    color: var(--white);
}

.participant-actions .btn.btn-collected:hover:not(:disabled) {
    background-color: #45a049;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.participant-actions .btn.btn-onbehalf {
    background-color: var(--warning-color);
    color: var(--white);
}

.participant-actions .btn.btn-onbehalf:hover:not(:disabled) {
    background-color: #e68900;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.participant-actions .btn.btn-bib {
    background-color: var(--info-color);
    color: var(--white);
}

.participant-actions .btn.btn-bib:hover:not(:disabled) {
    background-color: #1976d2;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.collected-badge {
    background-color: var(--success-color);
    color: var(--white);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    overflow-y: auto;
}

.modal-content {
    background: var(--white);
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

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

.modal-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

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

.close-btn {
    color: var(--text-secondary);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.close-btn:hover {
    background-color: var(--grey-light);
}

/* QR Scanner Modal */
.qr-modal-content {
    max-width: 600px;
}

.qr-scanner-container {
    position: relative;
    width: 100%;
    padding-bottom: 100%;
    background-color: #000;
    overflow: hidden;
}

#qr-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#qr-canvas {
    display: none;
}

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

.qr-frame {
    width: 70%;
    height: 70%;
    border: 3px solid var(--white);
    border-radius: 12px;
    position: relative;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
}

.qr-frame::before,
.qr-frame::after {
    content: '';
    position: absolute;
    width: 30px;
    height: 30px;
    border: 4px solid var(--white);
}

.qr-frame::before {
    top: -3px;
    left: -3px;
    border-right: none;
    border-bottom: none;
    border-top-left-radius: 12px;
}

.qr-frame::after {
    bottom: -3px;
    right: -3px;
    border-left: none;
    border-top: none;
    border-bottom-right-radius: 12px;
}

.qr-instructions {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
    padding: 24px;
    text-align: center;
    color: var(--white);
}

.qr-instructions p {
    margin-bottom: 8px;
    font-weight: 500;
}

.qr-subtitle {
    font-size: 14px;
    opacity: 0.8;
}

.qr-manual-input {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
}

.qr-manual-input input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
}

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

.qr-manual-input .btn {
    width: auto;
    padding: 12px 24px;
}

/* Participant Modal */
.participant-modal-content {
    max-width: 600px;
}

.participants-list {
    padding: 20px;
}

.participant-card {
    background: var(--grey-light);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
}

.participant-card:last-child {
    margin-bottom: 0;
}

.participant-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.participant-card-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.participant-card-details {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.participant-card-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.action-input {
    margin-top: 12px;
}

.action-input input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    margin-bottom: 12px;
}

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

.action-input .btn {
    width: 100%;
}

/* Warning Modal */
.warning-modal-content {
    max-width: 400px;
}

.warning-header {
    text-align: center;
    padding: 20px;
}

.warning-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.warning-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.warning-message {
    padding: 0 20px 20px;
    text-align: center;
    font-size: 16px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.modal-actions {
    padding: 0 20px 20px;
    display: flex;
    gap: 12px;
}

.modal-actions .btn {
    flex: 1;
}

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

    .event-card {
        padding: 16px;
    }

    .event-name {
        font-size: 16px;
    }

    .stats-row {
        grid-template-columns: 1fr;
    }

    .modal-content {
        max-width: 100%;
        margin: 10px;
    }

    .qr-manual-input {
        flex-direction: column;
    }

    .qr-manual-input .btn {
        width: 100%;
    }
}

