/* ==========================================================================
   Tile Grid Search Bar Styles
   ========================================================================== */

.tile-grid-search-bar {
    margin-bottom: 2rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.tile-grid-search-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    max-width: 100%;
    box-sizing: border-box;
}

.tile-grid-search-title-section {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 0 1 auto;
    min-width: 0;
}

.tile-grid-search-title {
    font-size: 1.75rem;
    font-weight: 600;
    margin: 0;
    color: #fff;
    flex-shrink: 0;
    white-space: nowrap;
    overflow: visible;
}

.tile-grid-library-selector {
    background-color: #212222;
    border: 1px solid #444;
    color: #fff;
    border-radius: 0.375rem;
    min-width: 120px;
    width: auto;
    flex-shrink: 0;
    height: 38px;
    padding: 0.375rem 2rem 0.375rem 0.75rem;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px 12px;
    appearance: none;
    position: relative;
    z-index: 1100; /* Above top bar (z-index 1050) */
}

.tile-grid-library-selector:focus {
    background-color: #2a2a2a;
    border-color: #FFE600;
    color: #fff;
    box-shadow: 0 0 0 0.25rem rgba(255, 230, 0, 0.1);
    z-index: 1100; /* Ensure it stays above when focused */
}

.tile-grid-library-selector option {
    background-color: #212222;
    color: #fff;
}

.tile-grid-search-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1 1 auto;
    min-width: 0;
    justify-content: flex-end;
}

.tile-grid-search-input-wrapper {
    position: relative;
    flex: 1 1 auto;
    max-width: 400px;
    min-width: 180px;
}

.tile-grid-search-input-wrapper i {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: #9AA4AA;
    font-size: 1rem;
    pointer-events: none;
}

.tile-grid-search-input {
    padding-left: 2.5rem;
    background-color: #212222;
    border: 1px solid #444;
    color: #fff;
    border-radius: 0.375rem;
    height: 38px;
    width: 100%;
}

.tile-grid-search-input:focus {
    background-color: #2a2a2a;
    border-color: #FFE600;
    color: #fff;
    box-shadow: 0 0 0 0.25rem rgba(255, 230, 0, 0.1);
}

.tile-grid-search-input::placeholder {
    color: #9AA4AA;
}

.tile-grid-filter-dropdown {
    background-color: #212222;
    border: 1px solid #444;
    color: #fff;
    border-radius: 0.375rem;
    min-width: 120px;
    width: auto;
    flex-shrink: 0;
    height: 38px;
    padding: 0.375rem 2rem 0.375rem 0.75rem;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px 12px;
    appearance: none;
}

.tile-grid-filter-dropdown:focus {
    background-color: #2a2a2a;
    border-color: #FFE600;
    color: #fff;
    box-shadow: 0 0 0 0.25rem rgba(255, 230, 0, 0.1);
}

.tile-grid-filter-dropdown option {
    background-color: #212222;
    color: #fff;
}

/* Responsive adjustments for search bar */
/* Very aggressive wrapping to prevent overlap - wrap everything at narrower widths */
@media (max-width: 1100px) {
    .tile-grid-search-container {
        gap: 1rem;
    }

    .tile-grid-search-title-section {
        flex: 0 0 100%;
        flex-wrap: nowrap;
    }

    .tile-grid-search-controls {
        flex: 0 0 100%;
        justify-content: flex-start;
    }

    .tile-grid-search-input-wrapper {
        flex: 1 1 auto;
        min-width: 150px;
        max-width: none;
    }
}

/* Further adjustments for medium screens */
@media (max-width: 900px) {
    .tile-grid-search-container {
        gap: 0.875rem;
    }

    .tile-grid-search-input-wrapper {
        min-width: 140px;
    }
}

/* Small tablet/large mobile: Stack everything vertically */
@media (max-width: 768px) {
    .tile-grid-search-bar {
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }

    .tile-grid-search-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    .tile-grid-search-title-section {
        width: 100% !important;
        max-width: 100% !important;
        flex-wrap: wrap;
        gap: 0.75rem;
        box-sizing: border-box !important;
    }

    .tile-grid-search-title {
        font-size: 1.5rem;
        flex: 1 1 100%;
        max-width: 100% !important;
    }

    .tile-grid-library-selector {
        flex: 1 1 auto;
        min-width: 0 !important;
        max-width: 100% !important;
        width: 100%;
        box-sizing: border-box !important;
    }

    .tile-grid-search-controls {
        width: 100% !important;
        max-width: 100% !important;
        flex-wrap: wrap;
        justify-content: flex-start;
        box-sizing: border-box !important;
    }

    .tile-grid-search-input-wrapper {
        flex: 1 1 100%;
        max-width: 100% !important;
        min-width: 0 !important;
        order: 1;
        box-sizing: border-box !important;
    }

    .tile-grid-search-input {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    .tile-grid-filter-dropdown {
        flex: 1 1 auto;
        order: 2;
        min-width: 0 !important;
        max-width: 48% !important;
        width: 48%;
        box-sizing: border-box !important;
    }

    .view-toggle-switch {
        order: 3;
        flex-shrink: 0;
    }
}

/* Small mobile: Further size reductions */
@media (max-width: 480px) {
    .tile-grid-search-bar {
        margin-bottom: 1rem;
    }

    .tile-grid-search-container {
        gap: 0.65rem !important;
    }

    .tile-grid-search-title {
        font-size: 1.25rem;
    }

    .tile-grid-search-controls {
        gap: 0.65rem !important;
    }

    .tile-grid-filter-dropdown {
        width: auto;
        flex: 1;
        max-width: 48% !important;
        min-width: 0 !important;
    }

    .view-toggle-switch {
        flex-shrink: 0;
    }

    /* Ensure all text elements don't cause overflow */
    h1, h2, h3, h4, h5, h6, p, span, div {
        max-width: 100%;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
}

/* ==========================================================================
   Library Page Container Styles
   ========================================================================== */

/* Global mobile overflow prevention */
* {
    box-sizing: border-box;
}

/* Prevent horizontal overflow on all screen sizes */
html {
    overflow-x: hidden !important;
    max-width: 100vw !important;
    width: 100% !important;
}

body {
    overflow-x: hidden !important;
    max-width: 100vw !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    /* Push all content below the top bar */
    padding-top: calc(var(--topbar-height) + 2px) !important; /* Top bar height + border */
}

/* Force all flex containers to respect viewport width */
.d-flex, .flex-grow-1, .container, .container-fluid {
    max-width: 100% !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
}

/* Override Bootstrap container on mobile for tighter fit */
@media (max-width: 768px) {
    .container, .container-fluid, .container.py-4 {
        padding: 0.75rem 0.5rem !important;
        max-width: 100vw !important;
        width: 100% !important;
        margin: 0 auto !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
        overflow-y: visible !important; /* Allow dropdowns to overflow */
    }

    /* Ensure page content area respects viewport */
    main, .page-content, .content-wrapper {
        max-width: 100vw !important;
        overflow-x: hidden !important;
        overflow-y: visible !important;
    }

    /* Allow search bar to overflow for dropdowns */
    .tile-grid-search-bar,
    .tile-grid-search-container,
    .tile-grid-search-title-section {
        overflow: visible !important;
    }
}

@media (max-width: 480px) {
    .container, .container-fluid, .container.py-4 {
        padding: 0.5rem 0.25rem !important;
    }
}

/* ==========================================================================
   Page Containers with Bottom Padding for Fixed Bottom Bar
   ========================================================================== */

/* Apply generous bottom padding to all pages to ensure content is never hidden by bottom bar */
.container.py-4,
.container-fluid.py-4 {
    padding-bottom: 120px !important; /* Ensure content is fully visible above 52px bottom bar */
}

/* Additional padding on mobile devices */
@media (max-width: 768px) {
    .container.py-4,
    .container-fluid.py-4 {
        padding-bottom: 140px !important; /* Extra padding for mobile to prevent overlap */
    }
}

/* ==========================================================================
   Contacts Page Styles
   ========================================================================== */

.contacts-container {
    padding: 1rem;
    padding-bottom: 120px; /* Extra space to ensure tiles are fully visible above bottom bar */
    padding-top: 32px;
    max-width: 100%;
    margin: 0;
}

.contacts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 200px));
    gap: 1.2rem;
    justify-content: center;
    max-width: 1200px;
    margin: 0 auto;
}

