/*
 * NXCom-Meet application styles that sit on top of the Velzon theme.
 *
 * Everything here is either
 *   a) a class meeting.js / whiteboard.js create at runtime, so it cannot be
 *      replaced with Bootstrap utility classes in the markup, or
 *   b) the video-conference chrome (grid, control bar, drawers) that has no
 *      Velzon equivalent.
 *
 * Colours are aliased onto Velzon's --vz-* tokens so the light/dark switch and
 * the customizer's primary-colour picker keep working here too.
 */

:root {
    --nx-primary: var(--vz-primary, #405189);
    --nx-primary-rgb: var(--vz-primary-rgb, 64, 81, 137);
    --nx-success: var(--vz-success, #0ab39c);
    --nx-danger: var(--vz-danger, #f06548);
    --nx-warning: var(--vz-warning, #f7b84b);
    --nx-info: var(--vz-info, #299cdb);

    /* Aliases consumed by the inline styles inside meeting.js. */
    --primary-color: var(--vz-primary, #405189);
    --primary-light-color: var(--vz-primary, #405189);
    --primary-dark-color: rgba(var(--vz-primary-rgb, 64, 81, 137), .75);
    --success-color: var(--vz-success, #0ab39c);
    --danger-color: var(--vz-danger, #f06548);
    --warning-color: var(--vz-warning, #f7b84b);
    --text-primary-color: var(--vz-body-color, #212529);
    --text-secondary-color: var(--vz-secondary-color, #878a99);
    --text-tertiary-color: var(--vz-secondary-color, #878a99);
    --surface-variant-color: var(--vz-light, #f3f6f9);
    --divider-color: var(--vz-border-color, #e9ebec);
    --shadow-sm: var(--vz-box-shadow-sm, 0 .125rem .25rem rgba(0, 0, 0, .075));
    --shadow-md: var(--vz-box-shadow, 0 .5rem 1rem rgba(0, 0, 0, .15));
    --shadow-lg: var(--vz-box-shadow-lg, 0 1rem 3rem rgba(0, 0, 0, .175));
}

/* ==========================================================================
   Small shared helpers
   ========================================================================== */

.nx-avatar-initial {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 50%;
    background-color: rgba(var(--vz-primary-rgb), .18);
    color: var(--vz-primary);
    font-weight: 600;
    text-transform: uppercase;
    line-height: 1;
}

.nx-cursor-pointer {
    cursor: pointer;
}

.nx-code-pill {
    font-family: var(--vz-font-monospace, monospace);
    letter-spacing: .08em;
    font-weight: 600;
}

/* ==========================================================================
   Dashboard section dividers
   ========================================================================== */

.nx-section-divider {
    position: relative;
    display: flex;
    align-items: center;
    margin: .25rem 0 1.25rem;
}

.nx-section-divider::before,
.nx-section-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent,
        var(--vz-border-color, #e9ebec) 20%,
        var(--vz-border-color, #e9ebec) 80%,
        transparent
    );
}

.nx-section-divider__label {
    display: inline-flex;
    align-items: center;
    gap: .425rem;
    padding: .25rem .875rem;
    margin: 0 .75rem;
    font-size: .6875rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--vz-secondary-color, #878a99);
    background-color: var(--vz-secondary-bg, var(--vz-body-bg, #fff));
    border: 1px solid var(--vz-border-color, #e9ebec);
    border-radius: 2rem;
    white-space: nowrap;
    user-select: none;
}

.nx-section-divider__label i {
    font-size: .8125rem;
    line-height: 1;
}

/* Stat-card coloured left-border accents */

.nx-stat-accent {
    border-left: 3px solid transparent;
    transition: border-color .2s ease-in-out, transform .2s ease-in-out;
}

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

.nx-stat-accent--primary { border-left-color: var(--vz-primary, #405189); }
.nx-stat-accent--success { border-left-color: var(--vz-success, #0ab39c); }
.nx-stat-accent--info    { border-left-color: var(--vz-info, #299cdb); }
.nx-stat-accent--warning { border-left-color: var(--vz-warning, #f7b84b); }

/* ==========================================================================
   Calendar (Home + Calendar pages)
   ========================================================================== */

.nx-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
}

.nx-calendar-dow {
    text-align: center;
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--vz-secondary-color);
    padding: 6px 0;
}

.nx-calendar-cell {
    min-height: 92px;
    padding: 6px;
    border: 1px solid var(--vz-border-color);
    border-radius: var(--vz-border-radius, .25rem);
    background-color: var(--vz-secondary-bg);
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: hidden;
}

.nx-calendar-cell.is-muted {
    background-color: transparent;
    border-color: transparent;
}

.nx-calendar-cell.is-today {
    border-color: rgba(var(--vz-primary-rgb), .5);
    background-color: rgba(var(--vz-primary-rgb), .06);
}

.nx-calendar-daynum {
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: .8125rem;
    font-weight: 600;
    flex-shrink: 0;
    color: var(--vz-body-color);
}

.nx-calendar-cell.is-muted .nx-calendar-daynum {
    color: var(--vz-secondary-color);
    opacity: .5;
}

.nx-calendar-cell.is-today .nx-calendar-daynum {
    background-color: var(--vz-primary);
    color: #fff;
}

.nx-calendar-chip {
    display: block;
    width: 100%;
    text-align: left;
    border: 0;
    font-size: .6875rem;
    font-weight: 600;
    padding: 3px 7px;
    border-radius: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

/* ==========================================================================
   Team chat
   ========================================================================== */

.nx-chat-wrapper {
    display: flex;
    align-items: stretch;
    gap: 1rem;
    min-height: calc(100vh - 240px);
}

.nx-chat-aside {
    width: 300px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.nx-chat-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.nx-chat-list {
    overflow-y: auto;
    max-height: 100%;
}

.nx-chat-list .list-group-item {
    cursor: pointer;
    border-left: 0;
    border-right: 0;
    background-color: transparent;
}

.nx-chat-list .list-group-item.active {
    background-color: rgba(var(--vz-primary-rgb), .1);
    border-color: var(--vz-border-color);
    color: var(--vz-body-color);
}

.nx-chat-list .list-group-item.active .nx-chat-item-name {
    color: var(--vz-primary);
}

.nx-chat-feed {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    min-height: 320px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nx-msg-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 1rem;
}

.nx-msg-group.is-me {
    align-items: flex-end;
}

.nx-bubble {
    position: relative;
    max-width: min(70%, 560px);
    padding: .625rem .875rem;
    border-radius: 1rem 1rem 1rem .25rem;
    background-color: var(--vz-light);
    color: var(--vz-body-color);
    font-size: .875rem;
    line-height: 1.5;
    word-break: break-word;
}

.nx-msg-group.is-me .nx-bubble {
    border-radius: 1rem 1rem .25rem 1rem;
    background-color: var(--vz-primary);
    color: #fff;
}

.nx-bubble .nx-bubble-actions {
    position: absolute;
    top: -2rem;
    right: 0;
    display: flex;
    gap: 2px;
    padding: 2px 4px;
    border-radius: .375rem;
    background-color: var(--vz-secondary-bg);
    border: 1px solid var(--vz-border-color);
    box-shadow: var(--vz-box-shadow-sm);
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s ease-in-out;
}

.nx-msg-group.is-me .nx-bubble .nx-bubble-actions {
    right: auto;
    left: 0;
}

.nx-bubble:hover .nx-bubble-actions {
    opacity: 1;
    pointer-events: auto;
}

.nx-bubble-actions button {
    border: 0;
    background: none;
    padding: 2px 4px;
    font-size: .875rem;
    line-height: 1;
    cursor: pointer;
    color: var(--vz-body-color);
}

.nx-reaction-pill {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    background-color: rgba(var(--vz-dark-rgb, 33, 37, 41), .12);
    border-radius: 1rem;
    padding: 1px 8px;
    font-size: .75rem;
    margin-top: 6px;
    margin-right: 4px;
}

.nx-typing-dots span {
    animation: nxTypingDots 1.4s infinite;
}

.nx-typing-dots span:nth-child(2) {
    animation-delay: .2s;
}

.nx-typing-dots span:nth-child(3) {
    animation-delay: .4s;
}

@keyframes nxTypingDots {
    0%, 20% { opacity: .2; }
    50% { opacity: 1; }
    100% { opacity: .2; }
}

@media (max-width: 991.98px) {
    .nx-chat-wrapper {
        flex-direction: column;
        min-height: 0;
    }

    .nx-chat-aside {
        width: 100%;
    }

    .nx-chat-list {
        max-height: 260px;
    }
}

/* ==========================================================================
   Pre-join lobby
   ========================================================================== */

.nx-prejoin-preview {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background-color: #16181d;
    border-radius: var(--vz-border-radius, .25rem);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nx-prejoin-preview video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}

.nx-prejoin-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .75rem;
    color: rgba(255, 255, 255, .65);
}

.nx-qr-box {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: #fff;
    padding: 8px;
    border-radius: var(--vz-border-radius, .25rem);
}

/* ==========================================================================
   Meeting room
   ========================================================================== */

.meet-room-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    width: 100%;
    background-color: #101216;
    color: #fff;
    overflow: hidden;
    position: relative;
}

.meet-header {
    flex-shrink: 0;
    min-height: 60px;
    padding: .5rem 1.25rem;
    background-color: rgba(15, 17, 21, .92);
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    z-index: 10;
}

.meet-grid-wrapper {
    flex: 1;
    position: relative;
    padding: 1rem 1rem 6.5rem;
    display: flex;
    gap: 1rem;
    overflow: hidden;
}

#videoGridContainer {
    flex: 1;
    min-width: 0;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    grid-auto-rows: 1fr;
    gap: 1rem;
    align-content: center;
}

.meet-video-tile {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 200px;
    background-color: #1b1e24;
    border-radius: .75rem;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, .07);
    box-shadow: var(--shadow-md);
    transition: box-shadow .25s ease-in-out, border-color .25s ease-in-out;
}

.meet-video-tile.pinned {
    border-color: var(--nx-primary);
    box-shadow: 0 0 0 2px var(--nx-primary);
}

.meet-video-tile.speaking {
    box-shadow: 0 0 0 3px var(--nx-success);
}

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

.meet-video-tile .avatar-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .75rem;
    z-index: 2;
    color: rgba(255, 255, 255, .7);
}

.meet-video-tile .avatar-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background-color: var(--nx-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 600;
    color: #fff;
    text-transform: uppercase;
}

.meet-video-tile .tile-tag {
    position: absolute;
    bottom: .75rem;
    left: .75rem;
    background-color: rgba(15, 17, 21, .78);
    border: 1px solid rgba(255, 255, 255, .1);
    padding: 4px 10px;
    border-radius: .375rem;
    font-size: .75rem;
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 5;
}

.meet-video-tile .tile-menu {
    position: absolute;
    top: .75rem;
    right: .75rem;
    display: flex;
    gap: 6px;
    z-index: 5;
    opacity: 0;
    transition: opacity .2s ease-in-out;
}

.meet-video-tile:hover .tile-menu,
.meet-video-tile:focus-within .tile-menu {
    opacity: 1;
}

.meet-video-tile .tile-hand {
    position: absolute;
    top: .75rem;
    left: .75rem;
    background-color: var(--nx-warning);
    color: #1b1e24;
    padding: 4px 10px;
    border-radius: .375rem;
    font-size: .75rem;
    font-weight: 600;
    z-index: 5;
}

#spotlightScreenContainer {
    flex: 1;
    min-width: 0;
    height: 100%;
    background-color: #0b0d10;
    border: 1px solid rgba(255, 255, 255, .07);
    border-radius: .75rem;
    overflow: hidden;
}

#spotlightScreenContainer video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.meet-drawer {
    width: 340px;
    flex-shrink: 0;
    height: 100%;
    background-color: #1b1e24;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: .75rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 20;
}

.meet-drawer .meet-drawer-head {
    padding: .875rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    font-weight: 600;
    color: #fff;
}

.meet-drawer .meet-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.meet-drawer .meet-drawer-foot {
    padding: .75rem;
    border-top: 1px solid rgba(255, 255, 255, .08);
}

.meet-control-bar {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    min-height: 66px;
    padding: .5rem 1rem;
    background-color: rgba(24, 27, 33, .95);
    border: 1px solid rgba(255, 255, 255, .09);
    border-radius: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: .5rem;
    z-index: 100;
    max-width: calc(100% - 2rem);
}

.btn-meet {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, .09);
    border: 1px solid rgba(255, 255, 255, .12);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color .15s ease-in-out, color .15s ease-in-out;
}

.btn-meet:hover,
.btn-meet:focus-visible {
    background-color: rgba(255, 255, 255, .2);
    color: #fff;
}

.btn-meet.active {
    background-color: #fff;
    border-color: #fff;
    color: #16181d;
}

.btn-meet.active:hover {
    background-color: rgba(255, 255, 255, .88);
    color: #16181d;
}

.btn-meet.disabled,
.btn-meet.is-off {
    background-color: rgba(var(--vz-danger-rgb, 240, 101, 72), .2);
    border-color: rgba(var(--vz-danger-rgb, 240, 101, 72), .45);
    color: var(--nx-danger);
    opacity: 1;
    pointer-events: auto;
}

.btn-meet-leave {
    height: 46px;
    padding: 0 1.5rem;
    border: 0;
    border-radius: 1.5rem;
    background-color: var(--nx-danger);
    color: #fff;
    font-weight: 600;
    font-size: .875rem;
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    cursor: pointer;
    transition: filter .15s ease-in-out;
}

.btn-meet-leave:hover {
    filter: brightness(1.08);
    color: #fff;
}

.nx-reaction-bar {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 2px 6px;
    background-color: rgba(255, 255, 255, .07);
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 2rem;
}

.nx-reaction-bar button {
    width: 34px;
    height: 34px;
    border: 0;
    background: none;
    border-radius: 50%;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    transition: background-color .15s ease-in-out;
}

.nx-reaction-bar button:hover {
    background-color: rgba(255, 255, 255, .16);
}

.floating-reaction {
    position: absolute;
    font-size: 2.5rem;
    pointer-events: none;
    animation: nxFloatReaction 3s ease-out forwards;
    z-index: 100;
}

@keyframes nxFloatReaction {
    0% { opacity: 0; transform: translateY(20px) scale(.6); }
    15% { opacity: 1; transform: translateY(-20px) scale(1.15); }
    80% { opacity: .85; }
    100% { opacity: 0; transform: translateY(-220px) scale(.8); }
}

#whiteboardModal .nx-whiteboard-surface {
    flex: 1;
    position: relative;
    overflow: hidden;
    background-color: #101216;
}

#whiteboardModal canvas {
    width: 100%;
    height: 100%;
    cursor: crosshair;
    display: block;
}

/* The room chrome is always dark, so keep Velzon's light-mode text readable
   inside it. */
.meet-room-container .form-control,
.meet-room-container .form-select {
    background-color: rgba(255, 255, 255, .06);
    border-color: rgba(255, 255, 255, .14);
    color: #fff;
}

.meet-room-container .form-control::placeholder {
    color: rgba(255, 255, 255, .45);
}

.meet-room-container .form-label,
.meet-room-container .form-check-label {
    color: rgba(255, 255, 255, .75);
}

@media (max-width: 767.98px) {
    .meet-grid-wrapper {
        flex-direction: column;
        padding: .75rem .75rem 6rem;
        overflow-y: auto;
    }

    #videoGridContainer {
        grid-template-columns: 1fr;
    }

    .meet-drawer {
        position: fixed;
        inset: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
        z-index: 180;
    }

    .meet-control-bar {
        width: calc(100% - 1.5rem);
        border-radius: 1.5rem;
        gap: .375rem;
        padding: .5rem;
    }

    .btn-meet {
        width: 40px;
        height: 40px;
    }

    .btn-meet-leave {
        height: 40px;
        padding: 0 1rem;
    }

    .nx-reaction-bar {
        order: 10;
        width: 100%;
        justify-content: center;
    }
}
