/* Kinetic Fitness Scanner Styles */
/* Centralized styling for staff check-in interface */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 100%);
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    color: #ffffff;
    padding: 1rem 1rem;
    overflow: hidden;
}

.app-layout {
    display: flex;
    flex-direction: row;
    gap: 1.25rem;
    max-width: 100%;
    align-items: flex-start;
    padding: 0 1rem;
}

.main-column {
    flex: 1 0 300px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    min-width: 360px;
}

.scanner-container {
    background: #1a1a1a;
    padding: 1.25rem 1.5rem;
    border-radius: 4px;
    box-shadow: 0 12px 28px rgba(0,0,0,0.4);
    text-align: center;
    border: 1px solid rgba(255,255,255,0.16);
}

.gym-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

.gym-logo img {
    height: 60px;
    margin-right: 1rem;
}

.gym-logo-text {
    font-size: 2.2rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 2px;
}

.subtitle {
    color: #999;
    margin-bottom: 2rem;
    font-size: 1.1rem;
    font-weight: 500;
}

.scanner-section {
    margin: 1.4rem 0;
    padding: 1.1rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.14);
}

.scanner-section h3 {
    color: #ff6b35;
    margin-bottom: 1rem;
    font-weight: 600;
}

.scanner-section p {
    color: #999;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.section-header {
    margin: 1rem 0;
    text-align: center;
}

.section-header h2 {
    color: #ff6b35;
    margin: 0;
    font-weight: 600;
}

.send-pass-button {
    background: linear-gradient(135deg, #ff6b35 0%, #ff8c42 100%) !important;
    margin-top: 0.5rem;
}

.qr-input {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 4px;
    margin-bottom: 0.8rem;
    text-align: center;
    transition: all 0.25s;
    background: rgba(255, 255, 255, 0.05);
    color: #ffffff;
}

.qr-input::placeholder {
    color: #666;
}

.qr-input:focus {
    outline: none;
    border-color: #ff6b35;
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.2);
    background: rgba(255, 255, 255, 0.08);
}

