html {
    overflow-x: hidden;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #121212;
    color: #e0e0e0;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
}

.navbar {
    background-color: #1e1e1e !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

h1 {
    text-align: center;
    color: #bb86fc;
    margin-bottom: 30px;
    font-size: 2.2em;
}

h2 {
    text-align: center;
    color: #bb86fc;
    margin-top: 40px;
    margin-bottom: 20px;
    font-size: 1.8em;
}

.content-container {
    background: #1e1e1e;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    box-sizing: border-box;
    margin: 20px auto;
    width: 100%;
    max-width: calc(100% - 40px);
}

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #e0e0e0;
}

input[type="file"],
input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #333;
    border-radius: 4px;
    background-color: #2a2a2a;
    color: #e0e0e0;
    box-sizing: border-box;
    transition: border-color 0.3s, box-shadow 0.3s;
}

input[type="file"]::file-selector-button {
    background-color: #bb86fc;
    color: #121212;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}

input[type="file"]::file-selector-button:hover {
    background-color: #9d6fe7;
}

input[type="text"]:focus,
input[type="password"]:focus {
    border-color: #bb86fc;
    box-shadow: 0 0 5px rgba(187, 134, 252, 0.4);
    outline: none;
}

.info-box {
    background-color: #2a2a2a;
    border-left: 4px solid #bb86fc;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 4px;
    font-size: 0.9em;
    line-height: 1.4;
}

.info-box p {
    margin: 0;
    color: #e0e0e0;
}

.message-container {
    padding: 15px;
    margin: 10px 0;
    border-radius: 4px;
    text-align: center;
    font-weight: bold;
    width: 100%;
    box-sizing: border-box;
}

#progressBarContainer {
    width: 100%;
    background-color: #333;
    border-radius: 5px;
    padding: 3px;
    margin: 20px 0;
}

#progressBar {
    width: 0%;
    height: 20px;
    background: linear-gradient(90deg, #bb86fc, #9d6fe7);
    border-radius: 4px;
    transition: width 0.3s ease-in-out;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

#progressText {
    color: #121212;
    font-size: 12px;
    font-weight: bold;
    text-shadow: 1px 1px 1px rgba(255, 255, 255, 0.3);
    z-index: 1;
}

#progressSubText {
    text-align: center;
    font-size: 0.9em;
    color: #b0b0b0;
    margin-top: 5px;
}

/* Styles for multiple upload progress bars */
.progress-item {
    width: 100%;
    background-color: #333;
    border-radius: 5px;
    padding: 3px;
    margin: 20px 0;
}

.progress-bar {
    width: 0%;
    height: 20px;
    background: linear-gradient(90deg, #bb86fc, #9d6fe7);
    border-radius: 4px;
    transition: width 0.3s ease-in-out;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.progress-text {
    color: #121212;
    font-size: 12px;
    font-weight: bold;
    text-shadow: 1px 1px 1px rgba(255, 255, 255, 0.3);
    z-index: 1;
}

.progress-subtext {
    text-align: center;
    font-size: 0.9em;
    color: #b0b0b0;
    margin-top: 5px;
}

button,
.btn {
    padding: 10px 15px;
    background-color: #bb86fc;
    color: #121212;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: background-color 0.3s;
    margin-top: 10px;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

/* Make primary form buttons full width */
form#uploadForm button {
    width: 100%;
}

form#uploadForm {
    margin-bottom: 30px;
}

button:hover,
.btn:hover {
    background-color: #9d6fe7;
}

.error {
    color: #cf6679;
    text-align: center;
    margin-top: 15px;
    font-weight: bold;
}

.error-box {
    background-color: #331c27;
    border-left: 4px solid #cf6679;
    padding: 15px;
    margin: 20px 0;
    border-radius: 4px;
}

.error-box p {
    margin: 0;
    color: #e0e0e0;
}

.success {
    background-color: #1c3330;
    border-left: 4px solid #03dac6;
    padding: 15px;
    margin: 20px 0;
    border-radius: 4px;
    color: #e0e0e0;
}

/* Table styling */
.table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    background-color: #1e1e1e;
    border-radius: 5px;
    /* Allow elements like dropdown menus to extend outside the table.
       The previous overflow:hidden clipped the action menu making it
       appear behind other elements. */
    overflow: visible;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Ensure responsive table containers don't hide dropdown menus */
.table-responsive {
    overflow: visible;
}

/* Ensure dropdown menus from file actions appear above other content */
.table .dropdown-menu {
    position: absolute;
    z-index: 2000;
}

.table th,
.table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #333;
    color: #e0e0e0;
}

