/* Global Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
body {
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}
.app-container {
    max-width: 100%;
    margin: 0 auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header Styles */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid #ddd;
    margin-bottom: 1rem;
}
h1 {
    font-size: 1.8rem;
    color: #333;
}
.config-section.hidden {
    display: none;
}

/* Footer Styles */
.footer {
    background-color: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-top: 1.5rem;
    text-align: center;
}
.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}
.footer a {
    color: #4a90e2;
    text-decoration: none;
    font-weight: bold;
    transition: color 0.3s;
}
.footer a:hover {
    color: #3a80d2;
    text-decoration: underline;
}
.copyright {
    font-size: 0.9rem;
    color: #666;
    margin-top: 0.5rem;
}
@media (max-width: 600px) {
    .footer {
        padding: 1rem;
    }
}

/* Main Content Container */
.main-content {
    display: grid;
    grid-template-columns: 1fr; /* Single column layout by default */
    gap: 1.5rem;
    flex-grow: 1;
}

/* Activity, Prompt, and Users Sections */
.activity-section,
.prompt-section,
#usersSection {
    background-color: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
}

/* Section Titles */
.activity-section h2,
.prompt-section h2,
#usersSection h2 {
    font-size: 1.4rem;
    margin-bottom: 1rem;
    color: #444;
    border-bottom: 2px solid #4a90e2;
    padding-bottom: 0.75rem;
}

/* Feed Styling */
.feed {
    flex-grow: 1;
    overflow-y: auto;
    max-height: 300px;
    border: 1px solid #eee;
    padding: 1rem;
    border-radius: 4px;
    background-color: #fafafa;
    margin-bottom: 1rem;
}

/* Feed Items */
.feed-item {
    padding: 0.8rem;
    border-bottom: 1px solid #eee;
    font-size: 1rem;
}
.feed-item:last-child {
    border-bottom: none;
}
.feed-item.event {
    color: #666;
    font-style: italic;
}
.feed-item.chat {
    color: #333;
}
.feed-item.tip {
    color: #28a745;
    font-weight: bold;
}
.feed-item.prompt {
    position: relative;
    color: #4a90e2;
    font-weight: bold;
    padding-left: 50px; /* Make space for the voice indicator */
}

/* Audio Controls */
.audio-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Status Bar */
.status-bar {
    display: flex;
    justify-content: space-between;
    padding: 1rem 0;
    border-top: 1px solid #ddd;
    margin-top: 1rem;
    font-size: 0.9rem;
    color: #666;
}



/* User List */
.user-list {
    flex-grow: 1;
    overflow-y: auto;
    max-height: 100%;
    border: 1px solid #eee;
    border-radius: 4px;
    background-color: #fafafa;
    margin-bottom: 1rem;
}

/* User Item */
.user-item {
    margin-bottom: 8px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    transition: box-shadow 0.3s;
}
.user-item:hover {
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1); /* Hover effect */
}

/* User Summary */
.user-summary {
    padding: 12px;
    background-color: #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.3s;
}
.user-summary:hover {
    background-color: #e0e0e0; /* Slightly darker on hover */
}
.user-summary.online {
    background-color: #d4edda;
    border-left: 4px solid #28a745; /* Green indicator for online users */
}
.user-summary .username {
    font-weight: bold;
    color: #333;
}
.user-summary .status {
    font-size: 0.9rem;
    color: #666;
}
.user-summary .status.online {
    color: #28a745; /* Green text for online status */
}

/* Expand Button */
.expand-button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    color: #666;
    padding: 0 5px;
    transition: color 0.3s;
}
.expand-button:hover {
    color: #333; /* Darker color on hover */
}

/* User Details */
.user-details {
    display: none;
    padding: 12px;
    background-color: white;
    border-top: 1px solid #e0e0e0;
}
.user-details.expanded {
    display: block;
}

/* Detail Row */
.detail-row {
    margin-bottom: 5px;
    display: flex;
    align-items: center;
}
.detail-row label {
    font-weight: bold;
    width: 140px;
    flex-shrink: 0;
    color: #444;
}
.detail-row span {
    color: #333;
}

/* Recent Messages */
.recent-messages {
    margin: 8px 0;
    padding-left: 20px;
    max-height: 100px;
    overflow-y: auto;
    font-size: 0.9rem;
    color: #555;
}

/* No Users Message */
.no-users {
    padding: 15px;
    text-align: center;
    color: #666;
    font-style: italic;
    font-size: 1rem;
}

/* Tablet and Desktop Layout */
@media (min-width: 768px) {
    .main-content {
        grid-template-columns: 1fr 1fr; /* Two columns */
        gap: 2rem;
    }
    .scanner-section {
        grid-column: 1 / -1; /* Span all columns */
        margin-bottom: 1.5rem;
    }
    .activity-section {
        grid-column: 1; /* First column */
    }
    .prompt-section {
        grid-column: 2; /* Second column */
    }
    #usersSection {
        grid-column: 1 / -1; /* Span all columns */
        margin-top: 1.5rem;
    }
}

