/**
 * UI Enhancements - Shared styles for Arkivmappen
 * Hover effects, transitions, loading states, and visual feedback
 */

/* ==========================================================================
   Page Header
   ========================================================================== */

.page-header {
    padding-top: 1rem;
    padding-bottom: 1rem;
}

/* ==========================================================================
   Table Layout Fixes
   ========================================================================== */

/* Ensure table-responsive doesn't cause horizontal overflow */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Constrain table to container with fixed layout */
.table {
    width: 100%;
    table-layout: fixed;
}

/* Column proportions (total ~100%):
   - Checkbox: 4%
   - Drag handle: 3%
   - Filename: 45%
   - Size: 10%
   - Type: 15%
   - Date: 10%
   - Actions: 13%
*/

.table .checkbox-cell {
    width: 4%;
}

.table .drag-cell {
    width: 3%;
}

.table .filename-cell {
    width: 40%;
    max-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Admin table - auto-size columns, no horizontal scroll */
.table-admin {
    table-layout: auto;
    width: 100%;
}

.table-admin td,
.table-admin th {
    white-space: nowrap;
}

.table .size-cell {
    width: 10%;
    white-space: nowrap;
}

.table .type-cell {
    width: 12%;
    max-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.table .date-cell {
    width: 10%;
    white-space: nowrap;
}

.table .status-cell {
    width: 12%;
    white-space: nowrap;
}

.table .actions-cell {
    width: 13%;
    white-space: nowrap;
}

/* Prevent card content from overflowing */
.card {
    max-width: 100%;
}

/* Ensure card header content wraps properly */
.card-header {
    flex-wrap: wrap;
}

/* ==========================================================================
   Table Row Hover Effects
   ========================================================================== */

.table tbody tr {
    transition: background-color 0.15s ease-in-out;
}

.table tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

.table-hover tbody tr:hover {
    background-color: rgba(32, 107, 196, 0.06);
}

/* Clickable table rows */
.table tbody tr.clickable {
    cursor: pointer;
}

.table tbody tr.clickable:hover {
    background-color: rgba(32, 107, 196, 0.08);
}

/* Selected row state */
.table tbody tr.selected {
    background-color: rgba(32, 107, 196, 0.1);
}

.table tbody tr.selected:hover {
    background-color: rgba(32, 107, 196, 0.14);
}

/* ==========================================================================
   Button Enhancements
   ========================================================================== */

.btn {
    transition: all 0.15s ease-in-out;
}

.btn:hover:not(:disabled):not(.disabled) {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn:active:not(:disabled):not(.disabled) {
    transform: translateY(0);
    box-shadow: none;
}

/* Button loading state */
.btn.is-loading {
    pointer-events: none;
    opacity: 0.85;
    cursor: wait;
}

.btn.is-loading .btn-spinner {
    display: inline-block;
}

/* Button success state */
.btn.is-success {
    pointer-events: none;
}

/* Icon buttons (no lift effect) */
.btn-icon:hover:not(:disabled) {
    transform: none;
    box-shadow: none;
}

/* ==========================================================================
   Card Hover Effects
   ========================================================================== */

.card.card-link {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

.card.card-link:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.card.card-link:active {
    transform: translateY(-2px);
}

/* ==========================================================================
   Focus States (Accessibility)
   ========================================================================== */

.btn:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible {
    outline: 2px solid rgba(32, 107, 196, 0.5);
    outline-offset: 2px;
}

/* ==========================================================================
   Form Validation States
   ========================================================================== */

.form-control.is-valid {
    border-color: #2fb344;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%232fb344' d='M2.3 6.73.6 4.53c-.4-1.04.46-1.4 1.1-.8l1.1 1.4 3.4-3.8c.6-.63 1.6-.27 1.2.7l-4 4.6c-.43.5-.8.4-1.1.1z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem 1rem;
    padding-right: 2.5rem;
}

.form-control.is-invalid {
    border-color: #d63939;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23d63939'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23d63939' stroke='none'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem 1rem;
    padding-right: 2.5rem;
}

.valid-feedback {
    display: block;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: #2fb344;
}

.invalid-feedback {
    display: block;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: #d63939;
}

/* ==========================================================================
   Toast Container
   ========================================================================== */

.toast-container {
    z-index: 1080;
}

.toast-container .toast {
    animation: slideInDown 0.3s ease-out;
}

.toast-container .toast.hiding {
    animation: slideOutUp 0.3s ease-out forwards;
}

@keyframes slideInDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideOutUp {
    from {
        transform: translateY(0);
        opacity: 1;
    }
    to {
        transform: translateY(-100%);
        opacity: 0;
    }
}

/* ==========================================================================
   Modal Loading Overlay
   ========================================================================== */

.modal-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: inherit;
}

/* Modal success state */
.modal-success-state {
    text-align: center;
    padding: 2rem;
}

.modal-success-state .icon-success {
    width: 64px;
    height: 64px;
    color: #2fb344;
    margin-bottom: 1rem;
    animation: scaleIn 0.3s ease-out;
}

@keyframes scaleIn {
    from {
        transform: scale(0);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* ==========================================================================
   Dropdown Enhancements
   ========================================================================== */

.dropdown-item {
    transition: background-color 0.15s ease;
}

/* ==========================================================================
   Progress Bar Enhancements
   ========================================================================== */

.progress-bar {
    transition: width 0.3s ease;
}

/* ==========================================================================
   Badge Hover Effects
   ========================================================================== */

.badge.badge-hover {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    cursor: pointer;
}

.badge.badge-hover:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

/* ==========================================================================
   List Group Enhancements
   ========================================================================== */

.list-group-item {
    transition: background-color 0.15s ease;
}

.list-group-item-action:hover {
    background-color: rgba(32, 107, 196, 0.06);
}

/* ==========================================================================
   Skeleton Loading
   ========================================================================== */

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

.skeleton-row {
    pointer-events: none;
}

.skeleton-row td {
    padding: 0.75rem 0.5rem;
}

.skeleton-cell {
    height: 1rem;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

.skeleton-cell.skeleton-checkbox {
    width: 16px;
    height: 16px;
}

.skeleton-cell.skeleton-filename {
    width: 70%;
    height: 1rem;
}

.skeleton-cell.skeleton-size {
    width: 50px;
    height: 1rem;
}

.skeleton-cell.skeleton-type {
    width: 60px;
    height: 1rem;
}

.skeleton-cell.skeleton-date {
    width: 70px;
    height: 1rem;
}

.skeleton-cell.skeleton-actions {
    width: 80px;
    height: 1.5rem;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Dark mode skeleton colors */
[data-bs-theme="dark"] .skeleton,
[data-bs-theme="dark"] .skeleton-cell {
    background: linear-gradient(90deg, #2a2a3e 25%, #3a3a4e 50%, #2a2a3e 75%);
    background-size: 200% 100%;
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */

/* Fade in animation */
.fade-in {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Pulse animation for attention */
.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

/* Smooth collapse transition */
.collapse-smooth {
    transition: max-height 0.3s ease-out, opacity 0.3s ease-out;
    overflow: hidden;
}

/* ==========================================================================
   Mobile Responsive Styles
   ========================================================================== */

/* Mobile folder sidebar toggle button */
.mobile-sidebar-toggle {
    display: none;
    width: 100%;
    margin-bottom: 1rem;
}

/* Mobile-specific header adjustments */
@media (max-width: 767.98px) {
    /* Page header layout */
    .page-header .row.g-2 {
        flex-wrap: wrap;
    }

    .page-header .col-auto.ms-auto {
        width: 100%;
        margin-top: 0.75rem;
        margin-left: 0 !important;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    /* Hide text labels in header buttons on mobile, show only icons */
    .page-header .btn-text-mobile {
        display: none;
    }

    /* Buttons with hidden text - center icons on mobile */
    /* Applies to any button containing .btn-text-mobile (which is hidden above) */
    .page-header .btn-upload-mobile,
    .page-header .btn-dashboard-mobile {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 2.5rem;
        padding: 0.375rem 0.75rem;
    }

    /* Reset icon margins inside these buttons on mobile (Tabler adds negative left margin) */
    .page-header .btn-upload-mobile .icon,
    .page-header .btn-dashboard-mobile .icon {
        margin: 0;
    }

    /* Generic utility: any button with .btn-icon-mobile class becomes icon-only centered */
    .btn-icon-mobile {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        min-width: 2.5rem;
        padding: 0.375rem 0.75rem;
    }

    .btn-icon-mobile .icon {
        margin: 0 !important;
    }

    /* Show mobile sidebar toggle */
    .mobile-sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Mobile sidebar - slide down drawer */
    .col-md-3.mobile-sidebar {
        flex: 0 0 100%;
        max-width: 100%;
        width: 100%;
        margin-bottom: 0.5rem;
        position: relative;
    }

    .mobile-sidebar-collapse {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        z-index: 1050;
        margin-top: 0.25rem;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
        border-radius: 0.5rem;
        overflow: hidden;
        max-height: 0;
        opacity: 0;
        transform: translateY(-10px);
        transition: max-height 0.3s ease-out, opacity 0.2s ease-out, transform 0.3s ease-out;
        pointer-events: none;
    }

    .mobile-sidebar-collapse.show {
        max-height: 70vh;
        opacity: 1;
        transform: translateY(0);
        pointer-events: auto;
    }

    .mobile-sidebar-collapse .card {
        margin: 0;
        border: none;
        border-radius: 0.5rem;
    }

    .mobile-sidebar-collapse .card-header {
        padding: 0.5rem;
    }

    .mobile-sidebar-collapse .card-body {
        padding: 0.75rem;
        max-height: calc(70vh - 60px);
        overflow-y: auto;
    }

    .mobile-sidebar-collapse .folder-tree {
        max-height: none;
    }

    /* Backdrop when drawer is open */
    .mobile-sidebar-backdrop {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.3);
        z-index: 1040;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease-out, visibility 0.3s ease-out;
    }

    .mobile-sidebar-backdrop.show {
        opacity: 1;
        visibility: visible;
    }

    /* Make main content full width on mobile */
    .col-md-9 {
        flex: 0 0 100%;
        max-width: 100%;
        width: 100%;
    }

    /* Breadcrumb text size */
    .breadcrumb {
        font-size: 0.8125rem;
    }

    /* Card header tabs - make scrollable */
    .card-header-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .card-header-tabs .nav-link {
        white-space: nowrap;
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }

    /* Hide tab text on very small screens, show icons */
    .nav-tabs .nav-link .tab-text-mobile {
        display: none;
    }

    /* File search in card header - full width on mobile */
    .card-header .ms-auto {
        width: 100%;
        margin-top: 0.75rem;
        margin-left: 0 !important;
        flex-direction: column;
        align-items: stretch !important;
    }

    .card-header #fileSearch {
        width: 100% !important;
        margin-bottom: 0.5rem;
    }

    /* Search scope toggle - compact */
    #searchScopeToggle {
        width: 100%;
    }

    #searchScopeToggle .btn {
        flex: 1;
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }

    /* Table cells - compact on mobile */
    .table th,
    .table td {
        padding: 0.5rem 0.25rem;
        font-size: 0.8125rem;
    }

    /* Switch to auto layout on mobile so hidden columns don't leave gaps */
    .table:not(.table-admin) {
        table-layout: auto;
    }

    /* Hide less important columns on mobile */
    .table .hide-mobile,
    .table .size-cell,
    .table .type-cell,
    .table .date-cell,
    .table .status-cell,
    .table th.size-cell,
    .table th.type-cell,
    .table th.date-cell,
    .table th.status-cell {
        display: none !important;
    }

    /* Filename cell - can now use more space */
    .table .filename-cell {
        width: auto;
        max-width: none;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Checkbox cell - fixed small width */
    .table .checkbox-cell {
        width: 40px;
    }

    /* Drag cell hidden, but set width to 0 in case */
    .table .drag-cell {
        width: 0;
        padding: 0 !important;
    }

    /* Action buttons in table - icon only */
    .table .btn-action-mobile .btn-text {
        display: none;
    }

    .table .btn-action-mobile {
        padding: 0.25rem 0.5rem;
    }

    /* Multi-select indicator - stack elements */
    .multi-select-indicator,
    .multi-select-actions {
        flex-direction: column;
        align-items: stretch !important;
        text-align: center;
    }

    .multi-select-indicator .flex-grow-1,
    .multi-select-actions .flex-grow-1 {
        margin-bottom: 0.5rem;
    }

    .multi-select-actions .btn {
        width: 100%;
        margin-bottom: 0.25rem;
    }

    /* Folder tree - compact on mobile */
    .folder-tree {
        max-height: 200px;
        overflow-y: auto;
    }

    .folder-item {
        padding: 0.375rem;
        font-size: 0.875rem;
    }

    /* Sidebar card - compact on mobile */
    .mobile-sidebar .card {
        min-height: auto !important;
    }

    .mobile-sidebar .card-body {
        padding: 0.75rem;
    }

    /* Modal adjustments */
    .modal-dialog {
        margin: 0.5rem;
    }

    .modal-body {
        padding: 1rem;
    }

    /* Form selectgroup - stack on mobile */
    .form-selectgroup {
        flex-direction: column;
    }

    .form-selectgroup-item {
        margin-bottom: 0.5rem;
    }

    /* Dashboard cards - full width on mobile */
    .col-md-6 {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    /* Page title - smaller on mobile */
    .page-title {
        font-size: 1.25rem;
    }

    /* Folder action buttons - stack and full width */
    .folder-actions-mobile .btn-group {
        flex-direction: column;
        width: 100%;
    }

    .folder-actions-mobile .btn-group .btn {
        border-radius: 0.25rem !important;
        margin-bottom: 0.25rem;
    }

    .folder-actions-mobile .btn-group .dropdown-toggle-split {
        display: none;
    }

    /* Archive folder buttons - smaller text */
    .archive-folder-buttons .btn {
        font-size: 0.75rem;
        padding: 0.375rem 0.5rem;
    }

    .archive-folder-buttons .btn .icon {
        width: 16px;
        height: 16px;
    }

    /* Search results info - compact */
    #searchResultsInfo {
        padding: 0.5rem;
        font-size: 0.8125rem;
    }

    #searchResultsInfo .d-flex {
        flex-direction: column;
        gap: 0.5rem;
    }

    /* Admin stats cards - 2 per row on mobile */
    .col-lg-3 {
        flex: 0 0 50%;
        max-width: 50%;
    }

    .col-lg-3 .card-body {
        padding: 0.75rem;
    }

    .col-lg-3 .subheader {
        font-size: 0.6875rem;
    }

    .col-lg-3 .h1 {
        font-size: 1.5rem;
    }

}

/* Extra small screens (< 576px) */
@media (max-width: 575.98px) {
    /* Even more compact table */
    .table th,
    .table td {
        padding: 0.375rem 0.25rem;
        font-size: 0.75rem;
    }

    /* Filename column - no max-width needed since other columns are hidden */
    .table .filename-cell {
        max-width: none;
    }

    /* Page title */
    .page-title {
        font-size: 1.125rem;
    }

    /* Logo smaller */
    .page-header img[alt="Arkivmappen"] {
        height: 20px !important;
    }

    /* Buttons in header - icon only, smaller */
    .page-header .btn {
        padding: 0.25rem 0.5rem;
    }

    .page-header .btn .icon {
        width: 18px;
        height: 18px;
    }

    /* Admin stats - 1 per row on very small */
    .col-lg-3.col-sm-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* Card headers */
    .card-header {
        padding: 0.75rem;
    }

    .card-title {
        font-size: 1rem;
    }

    /* Modals - full screen on very small devices */
    .modal-dialog {
        margin: 0;
        max-width: 100%;
        height: 100%;
    }

    .modal-content {
        height: 100%;
        border: 0;
        border-radius: 0;
    }

    /* Tab navigation - icons only */
    .nav-tabs .nav-link {
        padding: 0.5rem;
    }

    .nav-tabs .nav-link .icon {
        margin: 0;
    }
}

/* Tablet landscape and up - ensure sidebar shows */
@media (min-width: 768px) {
    .mobile-sidebar-collapse {
        display: flex !important;
        flex-direction: column;
        position: static;
        max-height: none;
        opacity: 1;
        transform: none;
        pointer-events: auto;
        box-shadow: none;
        overflow: visible;
    }

    .mobile-sidebar-toggle {
        display: none !important;
    }

    /* Folder sidebar expand on hover */
    .col-md-3.mobile-sidebar {
        overflow: visible !important;
        z-index: 10;
    }

    .col-md-3.mobile-sidebar .mobile-sidebar-collapse {
        min-width: 200px;
        transition: min-width 0.3s ease, box-shadow 0.3s ease;
    }

    .col-md-3.mobile-sidebar:hover .mobile-sidebar-collapse {
        min-width: 400px !important;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2) !important;
    }

}

/* ==========================================================================
   Preview Modal (Lightbox)
   ========================================================================== */

#previewModal .modal-content {
    overflow: hidden;
}

#previewModal .modal-body {
    padding: 0;
}

#previewModal .modal-body img,
#previewModal .modal-body video {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
}

#previewModal .modal-body iframe {
    width: 100%;
    height: 80vh;
    border: none;
}

#previewModal .modal-body pre {
    width: 100%;
    height: 80vh;
    overflow: auto;
    margin: 0;
    padding: 1rem;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}

#previewModal .modal-body audio {
    width: 100%;
    max-width: 400px;
}