.contact-tile {
    aspect-ratio: 1 / 1;
    width: 100%;
    height: auto;
    background: #212222;
    border-radius: 0.5rem;
    text-align: center;
    transition: transform 0.3s, box-shadow 0.2s, border 0.2s;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    cursor: pointer;
    box-sizing: border-box;
    padding: 1.2rem 0.7rem;
    min-width: 0;
    min-height: 0;
    border: 2px solid transparent;
}

.contact-tile:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.16);
    border: 2px solid #444;
}

.contact-tile .card-title {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 2px;
    text-align: center;
    color: #fff;
    text-shadow:
        0 1px 4px rgba(0, 0, 0, 0.5);
}

.contact-tile .card-text {
    font-size: 0.95rem;
    color: #fff;
    text-align: center;
    text-shadow:
        0 1px 4px rgba(0, 0, 0, 0.5);
}

.contact-link {
    text-decoration: none;
    color: inherit;
    display: block;
    width: 100%;
    height: 100%;
}

/* Contact FAB (Floating Action Button) */
.contact-fab {
    position: absolute;
    bottom: 12px;
    right: 12px;
    z-index: 2;
}

.fab-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1em;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
    transition: background 0.2s, box-shadow 0.2s;
    cursor: pointer;
    outline: none;
}

.fab-btn:active {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.fab-call {
    background: #217a3a;
    color: #fff;
}

.fab-call:hover {
    background: #145526;
}

.fab-delete {
    background: #d32f2f;
    color: #fff;
}

.fab-delete:hover {
    background: #a31515;
}

/* Contact status background colors */
.contact-bg-lightgray {
    background-color: #D8DFE1 !important;
}

.contact-bg-gray {
    background-color: #9AA4AA !important;
}

.contact-bg-darkgray {
    background-color: #212222 !important;
}

.contact-bg-yellow {
    background-color: #FFE600 !important;
}

.contact-bg-limegreen {
    background-color: #5FAE59 !important;
}

.contact-bg-purple {
    background-color: #4E44DD !important;
}

.contact-bg-blue {
    background-color: #00A2E8 !important;
}

.contact-bg-teal {
    background-color: #669999 !important;
}

.contact-bg-unknown {
    background-color: #9AA4AA !important;
}

/* Responsive: Tablet (3 columns) */
@media (max-width: 900px) and (min-width: 601px) {
    .contacts-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
        max-width: 660px;
    }
}

/* Responsive: Mobile (2 columns) */
@media (max-width: 600px) {
    .contacts-container {
        padding: 0.5rem;
        padding-bottom: 140px; /* Increased padding for mobile to prevent bottom bar overlap */
    }

    .contacts-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
        max-width: 100%;
        padding: 0 0.5rem;
    }

    .contact-tile {
        padding: 1rem 0.6rem;
    }

    .contact-tile svg.mb-2 {
        width: 2.8em;
        height: 2.8em;
        margin-bottom: 0.8rem;
    }

    .contact-tile .card-title {
        font-size: 1em;
    }

    .contact-tile .card-text {
        font-size: 0.9em;
    }

    .contact-fab {
        bottom: 10px;
        right: 10px;
    }

    .fab-btn {
        width: 30px;
        height: 30px;
        font-size: 1em;
    }
}

/* ==========================================================================
   Unified Tile Grid Styles (Consolidates Contact and Content Tiles)
   ========================================================================== */

/* Initial state: hide both views until data-view-mode is set.
   The data-view-mode attribute is set by inline script before render */
.unified-tile-grid {
    display: none; /* Hidden by default, shown by data-view-mode */
}

.unified-tile-list {
    display: none; /* Hidden by default */
}

/* Current Folder Bar Styles */
.current-folder-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    background: #1a1d21;
    border: 1px solid #2a2e32;
    border-radius: 8px;
}

.folder-back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: #23272b;
    border: 2px solid #2a2e32;
    border-radius: 6px;
    color: #fff;
    text-decoration: none;
    transition: all 0.2s ease;
}

.folder-back-btn:hover {
    background: #2a2e32;
    border-color: #FFE600;
    color: #FFE600;
    transform: translateX(-2px);
}

.folder-back-btn i {
    font-size: 1.2rem;
}

.current-folder-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
    font-weight: 500;
    color: #fff;
}

.current-folder-label i {
    color: #FFE600;
    font-size: 1.3rem;
}

