/* ============================================
   MINIMAL VIDEO CALLING PLATFORM STYLES
   ============================================ */

:root {
    --primary: #0d6efd;
    --success: #198754;
    --danger: #dc3545;
    --dark: #212529;
    --light: #f8f9fa;
    --white: #ffffff;
    --border: #dee2e6;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--light);
    color: var(--dark);
    overflow: hidden;
}

.screen {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.d-none {
    display: none !important;
}

/* ============================================
   LOGIN SCREEN
   ============================================ */
#loginScreen {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    overflow-y: auto;
}

.card {
    border-radius: 1rem;
}

/* Bigger logo */
.login-logo img{
    width:160px;
    height:auto;
}

/* Webcalling title smaller than logo */
.webcalling-title{
    font-size:24px;
    font-weight:700;
    letter-spacing:1px;
}

/* Divider */
.divider {
    text-align: center;
    position: relative;
    margin: 1.5rem 0;
}

.divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border);
}

.divider-text {
    background: var(--white);
    padding: 0 1rem;
    position: relative;
    color: #6c757d;
    font-size: 0.875rem;
}

/* ============================================
   LOBBY SCREEN
   ============================================ */
#lobbyScreen {
    background: var(--light);
}

.stat-card {
    transition: transform 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.user-card {
    transition: all 0.2s ease;
    border-left: 3px solid transparent !important;
}

.user-card:hover {
    background-color: #f8f9fa;
    border-left-color: var(--primary) !important;
}

.online-users-scroll {
    overflow-y: auto;
    max-height: 600px;
}

@media (max-width: 991.98px) {
    .online-users-scroll {
        max-height: 400px;
    }
}

/* ============================================
   CALLING SCREEN
   ============================================ */
#callingScreen {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.calling-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.calling-content {
    text-align: center;
    color: white;
}

.calling-animation i {
    font-size: 5rem;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(1.1);
    }
}

/* ============================================
   CALL SCREEN - MAIN STRUCTURE
   ============================================ */
#callScreen {
    background: #000;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
}

/* Call Header */
.call-header {
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    z-index: 100;
}

.call-info {
    color: white;
    font-size: 0.875rem;
}

.call-duration {
    font-weight: 600;
}

.call-separator {
    margin: 0 0.5rem;
    opacity: 0.5;
}

.participants-count {
    opacity: 0.8;
}

.recording-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(220, 53, 69, 0.15);
    border: 1px solid rgba(220, 53, 69, 0.4);
    padding: 0.2rem 0.6rem;
    border-radius: 0.5rem;
}

.recording-indicator .dot {
    width: 10px;
    height: 10px;
    background: #dc3545;
    border-radius: 50%;
    animation: blink 1.2s infinite;
}

.recording-indicator .text {
    color: #dc3545;
    font-weight: 700;
    font-size: 0.7rem;
    letter-spacing: 0.5px;
}

@keyframes blink {
    0% { opacity: 1; }
    50% { opacity: 0.2; }
    100% { opacity: 1; }
}

#callRecordBtn.recording {
    background: var(--danger) !important;
    color: white !important;
    animation: pulse-red 2s infinite;
}

@keyframes pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.6); }
    70% { box-shadow: 0 0 0 10px rgba(220, 53, 69, 0); }
    100% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0); }
}

.btn-header {
    color: white;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    margin-left: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    transition: all 0.2s;
}

.btn-header:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* Video Stage */
.video-stage {
    flex: 1;
    position: relative;
    background: #000;
    overflow: hidden;
    display: flex;
}

/* ============================================
   SPEAKER VIEW (Default)
   ============================================ */

/* Thumbnail Strip - Horizontal on Mobile, Sidebar on Desktop */
.thumbnail-strip {
    z-index: 50;
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

/* Desktop Sidebar for Speaker View */
@media (min-width: 992px) {
    #callScreen:not(.grid-view) .video-stage {
        flex-direction: row-reverse;
    }
    #callScreen:not(.grid-view) .thumbnail-strip {
        flex-direction: column;
        width: 200px;
        height: 100%;
        overflow-y: auto;
        overflow-x: hidden;
        border-right: none;
        border-left: 1px solid rgba(255, 255, 255, 0.1);
    }
    #callScreen:not(.grid-view) .thumbnail-video {
        width: 100%;
        aspect-ratio: 16/9;
        height: auto;
    }
}

