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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    user-select: none;
}

#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 400px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 0;
}

@media (min-width: 768px) {
    #app {
        margin: 20px auto;
        border-radius: 20px;
    }
}

.header {
    background: #2196F3;
    color: white;
    padding: 20px;
    text-align: center;
    border-radius: 20px 20px 0 0;
}

.header h1 {
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.channel-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    opacity: 0.9;
}

.main {
    flex: 1;
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    gap: 25px;
    align-items: center;
}

.channel-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 20px;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 25px;
    font-weight: 500;
    width: 100%;
    max-width: 280px;
    justify-content: center;
}

.channel-selector label {
    color: #495057;
    font-size: 0.9rem;
}

.channel-input {
    width: 80px;
    padding: 8px 12px;
    border: 2px solid #dee2e6;
    border-radius: 15px;
    text-align: center;
    font-size: 1rem;
    font-weight: 600;
    color: #495057;
    outline: none;
    transition: all 0.3s ease;
}

.channel-input:focus {
    border-color: #2196f3;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.join-btn {
    padding: 8px 16px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 15px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.join-btn:hover:not(:disabled) {
    background: #218838;
    transform: translateY(-1px);
}

.join-btn:active:not(:disabled) {
    transform: translateY(0);
}

.join-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

.status-panel {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
    width: 100%;
}

.status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    border-radius: 25px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.status.connected {
    background: #e8f5e8;
    color: #2e7d2e;
}

.status.disconnected {
    background: #ffeaea;
    color: #d32f2f;
}

.status.error {
    background: #fff3cd;
    color: #856404;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse 2s infinite;
}

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

.speaking-indicator {
    padding: 15px 20px;
    background: #f0f4ff;
    border: 2px solid #e3f2fd;
    border-radius: 25px;
    color: #1565c0;
    font-weight: 500;
    opacity: 0;
    transform: scale(0.9);
    transition: all 0.3s ease;
}

.speaking-indicator.active {
    opacity: 1;
    transform: scale(1);
    background: #e3f2fd;
    border-color: #2196f3;
}

.controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    width: 100%;
}

.ptt-button {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #4caf50, #45a049);
    color: white;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: 0 4px 20px rgba(76, 175, 80, 0.3);
    position: relative;
    overflow: hidden;
}

.ptt-button:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 6px 25px rgba(76, 175, 80, 0.4);
}

.ptt-button:active:not(:disabled),
.ptt-button.recording {
    background: linear-gradient(135deg, #f44336, #d32f2f);
    transform: scale(0.95);
    box-shadow: 0 2px 15px rgba(244, 67, 54, 0.4);
}

.ptt-button.recording::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    animation: ripple 1s infinite;
}

@keyframes ripple {
    0% {
        transform: scale(0.8);
        opacity: 1;
    }
    100% {
        transform: scale(1.2);
        opacity: 0;
    }
}

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

.ptt-button .ptt-icon {
    font-size: 2rem;
    margin-bottom: 5px;
}

.ptt-button .ptt-text {
    font-size: 0.8rem;
    text-align: center;
    line-height: 1.2;
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: 200px;
}

.volume-control label {
    font-weight: 500;
    color: #555;
}

.volume-control input[type="range"] {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
}

.volume-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #2196f3;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.volume-control input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #2196f3;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.beep-control {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 200px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 500;
    color: #555;
    font-size: 0.9rem;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.checkmark {
    width: 20px;
    height: 20px;
    border: 2px solid #ddd;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
}

.checkbox-label input[type="checkbox"]:checked + .checkmark {
    background: #2196f3;
    border-color: #2196f3;
}

.checkbox-label input[type="checkbox"]:checked + .checkmark::after {
    content: '✓';
    color: white;
    font-size: 12px;
    font-weight: bold;
}

.checkbox-label:hover .checkmark {
    border-color: #2196f3;
    transform: scale(1.05);
}

.checkbox-label input[type="checkbox"]:checked + .checkmark:hover {
    background: #1976d2;
}

.instructions {
    text-align: center;
    color: #666;
    font-size: 0.9rem;
    line-height: 1.5;
    max-width: 300px;
}

.instructions p {
    margin-bottom: 8px;
}

.footer {
    text-align: center;
    padding: 20px;
    color: #888;
    font-size: 0.8rem;
    border-top: 1px solid #eee;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .main {
        padding: 20px 15px;
        gap: 20px;
    }

    .ptt-button {
        width: 100px;
        height: 100px;
    }

    .ptt-button .ptt-icon {
        font-size: 1.5rem;
    }

    .header {
        padding: 15px;
    }

    .header h1 {
        font-size: 1.3rem;
    }
}

/* Focus styles for accessibility */
.ptt-button:focus-visible {
    outline: 3px solid #2196f3;
    outline-offset: 3px;
}

input[type="range"]:focus-visible {
    outline: 2px solid #2196f3;
    outline-offset: 2px;
}