/* Mobile fullscreen adjustments */
@media (max-width: 991.98px) {
    #previewModal .modal-dialog {
        margin: 0;
        max-width: 100%;
        height: 100%;
    }

    #previewModal .modal-content {
        height: 100%;
        border: 0;
        border-radius: 0;
    }

    #previewModal .modal-body {
        min-height: calc(100vh - 60px);
        height: calc(100vh - 60px);
    }

    #previewModal .modal-body img,
    #previewModal .modal-body video {
        max-height: calc(100vh - 80px);
    }

    #previewModal .modal-body iframe,
    #previewModal .modal-body pre {
        height: calc(100vh - 60px);
    }

    #previewModal .modal-header {
        padding: 0.75rem 1rem;
    }

    #previewModal .modal-title {
        font-size: 0.9375rem;
        max-width: calc(100% - 100px) !important;
    }
}

/* Touch-friendly tap targets */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 44px;
        min-width: 44px;
    }

    .btn-icon {
        min-height: 44px;
        min-width: 44px;
    }

    .dropdown-item {
        padding: 0.75rem 1rem;
    }

    .form-check-input {
        width: 1.25rem;
        height: 1.25rem;
    }

    .folder-item {
        min-height: 44px;
    }

    .nav-link {
        padding: 0.75rem 1rem;
    }
}

