/**
 * Advanced Premium UI - Ukken Chat
 * Dark mode, Glassmorphism, Smooth Animations
 */

:root {
    --bg-color: #0f172a;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --secondary: #10b981;
    --secondary-hover: #059669;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    overflow: hidden;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    -webkit-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Background animated shapes */
.bg-shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    z-index: -1;
    animation: float 20s infinite alternate ease-in-out;
}

.shape-1 {
    width: 40vw;
    height: 40vw;
    background: rgba(59, 130, 246, 0.3);
    top: -10%;
    left: -10%;
}

.shape-2 {
    width: 30vw;
    height: 30vw;
    background: rgba(16, 185, 129, 0.2);
    bottom: -10%;
    right: -10%;
    animation-delay: -5s;
}

.shape-3 {
    width: 25vw;
    height: 25vw;
    background: rgba(139, 92, 246, 0.2);
    top: 40%;
    left: 40%;
    animation-delay: -10s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(50px, 50px) scale(1.1); }
}

/* Glassmorphism Panel */
.app-container {
    width: 95%;
    max-width: 1400px;
    height: 90vh;
    position: relative;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    padding: 2rem;
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transform: scale(0.95);
    transition: var(--transition);
}

.glass-panel.active {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
    z-index: 10;
}

/* Setup Screen */
#setup-screen {
    align-items: center;
    justify-content: center;
    text-align: center;
}

.brand-title {
    font-size: 3rem;
    font-weight: 700;
    background: linear-gradient(to right, #60a5fa, #34d399);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
    margin-bottom: 3rem;
}

.actions-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.5rem;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.action-card {
    flex: 1 1 300px;
    min-width: 320px;
    max-width: 400px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: var(--transition);
}

.action-card:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.05);
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.icon-circle {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
}

.host-icon {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

.join-icon {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
}

.roni-icon {
    background: rgba(139, 92, 246, 0.2);
    color: #a78bfa;
}

.icon-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.1);
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.25rem;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}
.icon-btn:hover {
    background: rgba(255,255,255,0.2);
    transform: scale(1.05);
}

h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.action-card p {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
    height: 45px;
}

/* Inputs & Buttons */
input {
    width: 100%;
    padding: 1rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: white;
    font-size: 1rem;
    font-family: inherit;
    text-align: center;
    margin-bottom: 1rem;
    transition: var(--transition);
}

input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.btn {
    width: 100%;
    padding: 1rem;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    color: white;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.primary-btn {
    background: var(--primary);
}
.primary-btn:hover:not(:disabled) {
    background: var(--primary-hover);
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

.secondary-btn {
    background: var(--secondary);
}
.secondary-btn:hover:not(:disabled) {
    background: var(--secondary-hover);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}

.danger-btn {
    background: var(--danger);
}
.danger-btn:hover:not(:disabled) {
    background: var(--danger-hover);
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
}

.divider {
    display: flex;
    align-items: center;
    color: var(--text-muted);
}
.divider span {
    padding: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.hidden {
    display: none !important;
}

/* Passcode UI */
#passcode-display {
    width: 100%;
    margin-top: 1.5rem;
    animation: fadeIn 0.5s ease;
}

.passcode-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0,0,0,0.4);
    border: 1px dashed var(--primary);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin: 0.5rem 0 1rem;
}

#passcode-text {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: #60a5fa;
}

#copy-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    transition: var(--transition);
}

#copy-btn:hover {
    color: white;
}

.waiting-text {
    color: #fbbf24 !important;
    font-size: 0.9rem !important;
}

.error-text {
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.2);
    padding: 1rem;
    border-radius: 8px;
    margin-top: 2rem;
    width: 100%;
    max-width: 600px;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Video Call Screen */
#video-screen {
    padding: 1rem;
    gap: 1rem;
}

.video-wrapper {
    flex: 1;
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    background: #000;
    border: 1px solid var(--glass-border);
}