/* Service Worker Update Animation */
@keyframes pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.7);
    }
    70% {
        transform: scale(1.02);
        box-shadow: 0 0 0 8px rgba(76, 175, 80, 0);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0);
    }
}

/* Message History Panel */
.history-panel {
    margin: 20px auto;
    max-width: 600px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 15px;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    overflow: hidden;
}

.history-panel.collapsed {
    max-height: 60px;
}

.history-panel:not(.collapsed) {
    max-height: 500px;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.history-header h3 {
    margin: 0;
    font-size: 18px;
    color: white;
}

.history-controls {
    display: flex;
    gap: 10px;
}

.play-all-btn,
.history-toggle-btn {
    background: rgba(33, 150, 243, 0.8);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.play-all-btn:hover,
.history-toggle-btn:hover {
    background: rgba(33, 150, 243, 1);
    transform: translateY(-1px);
}

.play-all-btn:active,
.history-toggle-btn:active {
    transform: translateY(0);
}

.history-list {
    max-height: 400px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 5px;
}

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

.history-empty {
    color: rgba(255, 255, 255, 0.6);
    text-align: center;
    padding: 20px;
    font-style: italic;
}

.history-message {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
}

.history-message:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(33, 150, 243, 0.5);
}

.history-message.playing {
    background: rgba(33, 150, 243, 0.3);
    border-color: rgba(33, 150, 243, 0.8);
    box-shadow: 0 0 10px rgba(33, 150, 243, 0.5);
}

.history-message-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.history-user {
    color: rgba(33, 150, 243, 1);
    font-weight: 600;
    font-size: 14px;
}

.history-timestamp {
    color: rgba(0, 0, 0, 0.7);
    font-size: 12px;
}

.history-duration {
    color: rgba(0, 0, 0, 0.8);
    font-size: 13px;
    font-weight: 500;
}

.history-play-btn {
    background: rgba(76, 175, 80, 0.8);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.history-play-btn:hover {
    background: rgba(76, 175, 80, 1);
    transform: scale(1.1);
}

.history-play-btn:active {
    transform: scale(0.95);
}

.history-play-btn.playing {
    background: rgba(244, 67, 54, 0.8);
}

.history-play-btn.playing:hover {
    background: rgba(244, 67, 54, 1);
}

/* Scrollbar styling for history list */
.history-list::-webkit-scrollbar {
    width: 6px;
}

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

.history-list::-webkit-scrollbar-thumb {
    background: rgba(33, 150, 243, 0.5);
    border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb:hover {
    background: rgba(33, 150, 243, 0.8);
}

/* Responsive adjustments for history panel */
@media (max-width: 768px) {
    .history-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .history-controls {
        width: 100%;
        justify-content: space-between;
    }

    .history-message-info {
        font-size: 12px;
    }

    .history-user {
        font-size: 13px;
    }
}
/* Authentication link */
.auth-link {
    margin-top: 10px;
    text-align: center;
}

.auth-link-btn {
    display: inline-block;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.9em;
    transition: background 0.3s;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.auth-link-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* User menu */
.user-menu {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    backdrop-filter: blur(5px);
}

.user-menu-username {
    color: #fff;
    font-weight: 500;
    font-size: 0.9rem;
}

.user-menu-btn {
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.user-menu-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
}

.user-menu-btn:active {
    transform: translateY(0);
}

.user-menu-btn-primary {
    background: rgba(33, 150, 243, 0.8);
    border-color: rgba(33, 150, 243, 0.5);
}

.user-menu-btn-primary:hover {
    background: rgba(33, 150, 243, 1);
    border-color: rgba(33, 150, 243, 0.8);
}

@media (max-width: 480px) {
    .user-menu {
        flex-wrap: wrap;
        gap: 6px;
        padding: 8px;
    }

    .user-menu-username {
        font-size: 0.8rem;
        width: 100%;
        text-align: center;
    }

    .user-menu-btn {
        padding: 5px 10px;
        font-size: 0.75rem;
        flex: 1;
    }
}

/* Notification System */
.notification-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 90%;
    width: 400px;
    pointer-events: none;
}

.notification {
    background: #f44336;
    color: white;
    padding: 16px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 12px;
    pointer-events: all;
    animation: slideIn 0.3s ease-out;
    font-size: 0.95rem;
    line-height: 1.4;
}

.notification.success {
    background: #4caf50;
}

.notification.warning {
    background: #ff9800;
}

.notification.info {
    background: #2196f3;
}

.notification-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.notification-message {
    flex: 1;
}

.notification-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s;
    flex-shrink: 0;
}

.notification-close:hover {
    opacity: 1;
}

@keyframes slideIn {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateY(0);
        opacity: 1;
    }
    to {
        transform: translateY(-100%);
        opacity: 0;
    }
}

.notification.hiding {
    animation: slideOut 0.3s ease-in forwards;
}