/* ==========================================================================
   Admin Table Mobile Improvements
   ========================================================================== */

@media (max-width: 767.98px) {
    /* Hide table headers on mobile - we'll show data in card format */
    .table-admin thead {
        display: none;
    }

    /* Convert table rows to cards on mobile */
    .table-admin tbody {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }

    .table-admin tbody tr {
        display: flex;
        flex-direction: column;
        background: var(--tblr-bg-surface, #fff);
        border: 1px solid var(--tblr-border-color, #e6e7e9);
        border-radius: 0.5rem;
        padding: 1rem;
        gap: 0.5rem;
    }

    .table-admin tbody tr td {
        display: flex;
        align-items: center;
        padding: 0 !important;
        border: none !important;
        white-space: normal !important;
    }

    /* First cell (name) - make it the title */
    .table-admin tbody tr td:first-child {
        font-weight: 600;
        font-size: 1rem;
        color: var(--tblr-body-color);
    }

    /* Email cell styling */
    .table-admin tbody tr td:nth-child(2) {
        font-size: 0.875rem;
        color: var(--tblr-secondary);
        word-break: break-all;
    }

    /* Show all cells on mobile (override .hide-mobile for table cells) */
    .table-admin tbody tr td.hide-mobile {
        display: flex !important;
    }

    /* Add labels before content on mobile */
    .table-admin tbody tr td:nth-child(2)::before {
        content: "E-post: ";
        font-weight: 500;
        color: var(--tblr-secondary);
        margin-right: 0.25rem;
        flex-shrink: 0;
    }

    /* Privilege badges - full width row */
    .table-admin tbody tr td:has(.badge) {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    /* Actions cell - buttons in a row */
    .table-admin tbody tr td:last-child {
        margin-top: 0.5rem;
        padding-top: 0.75rem !important;
        border-top: 1px solid var(--tblr-border-color, #e6e7e9) !important;
        justify-content: stretch;
    }

    .table-admin tbody tr td:last-child .btn-group,
    .table-admin tbody tr td:last-child .d-flex {
        width: 100%;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .table-admin tbody tr td:last-child .btn {
        flex: 1;
        min-width: 0;
        justify-content: center;
    }

    /* Dark mode card styles */
    [data-bs-theme="dark"] .table-admin tbody tr {
        background: var(--tblr-bg-surface, #252540);
        border-color: var(--tblr-border-color, #3d3d5c);
    }

    [data-bs-theme="dark"] .table-admin tbody tr td:last-child {
        border-top-color: var(--tblr-border-color, #3d3d5c) !important;
    }
}

/* ==========================================================================
   Share Modal Improvements
   ========================================================================== */

/* Share file list - better scroll handling */
#shareFileList {
    max-height: 150px;
    overflow-y: auto;
    border-radius: 0.25rem;
}

@media (max-width: 575.98px) {
    #shareFileList {
        max-height: 100px;
    }

    /* Share options - stack on small screens */
    .share-options-row {
        flex-direction: column;
    }

    .share-options-row > * {
        margin-bottom: 0.5rem;
    }
}

/* ==========================================================================
   Noscript Warning
   ========================================================================== */

noscript {
    display: block;
    padding: 2rem;
    text-align: center;
}

noscript .alert {
    max-width: 500px;
    margin: 0 auto;
}

/* ==========================================================================
   No Results State
   ========================================================================== */

.no-results-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #6c757d;
}

.no-results-state .icon {
    width: 48px;
    height: 48px;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.no-results-state h4 {
    margin-bottom: 0.5rem;
    color: #495057;
}

.no-results-state p {
    margin-bottom: 0;
    font-size: 0.875rem;
}

[data-bs-theme="dark"] .no-results-state {
    color: #9ca3af;
}

[data-bs-theme="dark"] .no-results-state h4 {
    color: #e5e7eb;
}

/* ==========================================================================
   Disabled Button Tooltips
   ========================================================================== */

.btn-tooltip-wrapper {
    position: relative;
    display: inline-block;
}

.btn-tooltip-wrapper .btn:disabled + .disabled-tooltip,
.btn-tooltip-wrapper .btn.disabled + .disabled-tooltip {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    color: #fff;
    background-color: #495057;
    border-radius: 0.25rem;
    white-space: nowrap;
    z-index: 1070;
    margin-bottom: 0.25rem;
}

.btn-tooltip-wrapper .btn:disabled + .disabled-tooltip::after,
.btn-tooltip-wrapper .btn.disabled + .disabled-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #495057;
}

.btn-tooltip-wrapper:hover .btn:disabled + .disabled-tooltip,
.btn-tooltip-wrapper:hover .btn.disabled + .disabled-tooltip {
    display: block;
}

/* ==========================================================================
   Retry Feedback
   ========================================================================== */

.retry-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background-color: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 0.375rem;
    color: #856404;
    font-size: 0.875rem;
    animation: pulse 1.5s infinite;
}

.retry-indicator .spinner-border {
    width: 1rem;
    height: 1rem;
}

[data-bs-theme="dark"] .retry-indicator {
    background-color: #423a0f;
    border-color: #f59f00;
    color: #ffd43b;
}

/* ==========================================================================
   Dark Mode
   ========================================================================== */

/* Dark mode toggle button */
.dark-mode-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    background: transparent;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.dark-mode-toggle:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

[data-bs-theme="dark"] .dark-mode-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.dark-mode-toggle .icon-sun,
.dark-mode-toggle .icon-moon {
    width: 20px;
    height: 20px;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.dark-mode-toggle .icon-moon {
    display: block;
}

.dark-mode-toggle .icon-sun {
    display: none;
}

[data-bs-theme="dark"] .dark-mode-toggle .icon-moon {
    display: none;
}

[data-bs-theme="dark"] .dark-mode-toggle .icon-sun {
    display: block;
    color: #fbbf24;
}

/* Dark mode toggle in dropdown */
#darkModeToggle .icon-moon {
    display: inline-block;
}

#darkModeToggle .icon-sun {
    display: none;
}

#darkModeToggle .theme-label-dark {
    display: inline;
}

#darkModeToggle .theme-label-light {
    display: none;
}

[data-bs-theme="dark"] #darkModeToggle .icon-moon {
    display: none;
}