/* Mobile/Tablet: Horizontal Strip at Top */
@media (max-width: 991.98px) {
    #callScreen:not(.grid-view) .video-stage {
        flex-direction: column;
    }
    #callScreen:not(.grid-view) .thumbnail-strip {
        flex-direction: row;
        width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
    }
    .thumbnail-video {
        width: 120px;
        aspect-ratio: 16/9;
        height: auto;
    }
}

.thumbnail-strip::-webkit-scrollbar {
    display: none;
}

/* Video Overlay UI Overlays */
.video-stats-overlay {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    color: #ffffff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    font-family: 'Inter', system-ui, sans-serif;
    z-index: 50;
    pointer-events: none;
    display: flex;
    gap: 5px;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.video-stats-overlay i {
    font-size: 0.75rem;
}

.video-stats-overlay span {
    letter-spacing: -0.1px;
}

.cam-off-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #111;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    color: #555;
    font-size: 2rem;
    border-radius: inherit;
}

.thumbnail-video {
    flex-shrink: 0;
    border-radius: 0.75rem;
    overflow: hidden;
    background: #1a1a1a;
    border: 2px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
}

.thumbnail-video:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.thumbnail-video.active {
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(13, 110, 253, 0.3);
}

.thumbnail-video.speaking,
.video-container.speaking {
    border-color: var(--user-color, #00ecff) !important;
    box-shadow: 
        0 0 20px var(--user-color-alpha, rgba(0, 236, 255, 0.9)), 
        inset 0 0 10px var(--user-color-alpha, rgba(0, 236, 255, 0.5)) !important;
    transition: all 0.1s ease-in-out;
}

/* Ensure the speaker highlight is very bright */
.thumbnail-video.speaking::after,
.video-container.speaking::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 3px solid var(--user-color, #00ecff);
    border-radius: inherit;
    pointer-events: none;
    z-index: 60;
    box-shadow: 0 0 15px var(--user-color, #00ecff);
}

.thumbnail-video video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Main Video Area */
.main-video-area {
    flex: 1;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 1rem;
}

.main-video {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    position: relative;
    border-radius: 0.75rem;
    overflow: hidden;
}

.main-video video {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 0.75rem;
}

/* Portrait Video on Desktop (constrain width) */
@media (min-width: 992px) {
    .main-video video[data-portrait="true"] {
        max-width: 45%; /* Don't let portrait video be too wide on desktop */
    }
}

/* ============================================
   GRID VIEW
   ============================================ */
#callScreen.grid-view .thumbnail-strip {
    display: none;
}

#callScreen.grid-view .main-video-area {
    display: grid;
    gap: 1rem;
    padding: 1.5rem;
    width: 100%;
    height: 100%;
    align-content: center;
    justify-content: center;
    overflow-y: auto;
}

/* Grid layout based on count */
#callScreen.grid-view .main-video-area[data-count="1"] {
    grid-template-columns: minmax(300px, 1000px);
}

#callScreen.grid-view .main-video-area[data-count="2"] {
    grid-template-columns: repeat(2, minmax(280px, 1fr));
}

#callScreen.grid-view .main-video-area[data-count="3"],
#callScreen.grid-view .main-video-area[data-count="4"] {
    grid-template-columns: repeat(2, minmax(250px, 1fr));
}

#callScreen.grid-view .main-video-area[data-count="5"],
#callScreen.grid-view .main-video-area[data-count="6"] {
    grid-template-columns: repeat(3, minmax(200px, 1fr));
}

#callScreen.grid-view .main-video-area[data-count="7"],
#callScreen.grid-view .main-video-area[data-count="8"],
#callScreen.grid-view .main-video-area[data-count="9"] {
    grid-template-columns: repeat(3, minmax(180px, 1fr));
}

#callScreen.grid-view .main-video-area[data-count="10"] {
    grid-template-columns: repeat(4, minmax(150px, 1fr));
}

/* Mobile specific grid adjustments */
@media (max-width: 768px) {
    #callScreen.grid-view .main-video-area {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) !important;
        gap: 0.75rem;
        padding: 0.75rem;
        align-content: flex-start;
    }
}

.video-container {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 0.75rem;
    overflow: hidden;
    background: #111;
}

.video-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 0.75rem;
}