/* Current folder bar responsive adjustments */
@media (max-width: 768px) {
    .current-folder-bar {
        padding: 0.65rem 0.75rem;
        margin-bottom: 0.75rem;
        gap: 0.75rem;
    }

    .folder-back-btn {
        width: 32px;
        height: 32px;
    }

    .folder-back-btn i {
        font-size: 1.1rem;
    }

    .current-folder-label {
        font-size: 1rem;
    }

    .current-folder-label i {
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    .current-folder-bar {
        padding: 0.5rem 0.6rem;
        margin-bottom: 0.65rem;
        gap: 0.6rem;
    }

    .folder-back-btn {
        width: 30px;
        height: 30px;
    }

    .folder-back-btn i {
        font-size: 1rem;
    }

    .current-folder-label {
        font-size: 0.9rem;
    }

    .current-folder-label i {
        font-size: 1.1rem;
    }
}

/* Empty State Styles */
.empty-state-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
    padding: 2rem;
}

.empty-state-content {
    text-align: center;
    max-width: 500px;
}

.empty-state-icon {
    font-size: 4rem;
    color: #6c757d;
    margin-bottom: 1.5rem;
    opacity: 0.6;
}

.empty-state-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 0.75rem;
}

.empty-state-text {
    font-size: 1rem;
    color: #adb5bd;
    margin-bottom: 0;
    line-height: 1.5;
}

.empty-state-delete-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.95rem;
    padding: 0.5rem 1.25rem;
    border-radius: 0.375rem;
    transition: background-color 0.2s, color 0.2s;
}

.empty-state-delete-btn:hover {
    background-color: var(--bs-danger);
    color: #fff;
}

@media (max-width: 768px) {
    .empty-state-container {
        min-height: 300px;
        padding: 1.5rem;
    }
    
    .empty-state-icon {
        font-size: 3rem;
        margin-bottom: 1rem;
    }
    
    .empty-state-title {
        font-size: 1.25rem;
    }
    
    .empty-state-text {
        font-size: 0.95rem;
    }
}

@media (max-width: 480px) {
    .empty-state-container {
        min-height: 250px;
        padding: 1rem;
    }
    
    .empty-state-icon {
        font-size: 2.5rem;
        margin-bottom: 0.75rem;
    }
    
    .empty-state-title {
        font-size: 1.1rem;
    }
    
    .empty-state-text {
        font-size: 0.9rem;
    }
}

/* Library Selection Checkbox Styles */
.library-selection-checkbox-wrapper {
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: right;
}

.library-selection-checkbox {
    width: 28px;
    height: 28px;
    cursor: pointer;
    margin: 0;
    accent-color: #FFE600;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-color: rgba(42, 42, 42, 0.9);
    border: 2px solid #FFE600;
    border-radius: 4px;
    position: relative;
    transition: all 0.15s ease;
}

.library-selection-checkbox:hover {
    transform: scale(1.1);
    background-color: #333;
    border-color: #fff;
}

.library-selection-checkbox:checked {
    background-color: #FFE600;
    border-color: #FFE600;
}

.library-selection-checkbox:checked::after {
    content: '';
    position: absolute;
    left: 8px;
    top: 4px;
    width: 6px;
    height: 12px;
    border: solid #212222;
    border-width: 0 2.5px 2.5px 0;
    transform: rotate(45deg);
}

.library-list-checkbox-wrapper {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px 8px;
}

.library-list-checkbox-wrapper .library-selection-checkbox {
    width: 28px;
    height: 28px;
    cursor: pointer;
    margin: 0;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-color: rgba(42, 42, 42, 0.9);
    border: 2px solid #FFE600;
    border-radius: 4px;
    position: relative;
    transition: all 0.15s ease;
}

.library-list-checkbox-wrapper .library-selection-checkbox:hover {
    transform: scale(1.1);
    background-color: #333;
    border-color: #fff;
}

.library-list-checkbox-wrapper .library-selection-checkbox:checked {
    background-color: #FFE600;
    border-color: #FFE600;
}

.library-list-checkbox-wrapper .library-selection-checkbox:checked::after {
    content: '';
    position: absolute;
    left: 8px;
    top: 4px;
    width: 6px;
    height: 12px;
    border: solid #212222;
    border-width: 0 2.5px 2.5px 0;
    transform: rotate(45deg);
}

/* Show grid view when data-view-mode="grid" is set on html element */
html[data-view-mode="grid"] .unified-tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
    width: 100%;
    justify-content: center;
    max-width: 100vw;
    margin: 0 auto;
    padding-bottom: 20px; /* Extra padding to ensure last row is visible */
}

/* Show list view when data-view-mode="list" is set on html element */
html[data-view-mode="list"] .unified-tile-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    max-width: 100vw;
    margin: 0 auto;
    padding-bottom: 20px; /* Extra padding to ensure last item is visible */
}

/* Multi-column layout for list view on wide displays */
@media (min-width: 1200px) {
    html[data-view-mode="list"] .unified-tile-list {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 1rem;
        column-gap: 1.5rem;
    }
}

@media (min-width: 1600px) {
    html[data-view-mode="list"] .unified-tile-list {
        grid-template-columns: repeat(3, minmax(350px, 1fr));
        column-gap: 2rem;
        max-width: 100vw;
    }
}

.unified-tile-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease, border 0.2s ease;
    cursor: pointer;
    overflow: hidden;
    border-radius: 0.5rem;
    background-color: #212222;
    border: 2px solid transparent;
    position: relative;
    text-decoration: none;
}

.unified-tile-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

.unified-tile-link {
    text-decoration: none;
    color: inherit;
    display: block;
    width: 100%;
    height: 100%;
}

/* Contact-style tiles (square aspect ratio) */
.unified-tile-card.contact-tile-style {
    aspect-ratio: 1 / 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1.2rem 0.7rem;
    min-height: 170px;
}

.unified-tile-card.contact-tile-style:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.16);
    border: 2px solid #444;
}

.unified-tile-card.contact-tile-style img {
    width: 3.2em;
    height: 3.2em;
    margin-bottom: 1.1rem;
    max-width: 100%;
    max-height: 100%;
    color: #fff;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.25)) drop-shadow(0 3px 6px rgba(0, 0, 0, 0.2));
}

.unified-tile-card.contact-tile-style .card-title {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 2px;
    text-align: center;
    color: #fff;
    text-shadow:
        0 1px 4px rgba(0, 0, 0, 0.5);
}

.unified-tile-card.contact-tile-style .card-text {
    font-size: 0.95rem;
    color: #fff;
    text-align: center;
    text-shadow:
        0 1px 4px rgba(0, 0, 0, 0.5);
}

