/* Qube PTT - Mobile-first Push-to-Talk UI */

:root {
    --primary: #f59e0b;        /* Amber/orange - construction theme */
    --primary-dark: #d97706;
    --primary-light: #fbbf24;
    --bg-dark: #111827;
    --bg-card: #1f2937;
    --bg-card-hover: #374151;
    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --success: #10b981;
    --danger: #ef4444;
    --talking: #22c55e;
    --ai-accent: #8b5cf6;      /* Purple for AI features */
    --ai-accent-dark: #7c3aed;
    --ai-accent-light: #a78bfa;
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3);
}

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

html {
    font-size: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    max-width: 500px;
    margin: 0 auto;
    padding: 1rem;
    padding-bottom: env(safe-area-inset-bottom, 1rem);
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    margin-bottom: 1rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
}

.logo-icon {
    width: 28px;
    height: 28px;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

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

.connection-status.connected .status-dot {
    background: var(--success);
    animation: none;
}

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

/* Channel Selector */
.channel-selector {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
}

.channel-selector label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.channel-selector select {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    background: var(--bg-dark);
    border: 2px solid var(--primary);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
}

/* Participants */
.participants {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.participants-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.participant-count {
    background: var(--bg-dark);
    padding: 0.25rem 0.5rem;
    border-radius: 999px;
    font-weight: 600;
}

.participant-list {
    list-style: none;
}

.participant-list li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--bg-dark);
}

.participant-list li:last-child {
    border-bottom: none;
}

.participant-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
}

.participant-name {
    flex: 1;
}

.participant-talking {
    color: var(--talking);
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.participant-talking svg {
    width: 16px;
    height: 16px;
    animation: talking-pulse 0.5s ease-in-out infinite alternate;
}

@keyframes talking-pulse {
    from { transform: scale(1); opacity: 0.7; }
    to { transform: scale(1.2); opacity: 1; }
}

/* Talking Indicator */
.talking-indicator {
    background: linear-gradient(135deg, var(--bg-card), var(--bg-card-hover));
    border: 2px solid var(--bg-card-hover);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.2s ease;
}

.talking-indicator.active {
    border-color: var(--talking);
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.1), rgba(34, 197, 94, 0.05));
}

.talking-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
}

.talking-avatar svg {
    width: 24px;
    height: 24px;
    color: var(--text-secondary);
}

.talking-indicator.active .talking-avatar {
    background: var(--talking);
}

.talking-indicator.active .talking-avatar svg {
    color: white;
    animation: talking-pulse 0.5s ease-in-out infinite alternate;
}

.talking-name {
    font-size: 1.125rem;
    font-weight: 600;
}

/* PTT Button */
.ptt-container {
    text-align: center;
    padding: 0.5rem 0;
}

.ptt-button {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 4px solid var(--primary);
    background: linear-gradient(145deg, var(--bg-card), var(--bg-dark));
    color: var(--primary);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin: 0 auto 0.5rem;
    transition: all 0.15s ease;
    box-shadow: var(--shadow), 0 0 0 0 rgba(245, 158, 11, 0);
    -webkit-tap-highlight-color: transparent;
}

.ptt-button:active,
.ptt-button.active {
    transform: scale(0.95);
    background: var(--primary);
    color: var(--bg-dark);
    box-shadow: var(--shadow), 0 0 30px 10px rgba(245, 158, 11, 0.3);
}

.ptt-icon {
    width: 40px;
    height: 40px;
}

.ptt-label {
    font-size: 0.5rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.ptt-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* ═══════════════════════════════════════════════════════════════════
   AI Assistant Button & Session Overlay
   ═══════════════════════════════════════════════════════════════════ */

.ai-assistant-container {
    text-align: center;
    padding: 0.5rem 0 1rem;
    border-top: 1px solid var(--bg-card-hover);
    margin-top: 0.5rem;
}

.ai-assistant-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.5rem;
    border-radius: 999px;
    border: 2px solid var(--ai-accent);
    background: linear-gradient(145deg, rgba(139, 92, 246, 0.1), rgba(139, 92, 246, 0.05));
    color: var(--ai-accent-light);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.ai-assistant-btn:hover {
    background: linear-gradient(145deg, rgba(139, 92, 246, 0.2), rgba(139, 92, 246, 0.1));
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.3);
}