/* Name Label */
.name-label {
    position: absolute;
    bottom: 0.75rem;
    left: 0.75rem;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(10px);
    color: white;
    padding: 0.3rem 0.6rem;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    z-index: 10;
    pointer-events: none;
    transition: all 0.2s ease;
    width: fit-content;
}

.name-label i {
    font-size: 0.7rem;
    opacity: 0.8;
}

.video-container:hover .name-label {
    background: rgba(0, 0, 0, 0.7);
}

/* ============================================
   CALL CONTROLS (Footer)
   ============================================ */
.call-footer {
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(20px);
    height: 80px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    z-index: 100;
}



.call-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    width: 100%;
    margin: 0 auto;
}

.control-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.control-btn i {
    font-size: 1.4rem;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.control-btn.active {
    background: var(--success);
}

.control-btn.btn-danger {
    background: var(--danger);
    width: 64px;
    border-radius: 2rem;
}

#callScreenBtn {
    background: var(--primary);
    opacity: 0.9;
}

#callScreenBtn:hover {
    background: #0056b3;
    opacity: 1;
}

/* New Flip Button Style */
.flip-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: #ffffff;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: 0.3s;
    flex-shrink: 0;
}

.flip-btn:hover {
    background: #e8e8e8;
}

.camera {
    width: 28px;
    height: 19px;
    border: 2.5px solid #333;
    border-radius: 4px;
    position: relative;
    transition: transform 0.6s;
    perspective: 1000px;
}

.lens {
    width: 9px;
    height: 9px;
    border: 2.5px solid #333;
    border-radius: 50%;
    position: absolute;
    top: 3px;
    left: 7px;
}

.flip-btn:hover .camera {
    transform: rotateY(180deg);
}

.control-btn.btn-danger:hover {
    background: #c82333;
}

/* ============================================
   MOBILE RESPONSIVENESS
   ============================================ */

/* Mobile Portrait (< 576px) */
@media (max-width: 575.98px) {

    /* Thumbnail strip */
    .thumbnail-video {
        width: 100px;
        height: 60px;
    }

    /* Grid view - 1 column */
    #callScreen.grid-view .main-video-area {
        grid-template-columns: 1fr !important;
        gap: 0.5rem;
        padding: 0.5rem;
    }

    .video-container {
        min-height: 150px;
    }

    /* Controls */
    .control-btn {
        width: 48px;
        height: 48px;
    }

    .control-btn i {
        font-size: 1.125rem;
    }

    .control-btn.btn-danger {
        width: 56px;
        height: 48px;
    }

    .call-controls {
        gap: 0.5rem;
    }

    /* Header */
    .call-info {
        font-size: 0.75rem;
    }
}

/* Mobile Landscape & Tablet (576px - 991px) */
@media (min-width: 576px) and (max-width: 991.98px) {

    /* Thumbnail strip */
    .thumbnail-video {
        width: 120px;
        height: 70px;
    }

    /* Grid view - 2 columns */
    #callScreen.grid-view .main-video-area[data-count="2"],
    #callScreen.grid-view .main-video-area[data-count="3"],
    #callScreen.grid-view .main-video-area[data-count="4"],
    #callScreen.grid-view .main-video-area[data-count="5"],
    #callScreen.grid-view .main-video-area[data-count="6"] {
        grid-template-columns: repeat(2, 1fr);
    }

    #callScreen.grid-view .main-video-area {
        gap: 0.75rem;
        padding: 0.75rem;
    }
}

/* Desktop (>= 992px) */
@media (min-width: 992px) {

    /* Show control labels on desktop */
    .control-btn {
        width: 64px;
        height: 64px;
        padding: 0.5rem;
    }

    .control-btn .control-label {
        display: block;
    }

    .control-btn i {
        font-size: 1.5rem;
    }

    .call-controls {
        gap: 1rem;
    }
}

/* Ensure Screen Share button is visible on Desktop and Tablet */
@media (min-width: 768px) {
    #callScreenBtn {
        display: flex !important;
    }
}

/* ============================================
   MODALS
   ============================================ */
.incoming-icon i {
    font-size: 4rem;
    animation: shake 1s ease-in-out infinite;
}

@keyframes shake {

    0%,
    100% {
        transform: rotate(0deg);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: rotate(-10deg);
    }

    20%,
    40%,
    60%,
    80% {
        transform: rotate(10deg);
    }
}

.logout-icon i {
    font-size: 4rem;
}