.table th {
    background-color: #2a2a2a;
    font-weight: 600;
    color: #bb86fc;
}

.table tbody tr:nth-child(even) {
    background-color: #222;
}

.table tbody tr:hover {
    background-color: #2c2c2c;
}

/* Button styling in tables */
.table td .btn {
    margin: 2px;
    padding: 6px 10px;
    font-size: 0.85em;
    width: auto;
    display: inline-block;
}

.table td .btn-danger {
    background-color: #cf6679;
}

.table td .btn-danger:hover {
    background-color: #b55a69;
}

.table td .btn-primary {
    background-color: #bb86fc;
}

.table td .btn-primary:hover {
    background-color: #9d6fe7;
}

.table td .btn-success {
    background-color: #03dac6;
    color: #121212;
    font-weight: 600;
}

.table td .btn-success:hover {
    background-color: #02c4b5;
    color: #121212;
}

/* File type icons styling */
.file-type-icon {
    font-size: 1.1em;
    margin-right: 8px;
    display: inline-block;
}

/* Action buttons container improvements */
.action-buttons {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 5px;
}

.action-buttons .btn {
    margin: 0;
}

/* Responsive adjustments for action buttons */
@media (max-width: 768px) {
    .action-buttons {
        gap: 3px;
    }

    .action-buttons .btn {
        padding: 4px 6px;
        font-size: 0.75em;
    }

    .action-buttons .btn i {
        margin-right: 2px;
    }
}

/* Ensure consistent spacing for file table columns */
#files-container {
    /* No overflow or height constraints so the table scrolls with the page */
}

#fileTable {
    width: 100%;
    max-width: 100%;
    /* Let column widths adapt to content for responsiveness */
    table-layout: auto;
}

#fileTable th,
#fileTable td {
    padding: 12px;
    box-sizing: border-box;
}

#fileTable .select-column {
    width: clamp(30px, 3%, 40px);
    min-width: 30px;
}

#fileTable .filename-column {
    width: auto;
}

#fileTable .size-column {
    width: clamp(60px, 8%, 100px);
}

#fileTable .folder-column {
    width: clamp(120px, 15%, 200px);
}

#fileTable .public-link-column {
    width: clamp(150px, 20%, 280px);
}

#fileTable .public-access-column {
    width: clamp(60px, 5%, 80px);
}

/* Allow long text to wrap inside table cells */
#fileTable .filename-column,
#fileTable .folder-column,
#fileTable .public-link-column {
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: normal;
}

#fileTable .public-link-column .public-link {
    display: inline;
    overflow-wrap: anywhere;
}

#fileTable th:last-child,
#fileTable td:last-child {
    width: clamp(80px, 10%, 150px);
}

/* Hide less important columns on narrow screens */
@media (max-width: 768px) {
    #fileTable .folder-column,
    #fileTable .public-link-column {
        display: none;
    }
}

@media (max-width: 576px) {
    #fileTable .public-access-column {
        display: none;
    }
}

.filesize-cell {
    white-space: nowrap;
    text-align: right;
    color: #b0b0b0;
}

/* Public link styling */
.public-link {
    color: #bb86fc;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s;
}

.public-link:hover {
    color: #9d6fe7;
    text-decoration: underline;
}

/* Toggle switch styling */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #444;
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: #e0e0e0;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #bb86fc;
}

input:focus + .slider {
    box-shadow: 0 0 1px #bb86fc;
}