.ai-assistant-btn:active {
    transform: translateY(0);
}

.ai-icon {
    width: 24px;
    height: 24px;
}

.ai-label {
    font-size: 0.875rem;
}

.ai-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

/* AI Session Overlay */
.ai-session-overlay {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.98);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.ai-session-overlay.hidden {
    display: none;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.ai-session-content {
    width: 100%;
    max-width: 400px;
    padding: 2rem;
    text-align: center;
}

.ai-session-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
    position: relative;
}

.ai-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ai-accent), var(--ai-accent-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    animation: ai-glow 2s ease-in-out infinite alternate;
}

@keyframes ai-glow {
    from { box-shadow: 0 0 20px rgba(139, 92, 246, 0.4); }
    to { box-shadow: 0 0 40px rgba(139, 92, 246, 0.8); }
}

.ai-avatar svg {
    width: 32px;
    height: 32px;
    color: white;
}

.ai-session-info h3 {
    font-size: 1.25rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.ai-status {
    font-size: 0.875rem;
    color: var(--success);
}

.ai-status.listening {
    color: var(--ai-accent-light);
}

.ai-status.speaking {
    color: var(--talking);
}

.ai-end-btn {
    position: absolute;
    top: -1rem;
    right: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.ai-end-btn:hover {
    background: var(--danger);
    color: white;
}

.ai-end-btn svg {
    width: 20px;
    height: 20px;
}

/* AI Audio Visualizer */
.ai-session-visualizer {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    height: 60px;
    margin: 2rem 0;
}

.ai-wave {
    width: 4px;
    height: 20px;
    background: var(--ai-accent);
    border-radius: 2px;
    animation: ai-wave 1.2s ease-in-out infinite;
}

.ai-wave:nth-child(1) { animation-delay: 0s; }
.ai-wave:nth-child(2) { animation-delay: 0.1s; }
.ai-wave:nth-child(3) { animation-delay: 0.2s; }
.ai-wave:nth-child(4) { animation-delay: 0.3s; }
.ai-wave:nth-child(5) { animation-delay: 0.4s; }

@keyframes ai-wave {
    0%, 100% { height: 20px; opacity: 0.5; }
    50% { height: 50px; opacity: 1; }
}

.ai-session-overlay.ai-listening .ai-wave {
    background: var(--ai-accent-light);
    animation-duration: 0.6s;
}

.ai-session-overlay.ai-speaking .ai-wave {
    background: var(--talking);
    animation-duration: 0.4s;
}

.ai-session-hint {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

/* AI PTT Button (in overlay) */
.ai-ptt-button {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    border: 4px solid var(--ai-accent);
    background: linear-gradient(145deg, var(--bg-card), var(--bg-dark));
    color: var(--ai-accent);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin: 0 auto;
    transition: all 0.15s ease;
    box-shadow: var(--shadow), 0 0 0 0 rgba(139, 92, 246, 0);
    -webkit-tap-highlight-color: transparent;
}

.ai-ptt-button:active,
.ai-ptt-button.active {
    transform: scale(0.95);
    background: var(--ai-accent);
    color: white;
    box-shadow: var(--shadow), 0 0 30px 10px rgba(139, 92, 246, 0.4);
}

.ai-ptt-icon {
    width: 48px;
    height: 48px;
}

.ai-ptt-button span {
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* Direct call button styling */
.direct-call-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--bg-dark);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.direct-call-btn:hover {
    background: var(--primary);
    color: var(--bg-dark);
}

.direct-call-btn svg {
    width: 16px;
    height: 16px;
}

/* End direct call button */
.end-direct-call-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: none;
    background: var(--danger);
    color: white;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    margin-top: 0.5rem;
}

.end-direct-call-btn svg {
    width: 16px;
    height: 16px;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 100;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 2rem;
    width: 100%;
    max-width: 360px;
}

.modal-content h2 {
    margin-bottom: 1.5rem;
    text-align: center;
    color: var(--primary);
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    background: var(--bg-dark);
    border: 1px solid var(--bg-card-hover);
    border-radius: 8px;
    color: var(--text-primary);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
}

.btn-primary {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    font-weight: 600;
    background: var(--primary);
    color: var(--bg-dark);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    margin-top: 1rem;
    transition: background 0.2s ease;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-secondary);
}

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