[data-bs-theme="dark"] #darkModeToggle .icon-sun {
    display: inline-block;
    color: #fbbf24;
}

[data-bs-theme="dark"] #darkModeToggle .theme-label-dark {
    display: none;
}

[data-bs-theme="dark"] #darkModeToggle .theme-label-light {
    display: inline;
}

/* Dark mode base overrides */
[data-bs-theme="dark"] {
    color-scheme: dark;
}

[data-bs-theme="dark"] body {
    background-color: #1a1a2e;
    color: #e5e7eb;
}

[data-bs-theme="dark"] .page-wrapper {
    background-color: #1a1a2e;
}

[data-bs-theme="dark"] .page-body {
    background-color: #1a1a2e;
}

[data-bs-theme="dark"] .card {
    background-color: #252540;
    border-color: #3d3d5c;
}

[data-bs-theme="dark"] .card-header {
    background-color: #2a2a45;
    border-color: #3d3d5c;
}

[data-bs-theme="dark"] .table {
    color: #e5e7eb;
}

[data-bs-theme="dark"] .table thead th {
    background-color: #2a2a45;
    border-color: #3d3d5c;
    color: #9ca3af;
}

[data-bs-theme="dark"] .table tbody tr {
    border-color: #3d3d5c;
}

[data-bs-theme="dark"] .table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