.scan-button {
    background: linear-gradient(135deg, #c4c4c4 0%, #ffffff 100%);
    color: #1a1a1a;
    border: none;
    padding: 0.85rem 1.6rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.25s ease;
    width: 100%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.scan-button:hover {
    background: linear-gradient(135deg, #e0e0e0 0%, #ffffff 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 255, 255, 0.3);
}

.scan-button:disabled {
    background: #444;
    cursor: not-allowed;
    box-shadow: none;
}

.result-section {
    margin-top: 1.1rem;
    padding: 1rem;
    border-radius: 4px;
    display: none;
    border: 1px solid;
}

.result-success {
    background: rgba(46, 204, 113, 0.1);
    border-color: #2ecc71;
    color: #2ecc71;
}

.result-error {
    background: rgba(231, 76, 60, 0.1);
    border-color: #e74c3c;
    color: #e74c3c;
}

.result-warning {
    background: rgba(255, 193, 7, 0.1);
    border-color: #ffc107;
    color: #ffc107;
}

.result-payment-due {
    background: rgba(255, 107, 53, 0.1);
    border-color: #ff6b35;
    color: #ff6b35;
}

.alert-box { display: none; }

.payment-amount {
    font-size: 1.5rem;
    color: #fff;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.75rem;
}

.payment-amount::before { content: ''; }

.member-info {
    text-align: left;
    margin-top: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    padding: 1rem;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.member-name {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.6rem;
    color: #ffffff;
}

.member-detail {
    margin: 0.35rem 0;
    display: flex;
    justify-content: space-between;
    color: #cfcfcf;
    padding: 0.4rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.member-detail:last-child {
    border-bottom: none;
}

.status-active {
    color: #2ecc71;
    font-weight: bold;
}

.status-suspended {
    color: #e74c3c;
    font-weight: bold;
}

.status-non-member {
    color: #ffc107;
    font-weight: bold;
}


.camera-section {
    margin: 1rem 0;
    padding: 1.1rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 4px;
}

.camera-button {
    background: rgba(255, 255, 255, 0.08);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.14);
    padding: 0.65rem 1.2rem;
    border-radius: 4px;
    cursor: pointer;
    margin: 0.4rem;
    transition: all 0.25s;
    font-size: 0.9rem;
}

.camera-button:hover {
    background: rgba(255, 107, 53, 0.2);
    border-color: #ff6b35;
}

#video {
    width: 100%;
    max-width: 260px;
    border-radius: 4px;
    margin: 0.75rem 0;
    border: 1px solid rgba(255, 107, 53, 0.3);
}

.system-status {
    background: rgba(26, 26, 26, 0.8);
    color: white;
    padding: 0.55rem 0.85rem;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    font-size: 0.75rem;
    border: 1px solid rgba(255,255,255,0.12);
    backdrop-filter: blur(8px);
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.history-sidebar {
    flex: 1 1 auto;
    min-width: 300px;
    max-width: 400px;
    background: #1a1a1a;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.16);
    box-shadow: 0 12px 28px rgba(0,0,0,0.4);
    overflow: hidden;
    max-height: calc(100vh - 3rem);
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    position: relative;
}

.history-sidebar.collapsed {
    display: none;
}

.history-reopen-button {
    position: fixed;
    top: 6%;
    right: 20px;
    transform: translateY(-50%);
    background: linear-gradient(135deg, #ff6b35, #ff8c42);
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
    padding: 12px 18px;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.4);
    font-size: 0.9rem;
    font-weight: 600;
    display: none;
    z-index: 100;
    transition: all 0.25s ease;
}

.history-reopen-button.visible {
    display: block;
}

.history-reopen-button:hover {
    background: linear-gradient(135deg, #ff5722, #ff6b35);
    transform: translateY(-50%) scale(1.05);
    box-shadow: 0 6px 16px rgba(255, 107, 53, 0.5);
}

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: rgba(255,255,255,0.03);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.history-header h3 {
    margin: 0;
    font-size: 1rem;
    color: #ff6b35;
    font-weight: 600;
}

.toggle-history {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.toggle-history:hover {
    background: rgba(255,255,255,0.08);
}

.history-list {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.75rem;
    min-height: 200px;
}

.history-list.collapsed {
    display: none;
}

.history-list::-webkit-scrollbar {
    width: 6px;
}

.history-list::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.04);
    border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb {
    background: rgba(255,107,53,0.4);
    border-radius: 3px;
}

.history-empty {
    text-align: center;
    color: #666;
    padding: 2rem 1rem;
    font-size: 0.9rem;
}

.history-item {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    padding: 0.85rem;
    margin-bottom: 0.65rem;
    transition: all 0.2s;
}

.history-item:hover {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.15);
}

.history-item.success {
    border-left: 3px solid #2ecc71;
}

.history-item.warning {
    border-left: 3px solid #ffc107;
}

.history-item.error {
    border-left: 3px solid #e74c3c;
}

.history-item.payment-due {
    border-left: 3px solid #ff6b35;
}

.history-time {
    font-size: 0.75rem;
    color: #888;
    margin-bottom: 0.4rem;
}

.history-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: #fff;
    margin-bottom: 0.3rem;
}

.history-status {
    font-size: 0.85rem;
    color: #aaa;
}

.history-status.success {
    color: #2ecc71;
}

.history-status.warning {
    color: #ffc107;
}

.history-status.error {
    color: #e74c3c;
}

.status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 0.5rem;
    animation: pulse 2s infinite;
}

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

.status-connected {
    background: #0fec68;
}

.status-disconnected {
    background: #e74c3c;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Modal styles */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.result-modal-content {
    max-width: 480px;
    animation: modalSlideIn 0.3s ease-out;
}

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

.result-modal-content .modal-body {
    max-height: 400px;
    overflow-y: auto;
}

.result-modal-content.success { border-left: 4px solid #2ecc71; }
.result-modal-content.error { border-left: 4px solid #e74c3c; }
.result-modal-content.warning { border-left: 4px solid #ffc107; }
.result-modal-content.payment-due { border-left: 4px solid #ff6b35; }

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: #1a1a1a;
    border-radius: 8px;
    padding: 1.25rem 1.25rem 1rem 1.25rem;
    max-width: 480px;
    width: 92%;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.6);
    position: relative;
    z-index: 1001; /* Ensure modal content is above the overlay */
}

/* Ensure modal inputs are interactive and properly styled */
.modal-content input {
    pointer-events: auto;
    z-index: 1002;
    position: relative;
}

.modal-content input:focus {
    outline: none;
    border-color: #ff6b35;
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.2);
    background: rgba(255, 255, 255, 0.08);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.modal-title {
    color: #fff;
    font-size: 1.1rem;
    font-weight: 700;
}

.modal-close {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    color: #fff;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0.3rem 0.55rem;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: rgba(255,255,255,0.12);
}

.modal-body {
    color: #ddd;
}

.send-pass-link {
    background: none;
    border: none;
    color: #ff6b35;
    text-decoration: underline;
    cursor: pointer;
    font-size: 0.9rem;
    margin-top: 1rem;
    padding: 0.5rem;
    transition: color 0.3s;
}

.send-pass-link:hover {
    color: #ff8c42;
}

.verification-status {
    margin: 1rem 0;
    padding: 1rem;
    border-radius: 4px;
    font-size: 0.9rem;
}

.verification-success {
    background: rgba(46, 204, 113, 0.1);
    border: 1px solid #2ecc71;
    color: #2ecc71;
}

.verification-error {
    background: rgba(231, 76, 60, 0.1);
    border: 1px solid #e74c3c;
    color: #e74c3c;
}

.verification-warning {
    background: rgba(255, 193, 7, 0.1);
    border: 1px solid #ffc107;
    color: #ffc107;
}

/* Responsive design */
@media (max-width: 600px) {
    .scanner-container {
        padding: 1.5rem;
        width: 95%;
    }
    
    .gym-logo-text {
        font-size: 1.8rem;
    }
    
    .subtitle {
        font-size: 0.95rem;
    }
    
    .modal-content {
        width: 95%;
        padding: 1.5rem;
    }
}

/* Enhanced Mobile Styles - Better UX for Camera Scanning */
@media (max-width: 768px) {
    body {
        padding: 0;
        overflow-y: auto;
        overflow-x: hidden;
    }
    
    .app-layout {
        flex-direction: column;
        padding: 0;
        gap: 0;
    }
    
    .main-column {
        min-width: unset;
        width: 100%;
    }
    
    .scanner-container {
        border-radius: 0;
        padding: 1rem;
        min-height: 100vh;
    }
    
    /* Smaller text on mobile */
    .gym-logo-text {
        font-size: 1.5rem;
    }
    
    .subtitle {
        font-size: 0.85rem;
    }
    
    .section-header h2 {
        font-size: 1rem;
    }
    
    /* Hide manual input section on mobile by default (use camera instead) */
    .scanner-section {
        display: none;
    }
    
    /* Show manual input if user requests it */
    body.show-manual-input .scanner-section {
        display: block;
    }
    
    /* Make camera section prominent on mobile */
    .camera-section {
        margin-top: 1rem;
    }
    
    .camera-button {
        font-size: 1.1rem;
        padding: 1rem 1.5rem;
        width: 100%;
    }
    
    /* Full-screen camera on mobile */
    #qr-reader {
        width: 100% !important;
        max-width: 100% !important;
        margin: 1rem 0;
    }
    
    #qr-reader video {
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 8px;
    }
    
    /* History as modal on mobile */
    .history-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.95);
        z-index: 2000;
        transform: translateY(100%);
        transition: transform 0.3s ease;
        display: flex;
        flex-direction: column;
    }
    
    .history-sidebar.mobile-open {
        transform: translateY(0);
    }
    
    .history-header {
        padding: 1rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        flex-shrink: 0;
    }
    
    .history-list {
        flex: 1;
        overflow-y: auto;
        padding: 0.5rem;
    }
    
    /* Floating history button on mobile - compact FAB style */
    .history-reopen-button {
        display: flex !important;
        align-items: center;
        justify-content: center;
        position: fixed;
        bottom: 1.5rem;
        right: 1rem;
        z-index: 999;
        background: linear-gradient(135deg, #ff6b35 0%, #ff5722 100%);
        color: white;
        border: none;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        font-size: 1.5rem;
        box-shadow: 0 4px 16px rgba(255, 107, 53, 0.5);
        cursor: pointer;
        transition: transform 0.2s, box-shadow 0.2s;
    }
    
    .history-reopen-button:active {
        transform: scale(0.9);
        box-shadow: 0 2px 8px rgba(255, 107, 53, 0.6);
    }
    
    /* Hide the reopen button when history is open */
    .history-sidebar.mobile-open ~ .history-reopen-button {
        opacity: 0;
        pointer-events: none;
    }
    
    /* Make history items more compact on mobile */
    .history-item {
        padding: 0.6rem;
        margin-bottom: 0.5rem;
    }
    
    .history-time {
        font-size: 0.75rem;
    }
    
    .history-name {
        font-size: 0.9rem;
    }
    
    .history-status {
        font-size: 0.75rem;
    }
    
    .toggle-history {
        font-size: 1.5rem;
        min-width: 40px;
        height: 40px;
    }
    
    /* Better modals on mobile */
    .modal-content {
        max-height: 90vh;
        overflow-y: auto;
    }
    
    /* System status at bottom on mobile */
    .system-status {
        font-size: 0.8rem;
        padding: 0.75rem;
        position: sticky;
        bottom: 0;
        background: rgba(26, 26, 26, 0.95);
    }
    
    /* Compact send pass button on mobile */
    .send-pass-link {
        font-size: 0.9rem;
        padding: 0.7rem 1rem;
    }
}

/* Tablet and small desktop - middle ground */
@media (min-width: 769px) and (max-width: 1024px) {
    .scanner-container {
        padding: 1.5rem;
    }
    
    .history-sidebar {
        width: 280px;
    }
}

/* When camera is active on mobile, hide everything else */
@media (max-width: 768px) {
    body.camera-active .gym-logo,
    body.camera-active .subtitle,
    body.camera-active .section-header,
    body.camera-active .send-pass-link,
    body.camera-active .system-status {
        display: none;
    }
    
    body.camera-active .scanner-container {
        padding: 0;
        background: #000;
    }
    
    body.camera-active #qr-reader {
        margin: 0;
        height: 100vh;
    }
}