.unified-tile-main-icon {
    font-size: 3.2em;
    margin-bottom: 1.1rem;
    color: #fff;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5))
            drop-shadow(0 3px 6px rgba(0, 0, 0, 0.3));
}

/* Content-style tiles (rectangular with thumbnail) */
.unified-tile-card.content-tile-style {
    height: 280px;
}

.unified-tile-card.content-tile-style:hover {
    border: 2px solid #FFE600;
}

.unified-tile-thumbnail {
    width: 100%;
    height: 180px;
    object-fit: contain;
    background-color: #181c20;
    transition: opacity 0.3s ease-in-out;
}

/* Lazy loading state - start blank (hidden) */
.unified-tile-thumbnail[data-blob-url]:not([data-sas-loaded]) {
    opacity: 0;
}

/* Loaded state - fade in real thumbnail */
.unified-tile-thumbnail[data-sas-loaded="true"] {
    opacity: 1;
}

/* Error state - fade in placeholder */
.unified-tile-thumbnail[data-sas-loaded="error"] {
    opacity: 1;
}

/* Content thumbnail placeholder - centered icon style for placeholder images */
.unified-tile-thumbnail.content-thumbnail-placeholder {
    object-fit: contain;
    background-color: transparent; /* Let the yellow SVG show through */
    padding: 3rem;
    box-sizing: border-box;
}

.unified-tile-body {
    display: flex;
    flex-direction: column;
    padding: 1rem;
    background-color: #212222;
}

.unified-tile-body.content-body-style {
    height: 100px;
}

.unified-tile-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.unified-tile-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
    color: #FFE600;
}

.unified-tile-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
    color: #fff;
}

.unified-tile-subtitle {
    font-size: 0.8rem;
    color: #9AA4AA;
    margin: 0;
    padding-left: 2rem;
}

/* Unified FAB (works for both contact and content tiles) */
.unified-tile-fab {
    position: absolute;
    bottom: 12px;
    right: 12px;
    z-index: 2;
    display: flex;
    gap: 8px;
}

/* Back navigation card special styling */
.back-navigation-card {
    background-color: #1a1d21;
    border: 2px dashed #555;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 280px;
}

.back-navigation-card:hover {
    background-color: #252829;
    border: 2px dashed #FFE600;
    box-shadow: 0 8px 16px rgba(255, 230, 0, 0.15);
    transform: translateY(-4px);
}

.back-navigation-card .unified-tile-body {
    height: 280px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background-color: transparent;
    gap: 1rem;
}

.back-navigation-card .unified-tile-icon {
    font-size: 72px;
    margin: 0;
    color: #FFE600;
    transition: transform 0.2s ease;
    line-height: 1;
}

.back-navigation-card:hover .unified-tile-icon {
    transform: translateY(-4px);
}

.back-navigation-card .unified-tile-title {
    font-size: 1.15rem;
    font-weight: 500;
    white-space: normal;
    text-align: center;
    color: #e0e0e0;
    margin: 0;
    padding: 0 1rem;
}

a:has(.unified-tile-card) {
    color: inherit;
}

/* Responsive adjustments for unified grid */
@media (max-width: 900px) and (min-width: 601px) {
    html[data-view-mode="grid"] .unified-tile-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 1rem;
        max-width: 900px;
    }

    .unified-tile-card.content-tile-style {
        height: 260px;
    }

    .unified-tile-thumbnail {
        height: 160px;
    }
}

@media (max-width: 600px) {
    html[data-view-mode="grid"] .unified-tile-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.75rem;
        max-width: 100%;
        padding: 0 0.5rem;
    }

    .unified-tile-card.contact-tile-style {
        padding: 1rem 0.6rem;
        min-height: 140px;
    }

    .unified-tile-card.contact-tile-style svg.mb-2 {
        width: 2.8em;
        height: 2.8em;
        margin-bottom: 0.8rem;
    }

    .unified-tile-card.contact-tile-style .card-title {
        font-size: 1em;
    }

    .unified-tile-card.contact-tile-style .card-text {
        font-size: 0.9em;
    }

    /* Content tiles on mobile */
    .unified-tile-card.content-tile-style {
        height: 240px;
    }

    .unified-tile-thumbnail {
        height: 140px;
    }

    .unified-tile-body.content-body-style {
        height: 100px;
        padding: 0.75rem;
    }

    .unified-tile-title {
        font-size: 0.9rem;
    }

    .unified-tile-subtitle {
        font-size: 0.75rem;
        padding-left: 1.75rem;
    }

    /* Back navigation card on mobile */
    .back-navigation-card {
        height: 240px;
    }

    .back-navigation-card .unified-tile-body {
        height: 240px;
        padding: 1.5rem;
    }

    .back-navigation-card .unified-tile-icon {
        font-size: 56px;
    }

    .back-navigation-card .unified-tile-title {
        font-size: 1rem;
    }

    .unified-tile-fab {
        bottom: 10px;
        right: 10px;
    }

    .fab-btn {
        width: 30px;
        height: 30px;
        font-size: 1em;
    }

    .unified-tile-main-icon {
        font-size: 2.8em;
        margin-bottom: 0.8rem;
    }

    /* Checkbox adjustments */
    .library-selection-checkbox-wrapper {
        top: 4px;
        left: 4px;
    }

    .library-selection-checkbox {
        width: 24px;
        height: 24px;
    }

    .library-selection-checkbox:checked::after {
        left: 7px;
        top: 3px;
        width: 5px;
        height: 10px;
    }
}

@media (min-width: 768px) {
    html[data-view-mode="grid"] .unified-tile-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 1.25rem;
    }
}

@media (min-width: 1200px) {
    html[data-view-mode="grid"] .unified-tile-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        gap: 1.5rem;
    }
}

@media (min-width: 1600px) {
    html[data-view-mode="grid"] .unified-tile-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 1.5rem;
    }
}

/* ==========================================================================
   Unified Tile List View Styles
   ========================================================================== */

/* Note: Base visibility rules for .unified-tile-list are in the
   Unified Tile Grid Styles section with data-view-mode selectors */

.unified-list-item {
    display: block;
    text-decoration: none;
    color: inherit;
    background-color: #212222;
    border: 2px solid transparent;
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.1s ease;
    min-width: 0;
    overflow: hidden;
}

.unified-list-item:hover {
    background-color: #2a2a2a;
    border-color: #444;
    transform: translateX(4px);
}