[data-bs-theme="dark"] .table tbody tr.selected {
    background-color: rgba(32, 107, 196, 0.2);
}

[data-bs-theme="dark"] .form-control {
    background-color: #2a2a45;
    border-color: #3d3d5c;
    color: #e5e7eb;
}

[data-bs-theme="dark"] .form-control::placeholder {
    color: #6b7280;
}

[data-bs-theme="dark"] .form-control:focus {
    background-color: #2a2a45;
    border-color: #206bc4;
    color: #e5e7eb;
}

[data-bs-theme="dark"] .form-select {
    background-color: #2a2a45;
    border-color: #3d3d5c;
    color: #e5e7eb;
}

[data-bs-theme="dark"] .btn-outline-primary {
    color: #60a5fa;
    border-color: #60a5fa;
}

[data-bs-theme="dark"] .btn-outline-secondary {
    color: #9ca3af;
    border-color: #4b5563;
}

[data-bs-theme="dark"] .dropdown-menu {
    background-color: #252540;
    border-color: #3d3d5c;
}

[data-bs-theme="dark"] .dropdown-item {
    color: #e5e7eb;
}

[data-bs-theme="dark"] .dropdown-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #fff;
}

[data-bs-theme="dark"] .dropdown-divider {
    border-color: #3d3d5c;
}

[data-bs-theme="dark"] .modal-content {
    background-color: #252540;
    border-color: #3d3d5c;
}

[data-bs-theme="dark"] .modal-header {
    border-color: #3d3d5c;
}

[data-bs-theme="dark"] .modal-footer {
    border-color: #3d3d5c;
}


[data-bs-theme="dark"] .text-muted {
    color: #9ca3af !important;
}

[data-bs-theme="dark"] .text-secondary {
    color: #9ca3af !important;
}

[data-bs-theme="dark"] .border {
    border-color: #3d3d5c !important;
}

[data-bs-theme="dark"] .border-dashed {
    border-color: #4b5563 !important;
}

[data-bs-theme="dark"] .alert-info {
    background-color: rgba(32, 107, 196, 0.15);
    border-color: rgba(32, 107, 196, 0.3);
    color: #93c5fd;
}

[data-bs-theme="dark"] .alert-warning {
    background-color: rgba(245, 159, 0, 0.15);
    border-color: rgba(245, 159, 0, 0.3);
    color: #fcd34d;
}

[data-bs-theme="dark"] .alert-success {
    background-color: rgba(47, 179, 68, 0.15);
    border-color: rgba(47, 179, 68, 0.3);
    color: #86efac;
}

[data-bs-theme="dark"] .alert-danger {
    background-color: rgba(214, 57, 57, 0.15);
    border-color: rgba(214, 57, 57, 0.3);
    color: #fca5a5;
}

[data-bs-theme="dark"] .nav-tabs .nav-link {
    color: #9ca3af;
}

[data-bs-theme="dark"] .nav-tabs .nav-link:hover {
    color: #e5e7eb;
    border-color: #3d3d5c;
}

[data-bs-theme="dark"] .nav-tabs .nav-link.active {
    background-color: #252540;
    border-color: #3d3d5c #3d3d5c #252540;
    color: #fff;
}

[data-bs-theme="dark"] .breadcrumb {
    background-color: transparent;
}

[data-bs-theme="dark"] .breadcrumb-item + .breadcrumb-item::before {
    color: #6b7280;
}

[data-bs-theme="dark"] .breadcrumb-item a {
    color: #60a5fa;
}

[data-bs-theme="dark"] .breadcrumb-item.active {
    color: #9ca3af;
}

[data-bs-theme="dark"] .folder-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

[data-bs-theme="dark"] .folder-item.active {
    background-color: rgba(32, 107, 196, 0.2);
}

[data-bs-theme="dark"] .folder-item.matched {
    background-color: rgba(245, 159, 0, 0.2);
}

[data-bs-theme="dark"] .progress {
    background-color: #3d3d5c;
}

[data-bs-theme="dark"] .toast {
    background-color: #252540;
    border-color: #3d3d5c;
}

[data-bs-theme="dark"] .toast-header {
    background-color: #2a2a45;
    border-color: #3d3d5c;
    color: #e5e7eb;
}

[data-bs-theme="dark"] .toast-body {
    color: #e5e7eb;
}