input:checked + .slider:before {
    transform: translateX(26px);
}

/* Message container for AJAX feedback */
#messageContainer {
    margin-bottom: 20px;
}

.alert {
    padding: 12px 15px;
    border-radius: 4px;
    margin-bottom: 15px;
}

.alert-success {
    background-color: #1c3330;
    border: 1px solid #03dac6;
    color: #03dac6;
}

.alert-danger {
    background-color: #331c27;
    border: 1px solid #cf6679;
    color: #cf6679;
}

.alert-info,
.alert.alert-info,
#messageContainer .alert-info {
    background-color: #1c332d !important;
    border: 1px solid #03dac6 !important;
    color: #03dac6 !important;
}

/* Custom alert classes for upload process */
.alert-processing,
.alert.alert-processing,
#messageContainer .alert-processing {
    background-color: #311b3f !important;
    border: 1px solid #bb86fc !important;
    color: #bb86fc !important;
}

.alert-finalizing,
.alert.alert-finalizing,
#messageContainer .alert-finalizing {
    background-color: #311b3f !important;
    border: 1px solid #bb86fc !important;
    color: #bb86fc !important;
}

/* Auth container styles */
.auth-container {
    background: #1e1e1e;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    margin: 40px 0;
}

.auth-container h1 {
    margin-bottom: 30px;
    text-align: center;
    color: #bb86fc;
}

.auth-links a {
    color: #bb86fc;
    text-decoration: none;
    transition: color 0.3s;
}

.auth-links a:hover {
    color: #9d6fe7;
    text-decoration: underline;
}

.main-content {
    min-height: calc(100vh - 150px);
    margin-bottom: 30px;
}

/* Responsive improvements */
@media (max-width: 768px) {
    .container {
        padding: 20px;
        width: 95%;
    }
    
    .table td, .table th {
        padding: 10px;
    }
    
    .table td .btn {
        padding: 5px 8px;
        font-size: 0.8em;
        margin: 1px;
    }
}

/* Mobile-specific adjustments for action buttons */
@media (max-width: 768px) {
    /* Allow action buttons to wrap on small screens */
    .action-buttons {
        flex-wrap: wrap;
        gap: 5px;
        align-items: flex-start;
    }

    .action-buttons .btn {
        margin: 2px 0;
        width: auto;
    }
}

/* Modal Overlay System */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal-container {
    position: relative;
    background-color: #1e1e1e;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
    max-width: 95vw;
    max-height: 95vh;
    width: auto;
    height: auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #333;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.modal-overlay.show .modal-container {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background-color: #2a2a2a;
    border-bottom: 1px solid #333;
}

.modal-title {
    color: #bb86fc;
    margin: 0;
    font-size: 1.2em;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: #e0e0e0;
    font-size: 1.5em;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: color 0.3s ease, background-color 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 35px;
    height: 35px;
}

.modal-close:hover {
    color: #cf6679;
    background-color: rgba(207, 102, 121, 0.1);
}

.modal-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.modal-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #bb86fc;
    font-size: 1.1em;
    padding: 60px 40px;
    min-height: 200px;
    background: radial-gradient(circle, rgba(187, 134, 252, 0.1) 0%, transparent 70%);
    border-radius: 12px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.loading-spinner {
    font-size: 3em;
    margin-bottom: 20px;
    color: #bb86fc;
}

.loading-spinner i {
    animation: spin 1.5s linear infinite;
    filter: drop-shadow(0 0 10px rgba(187, 134, 252, 0.5));
}

.modal-loading-text {
    font-size: 1.2em;
    font-weight: 500;
    text-align: center;
    margin-top: 10px;
    color: #e0e0e0;
}