.unified-list-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.unified-list-icon-wrapper {
    flex-shrink: 0;
    width: 128px;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.25rem;
    overflow: hidden;
}

.unified-list-thumbnail {
    width: 128px;
    height: 72px;
    object-fit: contain;
    border-radius: 0.25rem;
}

.unified-list-main-icon {
    font-size: 2rem;
    color: #FFE600;
}

.unified-list-item.contact-list-item .unified-list-icon-wrapper img {
    width: 48px;
    height: 48px;
    color: #fff;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.25));
}

.unified-list-info {
    flex: 1;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}

.unified-list-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.unified-list-subtitle {
    font-size: 0.875rem;
    color: #9AA4AA;
    margin: 0.25rem 0 0 0;
}

.unified-list-type-icon {
    flex-shrink: 0;
    font-size: 1.25rem;
    color: #FFE600;
    margin-left: auto;
}

.unified-list-actions {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
    flex-shrink: 0;
}

.list-action-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: background 0.2s, box-shadow 0.2s, transform 0.1s;
    cursor: pointer;
    outline: none;
}

/* Contact list item specific styles */
.unified-list-item.contact-list-item {
    position: relative;
}

.unified-list-item.contact-list-item:hover {
    border-color: #555;
}

/* Contact list item text styling - white with soft drop shadow for contrast */
.unified-list-item.contact-list-item .unified-list-title {
    color: #fff;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.unified-list-item.contact-list-item .unified-list-subtitle {
    color: #fff;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

/* Back navigation list item */
.unified-list-item.back-nav-item {
    background-color: #1a1d21;
    border: 2px dashed #555;
}

.unified-list-item.back-nav-item:hover {
    background-color: #252829;
    border: 2px dashed #FFE600;
    transform: translateX(8px);
}

.unified-list-item.back-nav-item .unified-list-main-icon {
    font-size: 2.5rem;
}

/* Content list item specific styles */
.unified-list-item.content-list-item:hover {
    border-color: #FFE600;
}

/* Responsive adjustments for list view */
@media (max-width: 768px) {
    /* Make list view narrower and more compact on mobile */
    html[data-view-mode="list"] .unified-tile-list {
        gap: 0.75rem;
        padding: 0 0.5rem;
        max-width: 100% !important; /* Override desktop max-width */
        width: 100% !important;
        margin: 0 !important;
        box-sizing: border-box;
    }

    .unified-list-item {
        padding: 0.5rem 0.65rem;
        max-width: 100%;
        box-sizing: border-box;
    }

    .unified-list-content {
        gap: 0.75rem;
        max-width: 100%;
    }

    .unified-list-info {
        flex: 1;
        min-width: 0;
        max-width: 100%;
        overflow: hidden;
    }

    .unified-list-icon-wrapper {
        width: 128px;
        height: 72px;
    }

    .unified-list-thumbnail {
        width: 128px;
        height: 72px;
    }

    .unified-list-main-icon {
        font-size: 1.75rem;
    }

    .unified-list-title {
        font-size: 0.9rem;
    }

    .unified-list-subtitle {
        font-size: 0.8rem;
    }

    .unified-list-type-icon {
        font-size: 1.1rem;
    }

    .list-action-btn {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    html[data-view-mode="list"] .unified-tile-list {
        gap: 0.65rem;
        padding: 0 0.25rem !important; /* Tighter padding for small screens */
        max-width: 100% !important;
        width: 100% !important;
    }

    .unified-list-item {
        padding: 0.45rem 0.5rem;
        max-width: 100%;
    }

    .unified-list-content {
        gap: 0.6rem;
    }

    .unified-list-icon-wrapper {
        width: 128px;
        height: 72px;
    }

    .unified-list-thumbnail {
        width: 128px;
        height: 72px;
    }

    .unified-list-main-icon {
        font-size: 1.5rem;
    }

    .unified-list-title {
        font-size: 0.85rem;
    }

    .unified-list-subtitle {
        font-size: 0.75rem;
    }

    .unified-list-type-icon {
        font-size: 1rem;
    }

    .list-action-btn {
        width: 28px;
        height: 28px;
        font-size: 0.85rem;
    }
}

/* ==========================================================================
   Call Page Styles
   ========================================================================== */

/* Tunable variables */
:root {
    --call-header-footer-height: 120px;
    --call-padding: 12px;
}

.call-page {
    min-height: calc(100vh - var(--call-header-footer-height));
    display: flex;
    flex-direction: column;
    padding: var(--call-padding);
}

.call-top {
    display: flex;
    flex: 1 1 auto;
    gap: 1rem;
    min-height: 0;
}

.call-video-area {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.call-video-wrapper {
    flex: 0 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    background-color: #0b0b0b;
    border-radius: .25rem;
    padding: .5rem;
    max-height: calc(100vh - var(--call-header-footer-height) - 3rem);
}

.call-video-wrapper .ratio {
    width: 100%;
    height: 100%;
    aspect-ratio: 16 / 9;
    max-width: 100%;
    background-image: url('/icons/video-player.svg');
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
}

.call-video-wrapper img,
.call-video-wrapper video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
    border-radius: .125rem;
}

.call-video-caption {
    margin-top: .5rem;
    font-weight: 600;
    color: #fff;
}

/* Audio-only call placeholder (shown when remote peer has no video) */
.call-audio-placeholder .ratio {
    background-image: none;
}

.call-audio-placeholder-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: #0b0b0b;
    color: #9AA4AA;
    gap: 1rem;
}

/* Overlay variant — lives inside .ratio alongside #remoteVideo */
.call-audio-placeholder-overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #0b0b0b;
    color: #9AA4AA;
    gap: 1rem;
    z-index: 1;
}

.call-audio-avatar-icon {
    font-size: 6rem;
    line-height: 1;
}

.call-audio-label {
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: 0.02em;
}

/* Call setup progress indicator */
.call-setup {
    background-color: #181c20;
    border: 1px solid #2a2a2a;
}

.call-setup .progress {
    background-color: #23272b;
}

.call-setup .progress-bar {
    background-color: #ffc107;
}

.call-setup label {
    color: #9AA4AA;
}

.call-setup .form-control {
    background-color: #23272b;
    color: #fff;
    border-color: #2a2a2a;
}

.call-setup .form-control:focus {
    background-color: #2a2e32;
    color: #fff;
    border-color: #ffc107;
    box-shadow: 0 0 0 0.25rem rgba(255, 193, 7, 0.15);
}

/* Call page responsive */
@media (max-width: 767.98px) {
    .call-top {
        gap: .5rem;
    }
}