[data-bs-theme="dark"] .multi-select-indicator {
    background-color: rgba(32, 107, 196, 0.2);
    border-color: #60a5fa;
}

[data-bs-theme="dark"] .multi-select-indicator:hover {
    background-color: rgba(32, 107, 196, 0.3);
}

/* Dark mode file row colors */
[data-bs-theme="dark"] .file-row.file-color-blue { background-color: rgba(32, 107, 196, 0.15); }
[data-bs-theme="dark"] .file-row.file-color-red { background-color: rgba(214, 57, 57, 0.15); }
[data-bs-theme="dark"] .file-row.file-color-green { background-color: rgba(47, 179, 68, 0.15); }
[data-bs-theme="dark"] .file-row.file-color-yellow { background-color: rgba(245, 159, 0, 0.15); }
[data-bs-theme="dark"] .file-row.file-color-orange { background-color: rgba(247, 103, 7, 0.15); }
[data-bs-theme="dark"] .file-row.file-color-purple { background-color: rgba(174, 62, 201, 0.15); }
[data-bs-theme="dark"] .file-row.file-color-pink { background-color: rgba(214, 51, 108, 0.15); }
[data-bs-theme="dark"] .file-row.file-color-cyan { background-color: rgba(23, 162, 184, 0.15); }

/* Dark mode page header */
[data-bs-theme="dark"] .page-header {
    background-color: #1a1a2e;
    border-color: #3d3d5c;
}

[data-bs-theme="dark"] .page-title {
    color: #e5e7eb;
}

/* ==========================================================================
   ARIA Live Regions
   ========================================================================== */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Live region container for status announcements */
.live-region {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================================================
   Enhanced Empty State
   ========================================================================== */

.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.empty-state-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e7f3ff 0%, #f0f7ff 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.empty-state-icon .icon {
    width: 40px;
    height: 40px;
    color: #206bc4;
    opacity: 0.8;
}

.empty-state-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.5rem;
}

.empty-state-text {
    color: #6c757d;
    margin-bottom: 1.5rem;
    max-width: 300px;
}

[data-bs-theme="dark"] .empty-state-icon {
    background: linear-gradient(135deg, rgba(32, 107, 196, 0.2) 0%, rgba(32, 107, 196, 0.1) 100%);
}

[data-bs-theme="dark"] .empty-state-icon .icon {
    color: #60a5fa;
}

[data-bs-theme="dark"] .empty-state-title {
    color: #e5e7eb;
}

[data-bs-theme="dark"] .empty-state-text {
    color: #9ca3af;
}

/* ==========================================================================
   Multi-Select Buttons (Mobile Improvements)
   ========================================================================== */

.multi-select-buttons {
    flex-wrap: wrap;
}

.multi-select-buttons .btn-group {
    flex-shrink: 0;
}

@media (max-width: 767.98px) {
    /* Hide button text on mobile, show only icons */
    .multi-select-buttons .btn-text-desktop {
        display: none;
    }

    /* Adjust button padding for icon-only */
    .multi-select-buttons .btn {
        padding: 0.375rem 0.5rem;
    }

    /* Reset icon margins */
    .multi-select-buttons .btn .icon {
        margin: 0;
    }

    /* Keep button groups together */
    .multi-select-buttons {
        gap: 0.5rem;
    }

    /* Multi-select indicator - keep horizontal on mobile */
    .multi-select-indicator {
        flex-direction: row !important;
        flex-wrap: wrap;
        text-align: left !important;
    }

    .multi-select-indicator .flex-grow-1 {
        margin-bottom: 0 !important;
        min-width: 120px;
        flex: 1;
    }

    .multi-select-buttons {
        margin-left: auto;
        margin-top: 0;
    }
}

@media (max-width: 575.98px) {
    /* On very small screens, stack the indicator content */
    .multi-select-indicator {
        flex-direction: column !important;
        text-align: center !important;
    }

    .multi-select-indicator .flex-grow-1 {
        margin-bottom: 0.5rem !important;
    }

    .multi-select-buttons {
        margin-left: 0;
        justify-content: center;
        width: 100%;
    }
}

/* ==========================================================================
   Enhanced Mobile Experience
   ========================================================================== */

/* ---------- Mobile Dashboard Improvements ---------- */
@media (max-width: 767.98px) {
    /* Dashboard navigation cards - better spacing */
    .card.card-link .card-body {
        padding: 1.25rem;
    }

    .card.card-link .card-body p {
        font-size: 0.875rem;
        margin-bottom: 1rem;
    }

    .card.card-link .card-body .btn {
        width: 100%;
    }

    /* Dashboard cards - equal height on mobile */
    .row-deck > [class*="col-"] {
        margin-bottom: 0.75rem;
    }

    /* Stats cards on dashboard - more compact */
    .row-deck .col-sm-6.col-lg-3 .card-body {
        padding: 1rem;
    }

    .row-deck .col-sm-6.col-lg-3 .h1 {
        font-size: 1.75rem;
        margin-bottom: 0.5rem !important;
    }

    .row-deck .col-sm-6.col-lg-3 .subheader {
        font-size: 0.75rem;
    }

    /* Welcome message - compact */
    .row-deck > .col-12 > .card > .card-body.py-3 {
        padding: 0.75rem !important;
        font-size: 0.875rem;
    }
}