@media (min-width: 768px) {
    .feed {
        max-height: 400px; /* Increase feed height for tablets and desktops */
    }
}


@media (min-width: 768px) {
    .activity-section,
    .prompt-section {
        height: calc(100vh - 300px); /* Adjust based on header/footer height */
        min-height: 400px;
        transition: all 0.3s ease;
    }
}


/* Scanner Section */
.scanner-section {
    background-color: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    text-align: center;
}
#qrScannerContainer {
    position: relative;
    width: 100%;
    max-width: 500px;
    margin: 0 auto 1rem;
    overflow: hidden;
    border-radius: 8px;
    border: 2px solid #ddd;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}
#qrScanner {
    width: 100%;
    height: auto;
    background-color: #000;
    border-radius: 8px;
}
#qrCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Ensure canvas doesn't block interactions */
}
#startScan {
    margin-top: 1rem;
}
#scanResult {
    margin-top: 1rem;
    font-size: 1rem;
    color: #333;
}
#apiEndpoint {
    font-weight: bold;
    color: #4a90e2;
}


/* Scanner Buttons */
#startScan {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 4px;
    background-color: #4a90e2; /* Primary blue color */
    color: white;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.3s;
    font-weight: bold;
}
#startScan:hover {
    background-color: #3a80d2; /* Darker blue on hover */
}

#disconnect {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 4px;
    background-color: #e74c3c; /* Red color for disconnect */
    color: white;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.3s;
    font-weight: bold;
}
#disconnect:hover {
    background-color: #c0392b; /* Darker red on hover */
}

/* Scan Result Text */
#scanResult {
    margin-top: 1rem;
    font-size: 1rem;
    color: #333;
}
#apiEndpoint {
    font-weight: bold;
    color: #4a90e2;
}


/* Settings Button */
#configToggle {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 4px;
    background-color: #ff9f43; /* Warm orange color */
    color: white;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.3s;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 0.5rem; /* Space between icon and text */
}
#configToggle:hover {
    background-color: #e68a3b; /* Darker orange on hover */
    transform: scale(1.05); /* Slight zoom effect */
}
#configToggle:active {
    transform: scale(0.95); /* Slight shrink effect on click */
}


/* Config Section */
.config-section {
    background-color: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    margin-bottom: 1.5rem;
    transition: box-shadow 0.3s;
}
.config-section:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15); /* Subtle hover effect */
}

/* Form Group */
.form-group {
    margin-bottom: 1.5rem;
}
.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: bold;
    color: #444;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 1rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    transition: border-color 0.3s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #4a90e2; /* Highlight on focus */
    outline: none;
    box-shadow: 0 0 5px rgba(74, 144, 226, 0.5); /* Soft glow effect */
}

/* Textarea Adjustments */
textarea {
    min-height: 120px;
    resize: vertical; /* Allow vertical resizing */
}

/* Buttons in Config Section */
#saveConfig,
#testApiConnection {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.3s;
    font-weight: bold;
    margin-right: 0.5rem;
}
#saveConfig {
    background-color: #4a90e2;
    color: white;
}
#saveConfig:hover {
    background-color: #3a80d2;
    transform: scale(1.05);
}
#testApiConnection {
    background-color: #ff9f43;
    color: white;
}
#testApiConnection:hover {
    background-color: #e68a3b;
    transform: scale(1.05);
}

/* API Test Result */
#apiTestResult {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 4px;
    font-size: 1rem;
    color: #333;
    background-color: #f0f7ff;
    border: 1px solid #cce5ff;
}
#apiTestResult.success {
    background-color: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}
#apiTestResult.error {
    background-color: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

/* Factory Reset Button */
#factoryReset {
    margin-top: 1.5rem;
    padding: 0.7rem 1.2rem;
    border: none;
    border-radius: 4px;
    background-color: #e74c3c;
    color: white;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.3s;
    font-weight: bold;
}
#factoryReset:hover {
    background-color: #c0392b;
    transform: scale(1.05);
}


/* Voice Selection Dropdowns */
#sayVoiceSelect,
#doVoiceSelect {
    padding: 0.8rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    background-color: white;
    color: #333;
    transition: border-color 0.3s;
}
#sayVoiceSelect:focus,
#doVoiceSelect:focus {
    border-color: #4a90e2;
    outline: none;
    box-shadow: 0 0 5px rgba(74, 144, 226, 0.5);
}

/* Voice Test Buttons */
.voice-test-button {
    padding: 0.7rem 1.2rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.3s;
    font-weight: bold;
    margin-top: 0.5rem;
}
#testSayVoice {
    background-color: #0066cc;
    color: white;
}
#testSayVoice:hover {
    background-color: #004c99;
    transform: scale(1.05);
}
#testDoVoice {
    background-color: #444;
    color: white;
}
#testDoVoice:hover {
    background-color: #333;
    transform: scale(1.05);
}