/* ============================================
   UTILITIES
   ============================================ */
.scrollbar-hidden {
    scrollbar-width: none;
}

.scrollbar-hidden::-webkit-scrollbar {
    display: none;
}

/* Smooth transitions */
.video-container,
.thumbnail-video,
.control-btn {
    transition: all 0.2s ease;
}

/* Loading spinner */
.spinner-border {
    width: 2rem;
    height: 2rem;
}

/* Toast notifications */
.toast {
    min-width: 250px;
}

/* ============================================
   LANDSCAPE MODE OPTIMIZATION (Mobile)
   ============================================ */
@media (max-height: 500px) and (orientation: landscape) {

    .call-header,
    .call-footer {
        padding: 0.5rem 0;
    }

    .thumbnail-strip {
        top: 0.5rem;
    }

    .thumbnail-video {
        width: 80px;
        height: 50px;
    }

    .control-btn {
        width: 44px;
        height: 44px;
    }

    .control-btn.btn-danger {
        width: 52px;
        height: 44px;
    }

    .name-label {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
        bottom: 0.5rem;
        left: 0.5rem;
    }

    #callScreen.grid-view .main-video-area {
        padding: 0.5rem;
        gap: 0.5rem;
    }
}

/* ============================================
   HIGH CONTRAST MODE
   ============================================ */
@media (prefers-contrast: high) {

    .thumbnail-video,
    .video-container {
        border-width: 3px;
    }

    .name-label {
        background: rgba(0, 0, 0, 0.9);
    }
}

/* ============================================
   REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================
   PREMIUM INCOMING CALL MODAL
   ============================================ */

.incoming-call-premium {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(15px);
}

.caller-avatar-container {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto;
}

.caller-avatar-bg {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--primary), #00d2ff);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 25px rgba(13, 110, 253, 0.3);
}

.caller-avatar-ring {
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
    border: 2px solid var(--primary);
    border-radius: 50%;
    animation: ring-pulse 1.5s ease-out infinite;
    z-index: 1;
}

@keyframes ring-pulse {
    0% {
        transform: scale(0.8);
        opacity: 1;
    }
    100% {
        transform: scale(1.4);
        opacity: 0;
    }
}

.btn-call-action {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.btn-call-action:hover {
    transform: scale(1.15);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.btn-accept {
    background: #198754;
    animation: bounce 2s infinite;
}

.btn-decline {
    background: #dc3545;
}

@keyframes bounce {
    0%, 20%, 53%, 80%, 100% {
        transform: translate3d(0, 0, 0);
    }
    40%, 43% {
        transform: translate3d(0, -12px, 0) scaleY(1.1);
    }
    70% {
        transform: translate3d(0, -6px, 0) scaleY(1.05);
    }
    90% {
        transform: translate3d(0, -2px, 0);
    }
}

.ls-wide {
    letter-spacing: 0.15em;
    font-size: 0.75rem;
}

.shadow-2xl {
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

/* ============================================
   RECORDING BUTTON (Separate)
   ============================================ */
.recording-sidebar-container {
    position: absolute;
    right: 2rem;
    height: 100%;
    display: flex;
    align-items: center;
}

.recording-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 1rem;
    padding: 0.5rem 1rem;
    color: white;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 80px;
    gap: 2px;
}

.recording-btn .rec-icon-wrapper {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.recording-btn .rec-icon-wrapper i {
    font-size: 1.4rem;
}

.recording-btn .rec-label {
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.05rem;
    opacity: 0.8;
}

.recording-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.recording-btn.recording-active {
    background: rgba(220, 38, 38, 0.15);
    border-color: rgba(220, 38, 38, 0.5);
    color: #ff4d4d;
    box-shadow: 0 0 15px rgba(220, 38, 38, 0.2);
}

.recording-btn.recording-active .rec-icon-wrapper i {
    animation: pulse-red-icon 1.5s infinite;
}

@keyframes pulse-red-icon {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.7; }
    100% { transform: scale(1); opacity: 1; }
}

@media (max-width: 768px) {
    .recording-sidebar-container {
        position: static;
        margin-left: 0.5rem;
    }
    .recording-btn {
        min-width: auto;
        padding: 0.4rem 0.6rem;
    }
    .recording-btn .rec-label {
        display: none;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {

    .call-header,
    .call-footer,
    .thumbnail-strip {
        display: none;
    }
}