.modal-loading-subtext {
    font-size: 0.9em;
    color: #b0b0b0;
    text-align: center;
    margin-top: 8px;
    opacity: 0.8;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

.modal-loading-text {
    animation: pulse 2s ease-in-out infinite;
}

.modal-media-container {
    display: none;
    max-width: 100%;
    max-height: 100%;
    position: relative;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.modal-media-container.show {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

/* Modal Video Styling */
.modal-video {
    max-width: 90vw;
    max-height: 70vh;
    width: auto;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    background-color: #000;
}

/* Modal Image Styling */
.modal-image {
    max-width: 90vw;
    max-height: 70vh;
    width: auto;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    cursor: zoom-in;
    transition: transform 0.3s ease;
}

.modal-image.zoomed {
    cursor: zoom-out;
    transform: scale(1.5);
}

/* Modal Audio Styling */
.modal-audio {
    width: 400px;
    max-width: 90vw;
    height: 60px;
    border-radius: 8px;
    background-color: #2a2a2a;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* Modal PDF Styling */
.modal-pdf-container {
    width: 90vw;
    max-width: 1200px;
    height: 80vh;
    max-height: 900px;
    display: flex;
    flex-direction: column;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.modal-pdf-iframe {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 8px;
    background-color: #fff;
    flex: 1;
}

.modal-pdf-download-bar {
    background-color: #2a2a2a;
    padding: 10px 15px;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.pdf-controls {
    display: flex;
    gap: 10px;
}

.pdf-controls .btn {
    padding: 6px 12px;
    font-size: 0.9em;
}

.modal-pdf-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #1e1e1e;
    border-radius: 8px;
}

.pdf-fallback-content {
    text-align: center;
    color: #e0e0e0;
    max-width: 400px;
    padding: 40px;
}

.pdf-fallback-content h4 {
    color: #bb86fc;
    margin-bottom: 15px;
}

.pdf-fallback-content p {
    color: #b0b0b0;
    margin-bottom: 25px;
    line-height: 1.5;
}

.mobile-pdf-notice {
    background-color: #2a2a2a;
    color: #03dac6;
    padding: 8px 15px;
    font-size: 0.9em;
    border-bottom: 1px solid #333;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* PDF Loading States */
.modal-pdf-container.loading {
    opacity: 0.6;
}

.modal-pdf-container.loading .modal-pdf-iframe {
    pointer-events: none;
}

.pdf-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(30, 30, 30, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.pdf-loading-spinner {
    text-align: center;
    color: #bb86fc;
}

.pdf-loading-spinner i {
    font-size: 2em;
    margin-bottom: 10px;
    animation: spin 1s linear infinite;
}

/* PDF Error Handling Styles */
.modal-pdf-error {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #1e1e1e;
    border-radius: 8px;
    padding: 40px;
}

.pdf-error-content {
    text-align: center;
    color: #e0e0e0;
    max-width: 400px;
}

.pdf-error-content h4 {
    color: #cf6679;
    margin-bottom: 15px;
    font-size: 1.3em;
}

.pdf-error-content p {
    color: #b0b0b0;
    margin-bottom: 25px;
    line-height: 1.5;
}

.pdf-error-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.pdf-error-actions .btn {
    padding: 10px 20px;
    font-size: 1em;
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.3s ease;
}

.modal-footer {
    padding: 15px 20px;
    background-color: #2a2a2a;
    border-top: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.modal-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
    min-width: 0;
}

.modal-filename {
    color: #e0e0e0;
    font-weight: 600;
    font-size: 1em;
    word-break: break-all;
}

.modal-filesize,
.modal-filetype {
    color: #b0b0b0;
    font-size: 0.9em;
}

.modal-navigation {
    display: flex;
    gap: 10px;
}

.modal-nav-btn {
    background-color: #bb86fc;
    color: #121212;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 600;
    transition: background-color 0.3s ease;
    display: flex;
    align-items: center;
    gap: 5px;
}

.modal-nav-btn:hover {
    background-color: #9d6fe7;
}

.modal-nav-btn:disabled {
    background-color: #444;
    color: #888;
    cursor: not-allowed;
}

/* iOS Safari Specific Optimizations */
@supports (-webkit-touch-callout: none) {
    .modal-overlay {
        /* Prevent iOS Safari scroll bounce */
        position: fixed;
        -webkit-overflow-scrolling: touch;
    }
    
    .modal-video {
        /* Ensure proper aspect ratio on iOS */
        object-fit: contain;
        /* Better performance on iOS */
        transform: translateZ(0);
        -webkit-transform: translateZ(0);
    }
    
    .modal-container {
        /* Prevent iOS zoom issues */
        -webkit-user-select: none;
        user-select: none;
    }
}

/* Mobile Responsive Design */
@media (max-width: 768px) {
    .modal-container {
        max-width: 98vw;
        max-height: 98vh;
        border-radius: 8px;
    }
    /* Ensure overlays never block upload controls in portrait mode */
    @media (orientation: portrait) {
        /* Only hide inactive overlays so media viewer works properly */
        .modal-overlay:not(.show) {
            z-index: 1 !important;
            pointer-events: none !important;
            opacity: 0 !important;
        }
        .modal-overlay.show {
            z-index: 10002 !important;
        }
        .alert {
            z-index: 1 !important;
        }
        #progressBarContainer,
        #uploadForm,
        #fileInput,
        button[type="submit"] {
            z-index: 10001 !important;
            position: relative !important;
        }
    }
    .modal-header {
        padding: 12px 15px;
    }
    
    .modal-title {
        font-size: 1.1em;
    }
    
    .modal-body {
        padding: 15px;
    }
    
    .modal-video {
        max-width: 95vw;
        max-height: 60vh;
    }
    
    .modal-image {
        max-width: 95vw;
        max-height: 60vh;
    }
    
    .modal-audio {
        width: 100%;
        max-width: 95vw;
    }
    
    .modal-pdf-container {
        width: 98vw;
        height: 75vh;
        max-height: 600px;
    }
    
    .modal-pdf-download-bar {
        padding: 8px 12px;
    }
    
    .pdf-controls {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .pdf-controls .btn {
        padding: 8px 12px;
        font-size: 0.85em;
        flex: 1;
        min-width: 100px;
    }
    
    .mobile-pdf-notice {
        padding: 6px 12px;
        font-size: 0.8em;
    }
    
    .pdf-fallback-content {
        padding: 30px 20px;
        max-width: 300px;
    }
    
    .pdf-fallback-content .btn {
        display: block;
        width: 100%;
        margin: 5px 0;
    }
    
    .modal-pdf-error {
        padding: 30px 20px;
    }
    
    .pdf-error-content {
        max-width: 300px;
    }
    
    .pdf-error-actions {
        flex-direction: column;
        gap: 8px;
    }
    
    .pdf-error-actions .btn {
        width: 100%;
        padding: 12px 20px;
    }
    
    .modal-footer {
        padding: 12px 15px;
        flex-direction: column;
        align-items: stretch;
    }
    
    .modal-info {
        margin-bottom: 10px;
    }
    
    .modal-navigation {
        justify-content: center;
    }
    
    .modal-nav-btn {
        flex: 1;
        justify-content: center;
        max-width: 150px;
    }
}

/* Small Mobile Devices */
@media (max-width: 480px) {
    .modal-video {
        max-height: 50vh;
    }
    
    .modal-image {
        max-height: 50vh;
    }
    
    .modal-filename {
        font-size: 0.9em;
    }
    
    .modal-filesize,
    .modal-filetype {
        font-size: 0.8em;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .modal-close {
        width: 44px;
        height: 44px;
        font-size: 1.3em;
    }
    
    .modal-nav-btn {
        padding: 12px 20px;
        font-size: 1em;
        min-height: 44px;
    }
    
    .modal-image {
        /* Enable touch gestures on mobile */
        touch-action: pan-x pan-y pinch-zoom;
    }
}

/* Accessibility Improvements */
.modal-overlay:focus-within .modal-container {
    outline: 2px solid #bb86fc;
    outline-offset: 2px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .modal-overlay {
        background-color: rgba(0, 0, 0, 0.95);
    }
    
    .modal-container {
        border: 2px solid #fff;
    }
    
    .modal-close:hover {
        background-color: rgba(255, 255, 255, 0.2);
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .modal-overlay,
    .modal-container,
    .modal-close,
    .modal-nav-btn,
    .modal-image {
        transition: none;
    }
    
    .loading-spinner i {
        animation: none;
    }
}

/* Dark Mode Optimizations */
@media (prefers-color-scheme: dark) {
    .modal-overlay {
        background-color: rgba(0, 0, 0, 0.95);
    }
}
/* Modal Integration Styles */
.modal-view-btn,
.modal-view-link {
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
}

.modal-view-btn:hover,
.modal-view-link:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(187, 134, 252, 0.3);
}


/* Add visual indicator for viewable files */
tr[data-file-hash] .view-button-container .modal-view-btn::before,
tr[data-file-hash] .view-button-container .modal-view-link::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, #bb86fc, #03dac6);
    border-radius: 6px;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

tr[data-file-hash] .view-button-container .modal-view-btn:hover::before,
tr[data-file-hash] .view-button-container .modal-view-link:hover::before {
    opacity: 0.3;
}

/* Loading state improvements */
.modal-loading {
    background: radial-gradient(circle, rgba(187, 134, 252, 0.1) 0%, transparent 70%);
    border-radius: 12px;
    padding: 40px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transform: translateY(0);
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    0% {
        opacity: 0;
        transform: translateY(-20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile loading adjustments */
@media (max-width: 768px) {
    .modal-loading {
        padding: 30px 20px;
        min-height: 150px;
    }
    
    .loading-spinner {
        font-size: 2.5em;
        margin-bottom: 15px;
    }
    
    .modal-loading-text {
        font-size: 1.1em;
    }
    
    .modal-loading-subtext {
        font-size: 0.85em;
        margin-top: 6px;
    }
}

@media (max-width: 480px) {
    .modal-loading {
        padding: 25px 15px;
        min-height: 120px;
    }
    
    .loading-spinner {
        font-size: 2em;
        margin-bottom: 12px;
    }
    
    .modal-loading-text {
        font-size: 1em;
    }
    
    .modal-loading-subtext {
        font-size: 0.8em;
    }
}

/* Enhanced focus styles for accessibility */
.modal-view-btn:focus,
.modal-view-link:focus {
    outline: 2px solid #bb86fc;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(187, 134, 252, 0.2);
}

/* Smooth transitions for dynamic content */
.view-button-container {
    transition: all 0.3s ease;
}

.view-button-container.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Modal backdrop blur enhancement */
.modal-overlay.show {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* Better visual feedback for touch devices */
@media (hover: none) and (pointer: coarse) {
    .modal-view-btn:active,
    .modal-view-link:active {
        transform: scale(0.95);
        transition: transform 0.1s ease;
    }
}

/* Dark theme styling for move file modal */
#moveModal .modal-content {
    background-color: #1e1e1e;
    color: #e0e0e0;
    border: 1px solid #bb86fc;
}

#moveModal .modal-header {
    border-bottom: 1px solid #333;
}

#moveModal .modal-title {
    color: #bb86fc;
}

#moveModal .close {
    color: #e0e0e0;
    text-shadow: none;
}

#moveModal .close:hover {
    color: #bb86fc;
}

#moveModal .list-group-item {
    background-color: #1e1e1e;
    color: #e0e0e0;
    border: 1px solid #333;
    cursor: pointer;
}

#moveModal .list-group-item:hover {
    background-color: #2c2c2c;
    color: #bb86fc;
}

/* Dark theme styling for share link modal */
#shareModal .modal-content {
    background-color: #1e1e1e;
    color: #e0e0e0;
    border: 1px solid #bb86fc;
}

#shareModal .modal-header {
    border-bottom: 1px solid #333;
}

#shareModal .modal-title {
    color: #bb86fc;
}

#shareModal .close {
    color: #e0e0e0;
    text-shadow: none;
}

#shareModal .close:hover {
    color: #bb86fc;
}
