/* ══════════════════════════════════════════
   ETM Check-in Portal - Mobile-First Styles
   ══════════════════════════════════════════ */

.etm-checkin-portal {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    max-width: 600px;
    margin: 0 auto;
    padding: 16px;
    background: #f8fafc;
    min-height: 100vh;
    box-sizing: border-box;
}

.etm-checkin-portal * {
    box-sizing: border-box;
}

/* ── Header ── */
.etm-checkin-header {
    text-align: center;
    margin-bottom: 20px;
}

.etm-checkin-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 16px;
}

.etm-checkin-event-selector select {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
    color: #334155;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
    cursor: pointer;
}

.etm-checkin-event-selector select:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* ── Stats Bar ── */
.etm-checkin-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.etm-stat-item {
    background: #fff;
    border-radius: 12px;
    padding: 16px 12px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.etm-stat-value {
    display: block;
    font-size: 28px;
    font-weight: 700;
    color: #6366f1;
    line-height: 1;
}

.etm-stat-label {
    display: block;
    font-size: 11px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 6px;
}

/* ── Ticket Types Section ── */
.etm-ticket-types-section {
    background: #fff;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.etm-ticket-types-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    cursor: pointer;
    font-weight: 600;
    color: #334155;
    transition: background 0.2s;
}

.etm-ticket-types-toggle:hover {
    background: #f8fafc;
}

.etm-toggle-icon {
    font-size: 12px;
    color: #64748b;
    transition: transform 0.2s;
}

.etm-ticket-types-section.expanded .etm-toggle-icon {
    transform: rotate(180deg);
}

.etm-ticket-types-list {
    border-top: 1px solid #e2e8f0;
    max-height: 250px;
    overflow-y: auto;
}

.etm-ticket-type-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
}

.etm-ticket-type-item:last-child {
    border-bottom: none;
}

.etm-ticket-type-badge {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 12px;
    flex-shrink: 0;
}

.etm-ticket-type-badge.paid {
    background: #6366f1;
}

.etm-ticket-type-badge.free {
    background: #22c55e;
}

.etm-ticket-type-info {
    flex: 1;
    min-width: 0;
}