/* ==========================================================================
   View Toggle Switch Styles
   ========================================================================== */

.view-toggle-switch {
    display: inline-flex;
    background: #212529;
    border-radius: 0.375rem;
    padding: 0.25rem;
    gap: 0.25rem;
    align-items: center;
    border: 1px solid #495057;
}

.view-toggle-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.875rem;
    border: none;
    border-radius: 0.25rem;
    background: transparent;
    color: #9AA4AA;
    font-size: 0.875rem;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    white-space: nowrap;
}

.view-toggle-option i {
    font-size: 1rem;
}

.view-toggle-option:hover:not(.active) {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.view-toggle-option.active {
    background: #495057;
    color: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.view-toggle-text {
    display: inline;
}

/* Responsive: Hide text on mobile, show only icons */
@media (max-width: 768px) {
    .view-toggle-option {
        padding: 0.375rem 0.625rem;
    }

    .view-toggle-text {
        display: none;
    }
}

/* Inline breadcrumb styling (smaller font) */
.breadcrumb-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
    max-width: 100%;
    overflow: visible;
    list-style: none;
    padding: 0;
    margin: 0;
}

.breadcrumb-item-inline {
    display: inline-flex;
    align-items: center;
    font-size: 1rem;
    font-weight: 500;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.breadcrumb-link-inline {
    color: #FFE600;
    text-decoration: none;
    transition: color 0.2s ease;
    overflow: hidden;
    text-overflow: ellipsis;
}

.breadcrumb-link-inline:hover {
    color: #fff;
}

.breadcrumb-current {
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
}

.breadcrumb-separator-inline {
    font-size: 0.8rem;
    color: #fff;
    margin: 0 0.1rem;
    flex-shrink: 0;
}

.breadcrumb-ellipsis-inline {
    color: #9AA4AA;
    font-size: 1rem;
    font-weight: 500;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .breadcrumb-item-inline {
        font-size: 0.9rem;
        max-width: 150px;
    }

    .breadcrumb-separator-inline {
        font-size: 0.7rem;
    }

    .breadcrumb-ellipsis-inline {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .breadcrumb-item-inline {
        font-size: 0.85rem;
        max-width: 100px;
    }

    .breadcrumb-inline {
        gap: 0.2rem;
    }
}

/* Hybrid library selector as breadcrumb root */
.library-selector-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    background-color: #212222;
    border: 1px solid #444;
    border-radius: 0.375rem;
    height: 30px;
    transition: all 0.2s ease;
}
.library-selector-wrapper:hover {
    background-color: #2a2a2a;
    border-color: #FFE600;
}
.library-label {
    color: #fff;
    font-size: 1rem;
    font-weight: 500;
    padding: 0.25rem 0.5rem 0.25rem 0.75rem;
    display: inline-flex;
    align-items: center;
    height: 100%;
    border-radius: 0.375rem 0 0 0.375rem;
    cursor: default;
}
.library-dropdown-trigger {
    background: transparent;
    border: none;
    border-left: 1px solid #444;
    height: 100%;
    padding: 0 0.5rem;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #9AA4AA;
    border-radius: 0 0.375rem 0.375rem 0;
    position: relative;
    z-index: 10;
}
.library-dropdown-trigger:hover {
    color: #FFE600;
    background-color: rgba(255, 230, 0, 0.1);
}
.library-dropdown-trigger i {
    font-size: 0.75rem;
}
.library-dropdown {
    position: absolute;
    left: 0;
    top: calc(100% + 4px);
    width: max-content;
    background-color: #212222;
    border: 1px solid #444;
    border-radius: 0.375rem;
    padding: 0.25rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    display: flex;
    flex-direction: column;
}
.library-dropdown.show {
    opacity: 1;
    pointer-events: auto;
}
.library-dropdown-option {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: transparent;
    border: none;
    color: #fff;
    text-align: left;
    cursor: pointer;
    border-radius: 0.25rem;
    transition: background-color 0.15s ease;
    font-size: 0.95rem;
    white-space: nowrap;
}
.library-dropdown-option:hover {
    background-color: rgba(255, 230, 0, 0.15);
    color: #FFE600;
}
.library-dropdown-option.selected {
    background-color: rgba(255, 230, 0, 0.1);
    color: #FFE600;
}
@media (max-width: 768px) {
    .library-selector-wrapper {
        height: 28px;
    }
    .library-label {
        font-size: 0.9rem;
        padding: 0.2rem 0.4rem 0.2rem 0.6rem;
    }
    .library-dropdown-trigger {
        padding: 0 0.4rem;
    }
    .library-dropdown-trigger i {
        font-size: 0.7rem;
    }
    .library-dropdown {
        min-width: 160px; /* Ensure dropdown is readable on mobile */
    }
    .library-dropdown-option {
        font-size: 0.875rem;
        padding: 0.4rem 0.6rem;
    }
}
.breadcrumb-library-selector-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    background-color: #212222;
    border: 1px solid #444;
    border-radius: 0.375rem;
    height: 30px;
    
    transition: all 0.2s ease;
}

.breadcrumb-library-selector-wrapper:hover {
    background-color: #2a2a2a;
    border-color: #FFE600;
}

.breadcrumb-library-label {
    color: #fff;
    font-size: 1rem;
    font-weight: 500;
    padding: 0.25rem 0.5rem 0.25rem 0.75rem;
    display: inline-flex;
    align-items: center;
    height: 100%;
    border-radius: 0.375rem 0 0 0.375rem;
    cursor: default;
}

.breadcrumb-library-dropdown-trigger {
    background: transparent;
    border: none;
    border-left: 1px solid #444;
    height: 100%;
    padding: 0 0.5rem;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #9AA4AA;
    border-radius: 0 0.375rem 0.375rem 0;
    position: relative;
    z-index: 10;
}

.breadcrumb-library-dropdown-trigger:hover {
    color: #FFE600;
    background-color: rgba(255, 230, 0, 0.1);
}

.breadcrumb-library-dropdown-trigger i {
    font-size: 0.75rem;
}

.breadcrumb-library-dropdown {
    position: absolute;
    left: 0;
    top: calc(100% + 4px);
    width: max-content;
    background-color: #212222;
    border: 1px solid #444;
    border-radius: 0.375rem;
    padding: 0.25rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    display: flex;
    flex-direction: column;
}

.breadcrumb-library-dropdown.show {
    opacity: 1;
    pointer-events: auto;
}

.breadcrumb-library-dropdown-option {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: transparent;
    border: none;
    color: #fff;
    text-align: left;
    cursor: pointer;
    border-radius: 0.25rem;
    transition: background-color 0.15s ease;
    font-size: 0.95rem;
    white-space: nowrap;
}

.breadcrumb-library-dropdown-option:hover {
    background-color: rgba(255, 230, 0, 0.15);
    color: #FFE600;
}

.breadcrumb-library-dropdown-option.selected {
    background-color: rgba(255, 230, 0, 0.1);
    color: #FFE600;
}

@media (max-width: 768px) {
    .breadcrumb-library-selector-wrapper {
        height: 28px;
    }

    .breadcrumb-library-label {
        font-size: 0.9rem;
        padding: 0.2rem 0.4rem 0.2rem 0.6rem;
    }

    .breadcrumb-library-dropdown-trigger {
        padding: 0 0.4rem;
    }

    .breadcrumb-library-dropdown-trigger i {
        font-size: 0.7rem;
    }

    .breadcrumb-library-dropdown {
        min-width: 160px; /* Ensure dropdown is readable on mobile */
    }

    .breadcrumb-library-dropdown-option {
        font-size: 0.875rem;
        padding: 0.4rem 0.6rem;
    }
}

/* ==========================================================================
   Call Page - Media Selection Styles
   ========================================================================== */

.media-selection-container {
    max-width: 900px;
    margin: 2rem auto;
    padding: 2rem;
    background: #212222;
    border: 2px solid #444;
    border-radius: 0.75rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.media-selection-title {
    font-size: 1.75rem;
    font-weight: 600;
    color: #FFE600;
    margin-bottom: 1.5rem;
    text-align: center;
}

.media-selection-content {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
}

.media-preview-section {
    flex: 0 0 400px;
    display: flex;
    flex-direction: column;
}

.media-preview-wrapper {
    position: relative;
    background: #181c20;
    border: 2px solid #444;
    border-radius: 0.5rem;
    overflow: hidden;
    aspect-ratio: 16 / 9;
}

.media-preview-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #181c20;
}

.media-preview-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #9AA4AA;
}