/* Data Management Section */
.data-management {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}
.data-management h3 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: #444;
    border-bottom: 2px solid #4a90e2;
    padding-bottom: 0.5rem;
}
.button-group {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.action-button {
    padding: 0.7rem 1.2rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.3s;
    font-weight: bold;
}
#exportDataButton {
    background-color: #28a745;
    color: white;
}
#exportDataButton:hover {
    background-color: #218838;
    transform: scale(1.05);
}
#importDataButton {
    background-color: #ffc107;
    color: black;
}
#importDataButton:hover {
    background-color: #e0a800;
    transform: scale(1.05);
}
.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.checkbox-group label {
    font-size: 1rem;
    color: #444;
}
.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #4a90e2;
}
.result-box {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 4px;
    background-color: #f0f7ff;
    border: 1px solid #cce5ff;
    color: #333;
    font-size: 1rem;
}
.result-box.error {
    background-color: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.4s;
}
.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.4s;
}
input:checked + .slider {
    background-color: #4a90e2; /* Primary blue color */
}
input:focus + .slider {
    box-shadow: 0 0 1px #4a90e2;
}
input:checked + .slider:before {
    transform: translateX(26px);
}
.slider.round {
    border-radius: 34px;
}
.slider.round:before {
    border-radius: 50%;
}

/* Data Password Input */
#dataPassword {
    width: 100%;
    padding: 1rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    transition: border-color 0.3s;
}
#dataPassword:focus {
    border-color: #4a90e2; /* Highlight on focus */
    outline: none;
    box-shadow: 0 0 5px rgba(74, 144, 226, 0.5); /* Soft glow effect */
}

/* Event Timeline Styles */
.event-timeline {
    margin: 8px 0;
    max-height: 150px;
    overflow-y: auto;
    border: 1px solid #eee;
    border-radius: 4px;
    padding: 8px;
    background-color: #fafafa;
}

.event-item {
    display: flex;
    gap: 8px;
    padding: 6px 8px;
    margin-bottom: 4px;
    border-radius: 4px;
    font-size: 0.9rem;
    align-items: center;
    background-color: white;
    border-left: 3px solid #4a90e2;
}

.event-item.tip {
    border-left-color: #28a745;
    background-color: #f0fff4;
}

.event-item.chatMessage {
    border-left-color: #6c757d;
    background-color: #f8f9fa;
}

.event-item.privateMessage {
    border-left-color: #6f42c1;
    background-color: #f5f0ff;
}

.event-item.privateShow,
.event-item.privateShowSpy {
    border-left-color: #fd7e14;
    background-color: #fff4e6;
}

.event-item.mediaPurchase {
    border-left-color: #20c997;
    background-color: #e6fcf5;
}

.event-time {
    color: #6c757d;
    font-size: 0.8rem;
    min-width: 60px;
}

.event-content {
    flex-grow: 1;
}

/* Token Stats */
.token-stats {
    display: flex;
    gap: 12px;
    font-size: 0.9rem;
}

.token-stats span {
    padding: 4px 8px;
    background-color: #f0f7ff;
    border-radius: 4px;
    color: #4a90e2;
}

/* View All Events Button */
.view-all-events {
    width: 100%;
    padding: 8px;
    background-color: #f0f7ff;
    border: 1px solid #cce5ff;
    color: #4a90e2;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.3s;
}

.view-all-events:hover {
    background-color: #e0f0ff;
}

/* Event Timeline Modal */
.event-timeline-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;
}

.modal-content {
    background-color: white;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    overflow-y: auto;
    position: relative;
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 24px;
    cursor: pointer;
    color: #6c757d;
    transition: color 0.3s;
}

.close-modal:hover {
    color: #495057;
}

/* Full Event Timeline */
.full-event-timeline {
    margin-top: 16px;
    border: 1px solid #eee;
    border-radius: 4px;
    max-height: 400px;
    overflow-y: auto;
}

.full-event-timeline .event-item {
    padding: 10px 12px;
    margin-bottom: 6px;
}

/* Event Stats */
.event-stats {
    display: flex;
    gap: 16px;
    margin: 16px 0;
    padding-bottom: 16px;
    border-bottom: 1px solid #eee;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 12px;
    background-color: #f8f9fa;
    border-radius: 4px;
}

.stat-label {
    font-size: 0.8rem;
    color: #6c757d;
}

.stat-value {
    font-weight: bold;
    color: #4a90e2;
    font-size: 1.1rem;
}

/* Event Filters */
.event-filters {
    display: flex;
    gap: 8px;
    margin: 12px 0;
}

.event-filters select,
.event-filters input {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
}

.event-filters input {
    flex-grow: 1;
}

/* Enable Password Protection Label */
.settings-row > label {
    display: inline-block;
    margin-bottom: 0.5rem;
    font-weight: bold;
    color: #444;
}

/* Data Password Input */
#dataPassword {
    width: 100%;
    padding: 1rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    transition: border-color 0.3s;
}
#dataPassword:focus {
    border-color: #4a90e2; /* Highlight on focus */
    outline: none;
    box-shadow: 0 0 5px rgba(74, 144, 226, 0.5); /* Soft glow effect */
}