/* Dynamic Video Grid */
.video-grid {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    gap: 4px;
    padding: 4px;
    position: relative;
}
.video-grid[data-count="2"] {
    grid-template-columns: 1fr 1fr;
}
.video-grid[data-count="3"] {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}
.video-grid[data-count="3"] .grid-tile:first-child {
    grid-column: 1 / -1;
}
.video-grid[data-count="4"] {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

/* Individual video tile in the grid */
.grid-tile {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    background: #111;
}
.grid-tile video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.grid-tile .tile-label {
    position: absolute;
    bottom: 0.5rem;
    left: 0.5rem;
    background: rgba(0,0,0,0.6);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    color: white;
    z-index: 2;
}

/* Participant counter badge */
.participant-count {
    position: absolute;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    padding: 0.4rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
}

.local-video-container {
    position: absolute;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 200px;
    aspect-ratio: 4/3;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid rgba(255,255,255,0.2);
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    background: #111;
    z-index: 2;
    transition: var(--transition);
}

.local-video-container:hover {
    transform: scale(1.05);
}

#local-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
    transition: filter 0.3s ease;
}

.local-label {
    position: absolute;
    bottom: 0.5rem;
    left: 0.5rem;
    background: rgba(0,0,0,0.6);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    color: white;
}

.status-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.25rem;
    color: rgba(255,255,255,0.6);
    z-index: 1;
}

.controls-bar {
    height: 80px;
    background: rgba(15, 23, 42, 0.4);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    border: 1px solid var(--glass-border);
}

.control-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-3px);
}

.control-btn.disabled {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.4);
}

.control-btn.danger {
    background: var(--danger);
}
.control-btn.danger:hover {
    background: var(--danger-hover);
}

@media (max-width: 768px) {
    .actions-container {
        flex-direction: column;
        gap: 1.5rem;
    }
    .divider {
        display: none;
    }
    .local-video-container {
        width: 120px;
        bottom: 1rem;
        right: 1rem;
    }
    .glass-panel {
        padding: 1.5rem;
    }
    h1.brand-title {
        font-size: 2rem;
    }
}

/* Background Blur Toggle Active State */
.controls-bar .control-btn.blur-active {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.5), rgba(59, 130, 246, 0.5)) !important;
    color: #c4b5fd !important;
    border: 1px solid rgba(139, 92, 246, 0.6) !important;
    box-shadow: 0 0 16px rgba(139, 92, 246, 0.4), inset 0 0 8px rgba(139, 92, 246, 0.15) !important;
}
.controls-bar .control-btn.blur-active:hover {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.6), rgba(59, 130, 246, 0.6)) !important;
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.5), inset 0 0 10px rgba(139, 92, 246, 0.2) !important;
}

/* Video blur overlays */
.video-blur-overlay {
    position: absolute;
    inset: 0;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s ease;
    border-radius: inherit;
}
.video-blur-overlay.active {
    opacity: 1;
}

/* Connection quality indicator */
.connection-quality {
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 3;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    padding: 0.4rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.connection-quality.visible {
    opacity: 1;
}
.connection-quality .quality-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: pulse-dot 2s infinite;
}
.connection-quality .quality-dot.excellent {
    background: #34d399;
    box-shadow: 0 0 6px #34d399;
}
.connection-quality .quality-dot.good {
    background: #fbbf24;
    box-shadow: 0 0 6px #fbbf24;
}
.connection-quality .quality-dot.poor {
    background: #ef4444;
    box-shadow: 0 0 6px #ef4444;
}

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

/* Call duration timer */
.call-timer {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 3;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    padding: 0.4rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    color: rgba(255,255,255,0.8);
    font-variant-numeric: tabular-nums;
}

/* Allow selection on inputs and passcode text */
input, .passcode-box span {
    -webkit-user-select: text;
    -ms-user-select: text;
    user-select: text;
}