/* ---------- Mobile Header Improvements ---------- */
@media (max-width: 767.98px) {
    /* Header - tighter on mobile */
    .page-header {
        padding-top: 0.75rem;
        padding-bottom: 0.75rem;
    }

    /* Container padding on mobile */
    .page-header .container-xl,
    .page-body .container-xl {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    /* Page title - single line with ellipsis */
    .page-title {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 200px;
    }
}

@media (max-width: 575.98px) {
    .page-title {
        max-width: 150px;
    }
}

/* ---------- Mobile Form Improvements ---------- */
@media (max-width: 767.98px) {
    /* Form labels - slightly smaller */
    .form-label {
        font-size: 0.875rem;
        margin-bottom: 0.375rem;
    }

    /* Input fields - proper size for touch */
    .form-control,
    .form-select {
        font-size: 1rem; /* Prevents zoom on iOS */
        padding: 0.625rem 0.875rem;
    }

    /* Form buttons - full width on mobile */
    form .btn[type="submit"] {
        width: 100%;
        padding: 0.75rem 1rem;
    }

    /* Card actions buttons - better touch */
    .card-actions .btn {
        padding: 0.5rem 0.75rem;
    }
}

/* ---------- Mobile Card Improvements ---------- */
@media (max-width: 767.98px) {
    /* Cards - reduce padding */
    .card-body {
        padding: 1rem;
    }

    /* Card headers - compact */
    .card-header {
        padding: 0.875rem 1rem;
    }

    .card-title {
        font-size: 1rem;
    }

    /* Card with tabs - scrollable */
    .card-header-tabs {
        margin-left: -1rem;
        margin-right: -1rem;
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

/* ---------- Mobile List Group Improvements ---------- */
@media (max-width: 767.98px) {
    /* Share list items - better layout */
    .list-group-item {
        padding: 1rem;
    }

    .list-group-item .d-flex {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    /* Share item actions - full width on mobile */
    .list-group-item .btn-group {
        width: 100%;
        margin-top: 0.75rem;
    }

    .list-group-item .btn-group .btn {
        flex: 1;
    }

    /* Share metadata - stack on mobile */
    .list-group-item .text-muted.small {
        width: 100%;
    }
}

/* ---------- Mobile Modal Improvements ---------- */
@media (max-width: 767.98px) {
    /* Modal dialog - full width with small margin */
    .modal-dialog:not(.modal-sm) {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }

    /* Modal body - scrollable content */
    .modal-body {
        max-height: calc(100vh - 200px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Modal footer - stack buttons on mobile */
    .modal-footer {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .modal-footer > .btn {
        flex: 1;
        min-width: 120px;
    }

    .modal-footer > .btn-secondary {
        order: 1;
    }

    .modal-footer > .btn-primary,
    .modal-footer > .btn-danger,
    .modal-footer > .btn-success {
        order: 0;
        width: 100%;
        flex-basis: 100%;
    }
}

@media (max-width: 575.98px) {
    /* Full screen modals on small phones */
    .modal-dialog:not(.modal-sm) {
        margin: 0;
        max-width: 100%;
        height: 100%;
    }

    .modal-dialog:not(.modal-sm) .modal-content {
        height: 100%;
        border-radius: 0;
        border: none;
    }

    .modal-dialog:not(.modal-sm) .modal-body {
        max-height: none;
        flex: 1;
    }
}

/* ---------- Mobile Settings Page Improvements ---------- */
@media (max-width: 991.98px) {
    /* Settings cards - full width on tablet and mobile */
    .row-deck > .col-lg-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

@media (max-width: 767.98px) {
    /* Passkeys list - better mobile layout */
    #passkeysList .list-group-item {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    #passkeysList .list-group-item .btn {
        width: 100%;
    }

    /* Account info grid - single column */
    .col-md-4 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* ---------- Mobile Storage Management (Admin) ---------- */
@media (max-width: 767.98px) {
    /* Storage sections - stack on mobile */
    .col-md-6 {
        margin-bottom: 1.5rem;
    }

    .col-md-6:last-child {
        margin-bottom: 0;
    }

    /* Storage management button groups - stack on mobile */
    /* Only target btn-groups that are direct children of col-md-6 or card-body */
    .card-body > .btn-group:not(.multi-select-buttons .btn-group):not(.actions-cell .btn-group) {
        display: flex;
        flex-direction: column;
        width: 100%;
    }

    .card-body > .btn-group:not(.multi-select-buttons .btn-group):not(.actions-cell .btn-group) .btn {
        border-radius: 0.25rem !important;
        margin-bottom: 0.5rem;
    }

    .card-body > .btn-group:not(.multi-select-buttons .btn-group):not(.actions-cell .btn-group) .btn:last-child {
        margin-bottom: 0;
    }

    /* Storage stats - horizontal on mobile */
    .d-flex.gap-4 {
        flex-wrap: wrap;
        gap: 1rem !important;
    }
}

/* ---------- Mobile Navigation Bottom Bar Safe Area ---------- */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .page-body {
        padding-bottom: env(safe-area-inset-bottom);
    }

    .modal-footer {
        padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    }
}

/* ---------- Mobile File Row Expanded Details ---------- */
@media (max-width: 767.98px) {
    .file-details-row .file-details-cell {
        padding: 0.75rem !important;
    }

    .file-details-grid {
        gap: 0.5rem 1rem;
    }

    .file-detail-label {
        font-size: 0.6875rem;
    }

    .file-detail-value {
        font-size: 0.8125rem;
    }
}

/* ---------- Mobile Dropdown Menu Improvements ---------- */
@media (max-width: 767.98px) {
    /* Dropdown menus - full width on mobile */
    .dropdown-menu {
        min-width: 200px;
    }

    .dropdown-menu-end {
        right: 0;
        left: auto;
    }

    /* User dropdown - larger touch targets */
    .dropdown-item {
        padding: 0.75rem 1rem;
    }
}

/* ---------- Mobile Tab Improvements ---------- */
@media (max-width: 575.98px) {
    /* Tabs - larger touch targets, horizontal scroll */
    .nav-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .nav-tabs::-webkit-scrollbar {
        display: none;
    }

    .nav-tabs .nav-item {
        flex-shrink: 0;
    }

    .nav-tabs .nav-link {
        padding: 0.75rem 1rem;
        white-space: nowrap;
    }
}

/* ---------- Mobile Alert Improvements ---------- */
@media (max-width: 767.98px) {
    .alert {
        padding: 0.875rem 1rem;
        font-size: 0.875rem;
    }

    .alert .d-flex {
        flex-wrap: wrap;
    }

    .alert-icon {
        flex-shrink: 0;
    }
}

/* ---------- Mobile Badge Improvements ---------- */
@media (max-width: 575.98px) {
    .badge {
        font-size: 0.6875rem;
        padding: 0.25rem 0.5rem;
    }
}

/* ---------- Better Focus States for Touch ---------- */
@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects on touch devices */
    .btn:hover:not(:disabled):not(.disabled) {
        transform: none;
        box-shadow: none;
    }

    .card.card-link:hover {
        transform: none;
    }

    /* Active states instead */
    .btn:active:not(:disabled):not(.disabled) {
        transform: scale(0.98);
        opacity: 0.9;
    }

    .card.card-link:active {
        transform: scale(0.99);
    }

    /* Better visual feedback for taps */
    .dropdown-item:active,
    .list-group-item-action:active,
    .nav-link:active {
        background-color: rgba(32, 107, 196, 0.1);
    }
}

/* ---------- Mobile Breadcrumb Improvements ---------- */
@media (max-width: 767.98px) {
    .breadcrumb {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0.25rem;
        margin-bottom: 0.5rem;
    }

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

    .breadcrumb-item {
        flex-shrink: 0;
        white-space: nowrap;
    }

    .breadcrumb-item + .breadcrumb-item {
        padding-left: 0.375rem;
    }

    .breadcrumb-item + .breadcrumb-item::before {
        padding-right: 0.375rem;
    }
}

/* ---------- Mobile Invite Button (Admin) ---------- */
@media (max-width: 575.98px) {
    .nav-tabs .nav-item.ms-auto {
        margin-left: 0 !important;
        flex-basis: 100%;
        margin-top: 0.5rem;
    }

    .nav-tabs .nav-item.ms-auto .btn {
        width: 100%;
    }
}

/* ---------- Mobile Login Page Improvements ---------- */
@media (max-width: 575.98px) {
    /* Login card - full width on small phones */
    .page-center .container-tight {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .page-center .card-md {
        margin-left: -0.25rem;
        margin-right: -0.25rem;
    }

    .page-center .card-body {
        padding: 1.5rem 1.25rem;
    }

    /* Logo - responsive size */
    .page-center .navbar-brand img {
        max-width: 160px;
        height: auto;
    }

    /* Verification code input - larger on mobile */
    #verification-code {
        font-size: 1.75rem !important;
        letter-spacing: 0.5rem !important;
        padding: 0.875rem 0.5rem;
    }

    /* Passkey button - prominent */
    #passkey-login-btn {
        padding: 0.875rem 1rem;
        font-size: 1rem;
    }

    /* Register form - better spacing */
    #register-collapse .mb-3 {
        margin-bottom: 1rem !important;
    }
}

/* ---------- Mobile File Browser Improvements ---------- */
@media (max-width: 767.98px) {
    /* Actions cell - fixed width for the 3 buttons */
    .table .actions-cell {
        width: 110px !important;
        min-width: 110px !important;
        white-space: nowrap !important;
        text-align: right !important;
        vertical-align: middle !important;
        padding: 0.25rem 0.5rem !important;
    }

    /* Smaller action buttons on mobile */
    .table .actions-cell .btn {
        width: 30px;
        height: 30px;
        min-width: 30px;
        min-height: 30px;
        padding: 0;
    }

    /* Tighter spacing between action buttons */
    .table .actions-cell .btn.me-2 {
        margin-right: 0.125rem !important;
    }

    /* Icon size in buttons */
    .table .actions-cell .btn .icon {
        width: 16px;
        height: 16px;
    }

    /* File row actions dropdown */
    .table .actions-cell .dropdown-menu {
        position: fixed !important;
        min-width: 200px;
    }

    /* File details expanded row - proper mobile layout */
    .file-details-row .file-details-grid {
        grid-template-columns: 1fr;
    }
}

/* ---------- Mobile Share List Improvements ---------- */
@media (max-width: 767.98px) {
    /* Share list container */
    #sharesList .list-group-item {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
        padding: 1rem;
    }

    /* Share title/info section */
    #sharesList .list-group-item > .d-flex:first-child {
        width: 100%;
        flex-direction: column;
        align-items: flex-start !important;
    }

    /* Share link - truncate on mobile */
    #sharesList .list-group-item code {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        display: block;
        font-size: 0.75rem;
    }

    /* Share actions - full width buttons */
    #sharesList .list-group-item .btn-group {
        width: 100%;
        display: flex;
    }

    #sharesList .list-group-item .btn-group .btn {
        flex: 1;
        padding: 0.5rem;
    }

    /* Share badges - wrap */
    #sharesList .list-group-item .d-flex.gap-2 {
        flex-wrap: wrap;
    }
}

