/* NewTalkie - Modern Walkie-Talkie UI */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #4F46E5;
    --primary-dark: #4338CA;
    --success: #10B981;
    --danger: #EF4444;
    --warning: #F59E0B;
    --bg-dark: #1F2937;
    --bg-darker: #111827;
    --bg-card: #374151;
    --text-primary: #F9FAFB;
    --text-secondary: #9CA3AF;
    --border: #4B5563;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-darker);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
}

/* Screens */
.screen {
    display: none;
    min-height: 100vh;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* Join Screen */
#join-screen {
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, var(--bg-darker) 0%, var(--bg-dark) 100%);
}

#join-screen .container {
    width: 100%;
    max-width: 400px;
    padding: 40px 20px;
}

.logo {
    text-align: center;
    margin-bottom: 40px;
}

.logo .icon {
    font-size: 64px;
    display: block;
    margin-bottom: 16px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.logo h1 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(90deg, var(--primary), #818CF8);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

.logo p {
    color: var(--text-secondary);
    font-size: 16px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border);
    border-radius: 12px;
    background: var(--bg-dark);
    color: var(--text-primary);
    font-size: 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.form-group input::placeholder {
    color: var(--text-secondary);
}

.btn-primary {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 12px;
    background: var(--primary);
    color: white;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s, opacity 0.2s;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
}

.btn-primary:active:not(:disabled) {
    transform: scale(0.98);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.info-text {
    margin-top: 24px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}

/* Talkie Screen */
#talkie-screen {
    background: var(--bg-darker);
}

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--bg-dark);
    border-bottom: 1px solid var(--border);
}

.room-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.room-icon {
    font-size: 20px;
}

.user-count {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-card);
    border-radius: 20px;
    font-size: 14px;
}

.user-count span:first-child {
    font-weight: 700;
    color: var(--success);
}

.btn-leave {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.btn-leave:hover {
    background: var(--danger);
    color: white;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: 20px;
    overflow: hidden;
}

/* Users Panel */
.users-panel {
    background: var(--bg-dark);
    border-radius: 16px;
    padding: 16px;
    max-height: 200px;
    overflow-y: auto;
}

.users-panel h3 {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#users-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

#users-list li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--bg-card);
    border-radius: 20px;
    font-size: 14px;
    transition: background 0.2s, transform 0.2s;
}

#users-list li.talking {
    background: var(--success);
    color: white;
    animation: talkingPulse 0.5s infinite alternate;
}

@keyframes talkingPulse {
    from { transform: scale(1); }
    to { transform: scale(1.05); }
}

#users-list li .user-icon {
    font-size: 16px;
}

#users-list li.me {
    border: 2px solid var(--primary);
}

/* PTT Container */
.ptt-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.talking-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    background: var(--success);
    border-radius: 30px;
    font-weight: 600;
    animation: fadeIn 0.3s;
}

.talking-indicator.hidden {
    display: none;
}

.talking-indicator .pulse {
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    animation: pulseDot 0.5s infinite alternate;
}

@keyframes pulseDot {
    from { opacity: 0.5; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1.2); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.ptt-button {
    width: 200px;
    height: 200px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(145deg, var(--bg-card), var(--bg-dark));
    box-shadow: 
        8px 8px 20px rgba(0, 0, 0, 0.4),
        -8px -8px 20px rgba(255, 255, 255, 0.05);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

.ptt-button:hover {
    transform: scale(1.02);
}

.ptt-button:active,
.ptt-button.active {
    transform: scale(0.95);
    background: linear-gradient(145deg, var(--danger), #DC2626);
    box-shadow: 
        inset 4px 4px 10px rgba(0, 0, 0, 0.3),
        inset -4px -4px 10px rgba(255, 255, 255, 0.05);
}

.ptt-button .ptt-icon {
    font-size: 64px;
    transition: transform 0.2s;
}

.ptt-button:active .ptt-icon,
.ptt-button.active .ptt-icon {
    transform: scale(1.2);
}

.ptt-button .ptt-text {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.ptt-button:active .ptt-text,
.ptt-button.active .ptt-text {
    color: white;
}

.ptt-hint {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Status Bar */
.status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--bg-dark);
    border-top: 1px solid var(--border);
    font-size: 14px;
}

.status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-secondary);
}

.status.connected .dot {
    background: var(--success);
    animation: statusPulse 2s infinite;
}

.status.disconnected .dot {
    background: var(--danger);
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

#my-username {
    color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 480px) {
    .ptt-button {
        width: 160px;
        height: 160px;
    }
    
    .ptt-button .ptt-icon {
        font-size: 48px;
    }
    
    .users-panel {
        max-height: 150px;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-darker);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}