.etm-ticket-type-name {
    font-size: 14px;
    font-weight: 500;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.etm-ticket-type-stats {
    display: flex;
    gap: 8px;
    font-size: 12px;
    color: #64748b;
    margin-top: 2px;
}

.etm-ticket-type-counts {
    text-align: right;
    flex-shrink: 0;
}

.etm-ticket-type-checkedin {
    font-size: 16px;
    font-weight: 700;
    color: #22c55e;
}

.etm-ticket-type-total {
    font-size: 12px;
    color: #64748b;
}

.etm-no-ticket-types {
    text-align: center;
    padding: 20px;
    color: #64748b;
    font-size: 14px;
}

/* ── Scanner Section ── */
.etm-checkin-scanner-section {
    background: #fff;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* Tabs */
.etm-checkin-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.etm-tab-btn {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    background: #fff;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.etm-tab-btn:hover {
    border-color: #cbd5e1;
    background: #f8fafc;
}

.etm-tab-btn.active {
    border-color: #6366f1;
    background: #eef2ff;
    color: #6366f1;
}

.etm-tab-icon {
    font-size: 18px;
}

/* Camera Scanner */
.etm-camera-container {
    position: relative;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: 4/3;
    max-height: 300px;
}

#etm-camera-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

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

.etm-scan-region {
    width: 70%;
    height: 50%;
    border: 3px solid rgba(99, 102, 241, 0.8);
    border-radius: 12px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.4);
    animation: scan-pulse 2s ease-in-out infinite;
}

@keyframes scan-pulse {
    0%, 100% { border-color: rgba(99, 102, 241, 0.8); }
    50% { border-color: rgba(99, 102, 241, 0.4); }
}

.etm-camera-controls {
    position: absolute;
    bottom: 12px;
    left: 12px;
    right: 12px;
    display: flex;
    gap: 8px;
    justify-content: center;
}

.etm-scanner-hint {
    text-align: center;
    color: #64748b;
    font-size: 13px;
    margin: 12px 0 0;
}

/* Manual Input */
.etm-manual-input {
    display: flex;
    gap: 10px;
}

.etm-manual-input input {
    flex: 1;
    padding: 14px 16px;
    font-size: 18px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.etm-manual-input input:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.etm-manual-input button {
    white-space: nowrap;
}

/* ── Buttons ── */
.etm-btn {
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.etm-btn-primary {
    background: #6366f1;
    color: #fff;
}

.etm-btn-primary:hover {
    background: #4f46e5;
}

.etm-btn-secondary {
    background: #64748b;
    color: #fff;
}

.etm-btn-secondary:hover {
    background: #475569;
}

.etm-btn-outline {
    background: #fff;
    color: #64748b;
    border: 2px solid #e2e8f0;
}

.etm-btn-outline:hover {
    border-color: #cbd5e1;
    background: #f8fafc;
}

.etm-btn-success {
    background: #22c55e;
    color: #fff;
}

.etm-btn-danger {
    background: #ef4444;
    color: #fff;
}

/* ── Result Display (Legacy - Hidden) ── */
.etm-checkin-result {
    display: none !important;
}

/* ══════════════════════════════════════════
   Enhanced Result Modals
   ══════════════════════════════════════════ */

/* Modal Overlay */
.etm-result-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 10000;
    animation: etm-fade-in 0.2s ease-out;
}

@keyframes etm-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.etm-result-modal-overlay.etm-modal-closing {
    animation: etm-fade-out 0.2s ease-out forwards;
}

@keyframes etm-fade-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* Modal Container */
.etm-result-modal {
    background: #fff;
    border-radius: 24px;
    padding: 40px 32px;
    text-align: center;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
    animation: etm-modal-slide-up 0.3s ease-out;
}

@keyframes etm-modal-slide-up {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Modal Icon */
.etm-modal-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.etm-modal-icon svg {
    width: 48px;
    height: 48px;
}

/* Modal Title */
.etm-modal-title {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: 1px;
    margin-bottom: 16px;
    text-transform: uppercase;
}

/* Modal Details */
.etm-modal-details {
    font-size: 15px;
    line-height: 1.7;
    margin-bottom: 28px;
}

.etm-result-detail-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #f1f5f9;
}

.etm-result-detail-row:last-child {
    border-bottom: none;
}

.etm-detail-label {
    color: #64748b;
    font-weight: 500;
}

.etm-detail-value {
    color: #1e293b;
    font-weight: 600;
    text-align: right;
}

/* Scan Notes (New check-in vs Re-entry) */
.etm-scan-note {
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 16px;
    text-align: center;
}

.etm-new-scan-note {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.etm-reentry-note {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* Modal Button */
.etm-modal-btn {
    width: 100%;
    padding: 18px 32px;
    border: none;
    border-radius: 14px;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.etm-modal-btn:active {
    transform: scale(0.98);
}

/* ── SUCCESS MODAL (Green) ── */
.etm-modal-success {
    border: 4px solid #22c55e;
}

.etm-modal-success .etm-modal-icon {
    background: #dcfce7;
}

.etm-modal-success .etm-modal-icon svg {
    stroke: #16a34a;
}

.etm-modal-success .etm-modal-title {
    color: #16a34a;
}

.etm-modal-success .etm-modal-btn {
    background: #22c55e;
    color: #fff;
}

.etm-modal-success .etm-modal-btn:hover {
    background: #16a34a;
}

/* ── WRONG EVENT MODAL (Orange) ── */
.etm-modal-wrong-event {
    border: 4px solid #f97316;
    background: #fff7ed;
}

.etm-modal-wrong-event .etm-modal-icon {
    background: #fed7aa;
}

.etm-modal-wrong-event .etm-modal-icon svg {
    stroke: #ea580c;
}

.etm-modal-wrong-event .etm-modal-title {
    color: #ea580c;
}

.etm-wrong-event-info {
    background: #fff;
    border: 2px solid #fdba74;
    border-radius: 12px;
    padding: 16px;
    color: #9a3412;
    font-size: 16px;
}

.etm-wrong-event-info strong {
    display: block;
    margin-top: 8px;
    font-size: 18px;
    color: #ea580c;
}

.etm-modal-wrong-event .etm-modal-btn {
    background: #f97316;
    color: #fff;
}

.etm-modal-wrong-event .etm-modal-btn:hover {
    background: #ea580c;
}

/* ── WRONG CHECKPOINT MODAL (Purple/Violet) ── */
.etm-modal-wrong-checkpoint {
    border: 4px solid #8b5cf6;
    background: #f5f3ff;
}

.etm-modal-wrong-checkpoint .etm-modal-icon {
    background: #ddd6fe;
}

.etm-modal-wrong-checkpoint .etm-modal-icon svg {
    stroke: #7c3aed;
}

.etm-modal-wrong-checkpoint .etm-modal-title {
    color: #7c3aed;
}

.etm-wrong-checkpoint-info {
    background: #fff;
    border: 2px solid #c4b5fd;
    border-radius: 12px;
    padding: 16px;
    color: #5b21b6;
    font-size: 16px;
}

.etm-wrong-checkpoint-info strong {
    color: #7c3aed;
}

.etm-modal-wrong-checkpoint .etm-modal-btn {
    background: #8b5cf6;
    color: #fff;
}

.etm-modal-wrong-checkpoint .etm-modal-btn:hover {
    background: #7c3aed;
}

/* ── ALREADY SCANNED MODAL (Yellow) ── */
.etm-modal-already-scanned {
    border: 4px solid #eab308;
    background: #fefce8;
}

.etm-modal-already-scanned .etm-modal-icon {
    background: #fef08a;
}

.etm-modal-already-scanned .etm-modal-icon svg {
    stroke: #ca8a04;
}

.etm-modal-already-scanned .etm-modal-title {
    color: #ca8a04;
}

.etm-already-scanned-info {
    background: #fff;
    border: 2px solid #fef08a;
    border-radius: 12px;
    padding: 16px;
    color: #854d0e;
    font-size: 16px;
}

.etm-already-scanned-info strong {
    color: #ca8a04;
}

.etm-checkin-time {
    margin-top: 12px;
    font-size: 13px;
    color: #a16207;
    background: #fef9c3;
    padding: 8px 12px;
    border-radius: 8px;
}

.etm-modal-already-scanned .etm-modal-btn {
    background: #eab308;
    color: #fff;
}

.etm-modal-already-scanned .etm-modal-btn:hover {
    background: #ca8a04;
}

/* ── ERROR MODAL ── */
.etm-modal-error {
    border: 4px solid #ef4444;
}

.etm-modal-error .etm-modal-icon {
    background: #fee2e2;
}

.etm-modal-error .etm-modal-icon svg {
    stroke: #dc2626;
}

.etm-modal-error .etm-modal-title {
    color: #dc2626;
}

.etm-modal-error .etm-modal-btn {
    background: #64748b;
    color: #fff;
}

/* ── WARNING MODAL ── */
.etm-modal-warning {
    border: 4px solid #f59e0b;
}

.etm-modal-warning .etm-modal-icon {
    background: #fef3c7;
}

.etm-modal-warning .etm-modal-icon svg {
    stroke: #d97706;
}

.etm-modal-warning .etm-modal-title {
    color: #d97706;
}

.etm-modal-warning .etm-modal-btn {
    background: #64748b;
    color: #fff;
}

/* ── CANCELLED TICKET MODAL ── */
.etm-modal-cancelled {
    border: 4px solid #991b1b;
}

.etm-modal-cancelled .etm-modal-icon {
    background: #fecaca;
}

.etm-modal-cancelled .etm-modal-icon svg {
    stroke: #991b1b;
}

.etm-modal-cancelled .etm-modal-title {
    color: #991b1b;
}

.etm-modal-cancelled .etm-modal-btn {
    background: #64748b;
    color: #fff;
}

/* ── NOT REGISTERED MODAL ── */
.etm-modal-not-registered {
    border: 4px solid #7c3aed;
}

.etm-modal-not-registered .etm-modal-icon {
    background: #ede9fe;
}

.etm-modal-not-registered .etm-modal-icon svg {
    stroke: #7c3aed;
}

.etm-modal-not-registered .etm-modal-title {
    color: #7c3aed;
}

.etm-modal-not-registered .etm-modal-btn {
    background: #64748b;
    color: #fff;
}

/* Info containers for different status types */
.etm-cancelled-info,
.etm-not-registered-info {
    text-align: center;
    font-size: 16px;
    line-height: 1.6;
    color: #475569;
}

.etm-cancelled-info strong,
.etm-not-registered-info strong {
    font-family: 'SF Mono', 'Consolas', monospace;
    color: #1e293b;
}

/* ══════════════════════════════════════════
   Confirmation Dialog
   ══════════════════════════════════════════ */

.etm-confirm-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 24px;
    animation: etm-fade-in 0.15s ease-out;
}

.etm-confirm-dialog {
    background: #fff;
    border-radius: 16px;
    padding: 28px 24px;
    text-align: center;
    margin: 20px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2);
    animation: etm-modal-slide-up 0.2s ease-out;
}

.etm-confirm-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    background: #fef3c7;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.etm-confirm-icon svg {
    width: 32px;
    height: 32px;
    stroke: #d97706;
}

.etm-confirm-message {
    font-size: 18px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 20px;
}

.etm-confirm-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.etm-confirm-btn {
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.etm-confirm-yes {
    background: #22c55e;
    color: #fff;
}

.etm-confirm-yes:hover {
    background: #16a34a;
}

.etm-confirm-no {
    background: #f1f5f9;
    color: #64748b;
    border: 2px solid #e2e8f0;
}

.etm-confirm-no:hover {
    background: #e2e8f0;
    color: #475569;
}

/* ── Recent Check-ins ── */
.etm-checkin-recent {
    background: #fff;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.etm-checkin-recent h3 {
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
    margin: 0 0 16px;
}

.etm-recent-list {
    max-height: 300px;
    overflow-y: auto;
}

.etm-recent-item {
    display: flex;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #f1f5f9;
}

.etm-recent-item:last-child {
    border-bottom: none;
}

.etm-recent-icon {
    width: 36px;
    height: 36px;
    background: #dcfce7;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    flex-shrink: 0;
}

.etm-recent-icon::before {
    content: '✓';
    color: #16a34a;
    font-weight: bold;
}

.etm-recent-info {
    flex: 1;
    min-width: 0;
}

.etm-recent-code {
    font-family: monospace;
    font-size: 13px;
    font-weight: 600;
    color: #334155;
}

.etm-recent-name {
    font-size: 12px;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.etm-recent-time {
    font-size: 11px;
    color: #94a3b8;
    text-align: right;
    flex-shrink: 0;
}

/* ── Messages ── */
.etm-checkin-message {
    padding: 16px 20px;
    border-radius: 12px;
    text-align: center;
    font-weight: 500;
}

.etm-checkin-error {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.etm-checkin-warning {
    background: #fffbeb;
    color: #d97706;
    border: 1px solid #fde68a;
}

/* ── Loading State ── */
.etm-loading {
    opacity: 0.7;
    pointer-events: none;
}

.etm-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 3px solid #6366f1;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ══════════════════════════════════════════
   Responsive Adjustments
   ══════════════════════════════════════════ */

/* Small phones */
@media (max-width: 380px) {
    .etm-checkin-portal {
        padding: 12px;
    }

    .etm-checkin-header h1 {
        font-size: 20px;
    }

    .etm-stat-value {
        font-size: 22px;
    }

    .etm-stat-label {
        font-size: 10px;
    }

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

    .etm-manual-input button {
        width: 100%;
    }
}

/* Tablets and Desktop */
@media (min-width: 768px) {
    .etm-checkin-portal {
        padding: 24px;
        min-height: auto;
        margin-top: 20px;
        margin-bottom: 20px;
        border-radius: 20px;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    }

    .etm-camera-container {
        max-height: 400px;
    }

    .etm-result-content {
        max-width: 420px;
    }
}

/* Fullscreen mode (PWA/Kiosk) */
@media (display-mode: fullscreen), (display-mode: standalone) {
    .etm-checkin-portal {
        max-width: 100%;
        min-height: 100vh;
        border-radius: 0;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .etm-checkin-portal {
        background: #0f172a;
    }

    .etm-checkin-header h1 {
        color: #f1f5f9;
    }

    .etm-checkin-event-selector select,
    .etm-stat-item,
    .etm-checkin-scanner-section,
    .etm-checkin-recent,
    .etm-result-content {
        background: #1e293b;
        border-color: #334155;
        color: #e2e8f0;
    }

    .etm-tab-btn {
        background: #1e293b;
        border-color: #334155;
        color: #94a3b8;
    }

    .etm-tab-btn.active {
        background: #312e81;
        border-color: #6366f1;
        color: #a5b4fc;
    }

    .etm-manual-input input {
        background: #0f172a;
        border-color: #334155;
        color: #f1f5f9;
    }

    .etm-recent-item {
        border-color: #334155;
    }

    .etm-recent-code {
        color: #e2e8f0;
    }

    .etm-ticket-types-section {
        background: #1e293b;
    }

    .etm-ticket-types-toggle {
        color: #e2e8f0;
    }

    .etm-ticket-types-toggle:hover {
        background: #334155;
    }

    .etm-ticket-types-list {
        border-color: #334155;
    }

    .etm-ticket-type-item {
        border-color: #334155;
    }

    .etm-ticket-type-name {
        color: #e2e8f0;
    }
}