/* ---------- Mobile Color Picker Improvements ---------- */
@media (max-width: 575.98px) {
    .color-picker-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 0.375rem;
    }

    .color-option {
        width: 36px;
        height: 36px;
    }
}

/* ---------- Mobile Empty State Improvements ---------- */
@media (max-width: 767.98px) {
    .empty-state {
        padding: 2rem 1rem;
    }

    .empty-state-icon {
        width: 64px;
        height: 64px;
        margin-bottom: 1rem;
    }

    .empty-state-icon .icon {
        width: 32px;
        height: 32px;
    }

    .empty-state-title {
        font-size: 1.125rem;
    }

    .empty-state-text {
        font-size: 0.875rem;
    }

    .no-results-state {
        padding: 2rem 1rem;
    }

    .no-results-state .icon {
        width: 40px;
        height: 40px;
    }
}

/* ---------- Mobile Progress/Upload Improvements ---------- */
@media (max-width: 767.98px) {
    /* Upload progress - better visibility */
    .progress {
        height: 0.5rem;
        border-radius: 0.25rem;
    }

    /* Move overlay - better mobile display */
    .move-overlay-content {
        width: calc(100% - 2rem);
        max-width: 300px;
        padding: 1.5rem;
    }
}

/* ---------- Mobile Toast Improvements ---------- */
@media (max-width: 575.98px) {
    .toast-container {
        left: 0.5rem !important;
        right: 0.5rem !important;
        max-width: none !important;
    }

    .toast-container .toast {
        width: 100%;
    }
}

/* ---------- Fix iOS Safari 100vh Issue ---------- */
@supports (-webkit-touch-callout: none) {
    /* iOS Safari specific */
    .modal-dialog:not(.modal-sm) .modal-content {
        max-height: -webkit-fill-available;
    }

    @media (max-width: 575.98px) {
        .modal-dialog:not(.modal-sm) {
            height: -webkit-fill-available;
        }
    }
}