.media-preview-placeholder i {
    font-size: 4rem;
    margin-bottom: 1rem;
    color: #444;
}

.media-preview-placeholder p {
    font-size: 1rem;
    margin: 0;
}

.media-device-controls {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.device-selection-group {
    background: #1a1d21;
    padding: 1.25rem;
    border-radius: 0.5rem;
    border: 1px solid #2a2e32;
}

.device-selection-group h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #FFE600;
    margin: 0 0 1rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.device-selection-group h3 i {
    font-size: 1.3rem;
}

.device-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: #23272b;
    border: 2px solid transparent;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.device-option:hover {
    border-color: #444;
    background: #2a2e32;
}

.device-option.selected {
    border-color: #FFE600;
    background: #2a2e32;
}

.device-option input[type="radio"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #FFE600;
}

.device-option label {
    flex: 1;
    color: #fff;
    margin: 0;
    cursor: pointer;
    font-size: 0.95rem;
}

.device-single-label {
    color: #fff;
    margin: 0;
    padding: 0.5rem 0;
    font-size: 0.95rem;
}

.device-unavailable-message {
    color: #9AA4AA;
    font-style: italic;
    margin: 0;
    padding: 0.5rem 0;
    font-size: 0.9rem;
}

.audio-level-indicator {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: #23272b;
    border-radius: 0.375rem;
}

.audio-level-label {
    color: #9AA4AA;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.audio-level-bar-container {
    height: 8px;
    background: #1a1d21;
    border-radius: 4px;
    overflow: hidden;
}

.audio-level-bar {
    height: 100%;
    background: linear-gradient(to right, #5FAE59, #FFE600, #d32f2f);
    width: 0%;
    transition: width 0.1s ease;
    border-radius: 4px;
}

.media-selection-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    padding-top: 1rem;
    border-top: 1px solid #2a2e32;
}

.media-selection-actions .btn {
    min-width: 140px;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
}

.media-selection-actions .btn-secondary {
    background: #444;
    border: 2px solid #555;
    color: #fff;
}

.media-selection-actions .btn-secondary:hover {
    background: #555;
    border-color: #666;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.media-selection-actions .btn-primary {
    background: #5FAE59;
    border: 2px solid #5FAE59;
    color: #fff;
}

.media-selection-actions .btn-primary:hover {
    background: #4a9547;
    border-color: #4a9547;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(90, 174, 89, 0.4);
}

.media-selection-actions .btn-primary:disabled {
    background: #444;
    border-color: #444;
    color: #9AA4AA;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Base message container (shared layout for error and info) */
.media-selection-message {
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.media-selection-message i {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.media-selection-message p {
    margin: 0;
    font-size: 0.95rem;
}

/* Error variant (red) */
.media-selection-error {
    background: rgba(211, 47, 47, 0.15);
    border: 2px solid #d32f2f;
    color: #ff6b6b;
}

/* Info variant (blue) */
.media-selection-info {
    background: rgba(0, 162, 232, 0.15);
    border: 2px solid #00A2E8;
    color: #5eb8ff;
}

/* Media selection loading overlay */
.media-selection-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    gap: 1.25rem;
    color: #9AA4AA;
    font-size: 1rem;
}

.media-selection-loading p {
    margin: 0;
}

.media-selection-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #2a2e32;
    border-top-color: #FFE600;
    border-radius: 50%;
    animation: ms-spin 0.8s linear infinite;
}

@keyframes ms-spin {
    to { transform: rotate(360deg); }
}

/* "No Camera" device option */
.device-option.no-camera-option {
    border-style: dashed;
}

.device-option.no-camera-option label {
    color: #9AA4AA;
}

.device-option.no-camera-option.selected label {
    color: #fff;
}

/* Responsive adjustments for media selection */
@media (max-width: 900px) {
    .media-selection-content {
        flex-direction: column;
    }

    .media-preview-section {
        flex: 1;
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    .media-selection-container {
        padding: 1.5rem 1rem;
        margin: 1rem;
    }

    .media-selection-title {
        font-size: 1.5rem;
        margin-bottom: 1.25rem;
    }

    .media-selection-content {
        gap: 1.5rem;
        margin-bottom: 1.5rem;
    }

    .media-device-controls {
        gap: 1.25rem;
    }

    .device-selection-group {
        padding: 1rem;
    }

    .device-selection-group h3 {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .media-selection-container {
        padding: 1rem 0.75rem;
        margin: 0.5rem;
    }

    .media-selection-title {
        font-size: 1.25rem;
        margin-bottom: 1rem;
    }

    .media-selection-actions {
        flex-direction: column;
    }

    .media-selection-actions .btn {
        width: 100%;
    }

    .device-option {
        padding: 0.6rem;
    }

    .device-option label {
        font-size: 0.875rem;
    }
}

/* ==========================================================================
   Call Page - Video Device Selector Overlay
   ========================================================================== */

.call-video-wrapper {
    position: relative;
}

.video-device-selector {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 100;
    display: flex;
    gap: 0.5rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

/* Fullscreen and PiP action buttons — bottom-right corner of the video */
.video-action-buttons {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    z-index: 100;
    display: flex;
    gap: 0.5rem;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

/* Desktop (mouse): reveal on hover */
@media (pointer: fine) {
    .call-video-wrapper:hover .video-action-buttons,
    .call-video-wrapper:hover .video-device-selector {
        opacity: 1;
        pointer-events: auto;
    }
}

/* Touch (coarse pointer): reveal via JS-toggled .controls-visible class */
@media (pointer: coarse) {
    .call-video-wrapper.controls-visible .video-action-buttons,
    .call-video-wrapper.controls-visible .video-device-selector {
        opacity: 1;
        pointer-events: auto;
    }
}

/* Volume control group: mute button + range slider in one pill */
.video-volume-group {
    display: flex;
    align-items: center;
    background-color: rgba(33, 34, 34, 0.85);
    border: 1px solid #444;
    border-radius: 0.375rem;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.video-volume-group .video-device-btn {
    border: none !important;
    box-shadow: none !important;
    border-radius: 0.25rem 0 0 0.25rem !important;
    flex-shrink: 0;
}

.video-volume-slider {
    width: 80px;
    height: 4px;
    cursor: pointer;
    accent-color: #FFE600;
    background: transparent;
    margin: 0 0.5rem;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .video-action-buttons {
        bottom: 0.5rem;
        right: 0.5rem;
    }

    .video-volume-slider {
        width: 60px;
    }
}

@media (max-width: 480px) {
    .video-volume-slider {
        width: 48px;
    }
}

.video-device-btn {
    background-color: rgba(33, 34, 34, 0.85) !important;
    border: 1px solid #444 !important;
    color: #fff !important;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.video-device-btn:hover {
    background-color: rgba(42, 42, 42, 0.95) !important;
    border-color: #FFE600 !important;
    color: #FFE600 !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.video-device-btn:active,
.video-device-btn:focus {
    background-color: rgba(42, 42, 42, 0.95) !important;
    border-color: #FFE600 !important;
    color: #FFE600 !important;
    box-shadow: 0 0 0 0.25rem rgba(255, 230, 0, 0.15) !important;
}

.video-device-btn i {
    font-size: 1.1rem;
}

/* Dropdown menu styling */
#videoDeviceDropdownList {
    background-color: rgba(33, 34, 34, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid #444;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    min-width: 200px;
    padding: 0.5rem;
}

#videoDeviceDropdownList .dropdown-item {
    color: #fff;
    padding: 0.6rem 0.85rem;
    border-radius: 0.25rem;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#videoDeviceDropdownList .dropdown-item:hover {
    background-color: rgba(255, 230, 0, 0.15);
    color: #FFE600;
}

#videoDeviceDropdownList .dropdown-item.active {
    background-color: rgba(255, 230, 0, 0.2);
    color: #FFE600;
    font-weight: 500;
}

#videoDeviceDropdownList .dropdown-item i {
    font-size: 1rem;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .video-device-selector {
        top: 0.5rem;
        right: 0.5rem;
    }

    .video-device-btn {
        padding: 0.4rem 0.6rem;
    }

    .video-device-btn i {
        font-size: 1rem;
    }

    #videoDeviceDropdownList {
        min-width: 180px;
    }

    #videoDeviceDropdownList .dropdown-item {
        padding: 0.5rem 0.7rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .video-device-selector {
        top: 0.25rem;
        right: 0.25rem;
    }

    .video-device-btn {
        padding: 0.35rem 0.5rem;
    }

    .video-device-btn i {
        font-size: 0.95rem;
    }

    #videoDeviceDropdownList {
        min-width: 160px;
    }
}

/* ==========================================================================
   Call Page - Local Self-View (PiP) Overlay
   ========================================================================== */

.self-view-container {
    position: absolute;
    bottom: 3.5rem;
    left: 1rem;
    z-index: 90;
    width: 200px;
    border-radius: 0.5rem;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    background: #000;
    cursor: grab;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
    user-select: none;
}

.self-view-container:hover {
    border-color: rgba(255, 230, 0, 0.4);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
}

.self-view-container.self-view-dragging {
    cursor: grabbing;
    border-color: rgba(255, 230, 0, 0.6);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.7);
    transition: none;
}

.self-view-video {
    position: relative;
    z-index: 1;
    width: 100%;
    display: block;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    background: #111;
}

/* Rendered at full size behind selfViewVideo so Chrome decodes frames.
   opacity:0.001 forces a compositing layer (opacity:0 may be skipped).
   disablepictureinpicture is NOT set here so requestPictureInPicture() works.
   selfViewVideo (z-index:1) covers it entirely, blocking Chrome's native PiP overlay. */
.self-view-pip-helper {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    opacity: 0.001;
    pointer-events: none;
    object-fit: cover;
}

.self-view-toggle-btn {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    z-index: 2;
    background-color: rgba(0, 0, 0, 0.55);
    border: none;
    color: #fff;
    border-radius: 50%;
    width: 1.5rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease, background-color 0.2s ease;
    font-size: 0.7rem;
    padding: 0;
}

.self-view-container:hover .self-view-toggle-btn {
    opacity: 1;
}

.self-view-toggle-btn:hover {
    background-color: rgba(0, 0, 0, 0.8);
}

/* PiP button sits on the top-left, mirroring the hide button on the top-right */
.self-view-pip-btn {
    right: auto;
    left: 0.25rem;
}

@media (max-width: 768px) {
    .self-view-container {
        width: 150px;
        bottom: 3rem;
        left: 0.5rem;
    }

    .self-view-toggle-btn {
        opacity: 1;
    }
}

@media (max-width: 480px) {
    .self-view-container {
        width: 120px;
        bottom: 2.5rem;
        left: 0.5rem;
    }
}

