:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --bg-card: #ffffff;
    --text-primary: #1a1a1a;
    --text-secondary: #666666;
    --border-color: #e0e0e0;
    --accent-color: #4099de;
    --accent-hover: #2563eb;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --accent-color: #4099de;
    --accent-hover: #60a5fa;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: var(--transition);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
}

.header {
    background-color: var(--bg-card);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.header img.logo {
    max-height: 40px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

.file-count {
    margin-top: 9px;
    padding: 6px 0;
    font-size: 14px;
    color: var(--text-secondary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.view-controls {
    display: flex;
    gap: 8px;
    background-color: var(--bg-secondary);
    padding: 4px;
    border-radius: 8px;
}

.upload-btn-text {
    margin-left: 5px;
}

#uploadBtnContainer .view-btn:hover{
    background-color: var(--accent-hover);
    color: white;
}

.view-btn {
    background: transparent;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.view-btn:hover {
    background-color: var(--bg-card);
    color: var(--text-primary);
}

.view-btn.active {
    background-color: var(--accent-color);
    color: white;
}

.scroll-mode-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toggle-label {
    font-size: 14px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-color);
    transition: 0.3s;
    border-radius: 26px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--accent-color);
}

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

.theme-toggle {
    background-color: var(--bg-secondary);
    border: none;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-primary);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    background-color: var(--border-color);
}

.upload-btn {
    background-color: var(--accent-color);
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    color: white;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
}

.upload-btn:hover {
    background-color: var(--accent-hover);
}

.upload-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.upload-btn svg.spinning {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.sun-icon {
    display: block;
}

.moon-icon {
    display: none;
}

[data-theme="dark"] .sun-icon {
    display: none;
}

[data-theme="dark"] .moon-icon {
    display: block;
}

.main-content {
    min-height: 400px;
}

.file-grid {
    display: grid;
    gap: 20px;
    margin-bottom: 32px;
    transition: var(--transition);
}

.file-grid.card-view {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.file-grid.list-view {
    grid-template-columns: 1fr;
}

.file-card {
    background-color: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border-color);
    transition: var(--transition);
    cursor: pointer;
    animation: fadeIn 0.3s ease;
}

.file-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--accent-color);
}

.card-view .file-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.list-view .file-card {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 20px;
    text-align: left;
    min-width: 0;
}

.file-thumbnail {
    width: 100%;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    margin-bottom: 12px;
    flex-shrink: 0;
    background-size: cover, 36px 36px;
    background-position: center;
    background-repeat: no-repeat;
}

.list-view .file-thumbnail {
    margin-bottom: 0;
    width: 80px;
    height: 80px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.file-info {
    flex: 1;
    width: 100%;
}

.file-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    word-break: hidden;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
    display: block;
}

.list-view .file-name {
    max-width: 50%;
    min-width: 0;
}

.file-meta {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 5px;
    margin-top: 5px;
}

.file-meta svg {
    width: 18px;
    height: 18px;
}

.list-view .file-meta {
    justify-content: flex-start;
    gap: 20px;
}

.file-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.file-actions-inline {
    display: none;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.list-view .file-actions-inline {
    display: flex;
    gap: 10px;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 20px;
    background-color: var(--bg-card);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.pagination.hidden {
    display: none;
}

.pagination-btn {
    padding: 10px 20px;
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

.pagination-btn:hover:not(:disabled) {
    background-color: var(--accent-hover);
}

.pagination-btn:disabled {
    background-color: var(--border-color);
    color: var(--text-secondary);
    cursor: not-allowed;
    opacity: 0.5;
}

.page-numbers {
    display: flex;
    gap: 8px;
}

.page-number {
    padding: 8px 14px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
    color: var(--text-primary);
}

.page-number:hover {
    background-color: var(--border-color);
}

.page-number.active {
    background-color: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.loading-indicator {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.spinner {
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--accent-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

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

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        align-items: stretch;
    }

    .header-left,
    .header-right {
        justify-content: space-between;
        width: 100%;
    }

    .header h1 {
        font-size: 24px;
    }

    .file-grid.card-view {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 16px;
    }

    .pagination {
        flex-wrap: wrap;
    }

    .page-numbers {
        order: 3;
        width: 100%;
        justify-content: center;
        margin-top: 8px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 12px;
    }

    .header {
        padding: 16px;
    }

    .file-grid.card-view {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }

    .scroll-mode-toggle .toggle-label {
        font-size: 12px;
    }
}

.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: none;
}

.lightbox.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
}

.lightbox-content {
    position: relative;
    background: var(--bg-card);
    border-radius: 16px;
    max-width: 900px;
    width: 90%;
    max-height: 90vh;
    box-shadow: var(--shadow-lg);
    z-index: 1001;
    animation: slideUp 0.3s ease;
    display: flex;
    flex-direction: column;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.lightbox-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: var(--bg-secondary);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    color: var(--text-primary);
    transition: var(--transition);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-bottom: 4px;
}

.lightbox-close:hover {
    background: var(--accent-color);
    color: white;
}

.lightbox-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-secondary);
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    box-shadow: var(--shadow-md);
    cursor: pointer;
    transition: var(--transition);
    z-index: 10;
}

.lightbox-arrow svg {
    pointer-events: none;
}

.lightbox-arrow:hover {
    background: var(--accent-color);
    color: white;
}

.lightbox-arrow:disabled,
.lightbox-arrow[disabled] {
    opacity: 0.4;
    cursor: not-allowed;
}

.lightbox-arrow-prev {
    left: -60px;
}

.lightbox-arrow-next {
    right: -60px;
}

.lightbox-body {
    padding: 20px;
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.file-preview {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.file-preview h2 {
    color: var(--text-primary);
    font-size: 24px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 16px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
    display: block;
    padding-right: 40px;
    flex-shrink: 0;
}

.max-iframe-height,
.max-iframe-height figure,
.max-iframe-height iframe {
    max-height: 50vh !important;
}

.add-scroll {
    max-height: 60vh !important;
    height: auto !important;
    overflow-y: auto !important;
    scrollbar-width: thin;
}

.preview-info {
    margin-top: 10px;
}

.preview-info p {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
    display: block;
}

.preview-content {
    padding-top: 20px;
    flex: 1;
    overflow: hidden;
}

.preview-thumbnail {
    position: relative;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
    overflow: hidden;
    background: var(--bg-card);
    aspect-ratio: var(--media-aspect, 16 / 9);
    max-height: 60vh;
    flex-shrink: 0;
}

.preview-thumbnail::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.05);
    border-radius: inherit;
}

.preview-thumbnail iframe,
.preview-thumbnail embed,
.preview-thumbnail video {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
    object-fit: contain;
}

.image-placeholder, .video-placeholder {
    text-align: center;
    padding: 48px;
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-secondary) 100%);
    border-radius: 8px;
}

.image-icon, .video-icon {
    font-size: 72px;
    margin-bottom: 16px;
}

.image-desc, .video-desc {
    font-size: 18px;
    color: var(--text-primary);
    margin-bottom: 16px;
    font-weight: 500;
}

.image-details, .video-details {
    display: flex;
    gap: 24px;
    justify-content: center;
    flex-wrap: wrap;
    color: var(--text-secondary);
    font-size: 14px;
}

.spreadsheet-preview table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
}

.spreadsheet-preview th,
.spreadsheet-preview td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
    color: #1a1a1a;
}

.spreadsheet-preview th {
    background: #f5f5f5;
    font-weight: 600;
}

.spreadsheet-preview .positive {
    color: #22c55e;
    font-weight: 600;
}

.spreadsheet-preview .negative {
    color: #ef4444;
    font-weight: 600;
}

.archive-preview {
    color: var(--text-primary);
}

.archive-list {
    list-style: none;
    margin: 16px 0;
    padding: 0;
}

.archive-list li {
    padding: 8px 12px;
    background: var(--bg-card);
    margin-bottom: 8px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.archive-info {
    margin-top: 16px;
    font-style: italic;
    color: var(--text-secondary);
}

.text-preview pre {
    background: white;
    padding: 24px;
    border-radius: 8px;
    color: #1a1a1a;
    overflow-x: auto;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
}

.file-actions {
    margin-top: 20px;
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    width: 100%;
}

.action-btn {
    text-decoration: none;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 15px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
}

.action-btn:hover {
    background: var(--accent-hover);
    box-shadow: var(--shadow-md);
}

@media (max-width: 768px) {
    .lightbox-content {
        width: 95%;
        max-height: 95vh;
        max-width: 100%;
    }

    .lightbox-body {
        padding: 16px;
    }

    .lightbox-close {
        width: 44px;
        height: 44px;
        font-size: 32px;
        top: 12px;
        right: 12px;
    }

    .lightbox-arrow {
        width: 44px;
        height: 44px;
    }

    .lightbox-arrow svg {
        width: 18px;
        height: 18px;
    }

    .lightbox-arrow-prev {
        left: 8px;
    }

    .lightbox-arrow-next {
        right: 8px;
    }

    .file-preview h2 {
        font-size: 18px;
    }

    .preview-content {
        padding: 12px;
    }

    .preview-info {
        font-size: 14px;
    }

    .image-icon, .video-icon {
        font-size: 56px;
    }

    .file-actions {
        flex-direction: column;
        gap: 8px;
    }

    .action-btn {
        width: 100%;
        font-size: 14px;
        padding: 12px 16px;
    }
}

@media (max-width: 480px) {
    .lightbox-content {
        width: 100%;
        height: auto;
        max-height: 90vh;
        border-radius: 12px;
        margin: auto;
    }

    .lightbox-body {
        padding: 12px;
        max-height: 85vh;
    }

    .lightbox-close {
        width: 40px;
        height: 40px;
        font-size: 28px;
        top: 8px;
        right: 8px;
    }

    .lightbox-arrow {
        width: 40px;
        height: 40px;
    }

    .lightbox-arrow svg {
        width: 16px;
        height: 16px;
    }

    .lightbox-arrow-prev {
        left: 4px;
    }

    .lightbox-arrow-next {
        right: 4px;
    }

    .file-preview h2 {
        font-size: 16px;
        padding-right: 40px;
        padding-bottom: 12px;
    }

    .preview-content {
        padding: 8px;
    }

    .preview-thumbnail {
        max-height: 50vh !important;
        max-width: 90vw !important;
    }

    .max-iframe-height,
    .max-iframe-height figure,
    .max-iframe-height iframe {
        max-height: 50vh !important;
        height: auto !important;
    }

    .add-scroll {
        max-height: 50vh !important;
        height: auto !important;
        overflow-y: auto !important;
    }

    .preview-info {
        font-size: 13px;
    }

    .preview-info p {
        margin: 4px 0;
    }

    .file-actions {
        margin-top: 12px;
    }

    .action-btn {
        font-size: 13px;
        padding: 10px 14px;
    }

    .action-btn svg {
        width: 16px;
        height: 16px;
    }
}

.dropzone-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(64, 153, 222, 0.1);
    backdrop-filter: blur(4px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.dropzone-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.dropzone-content {
    background-color: var(--bg-card);
    border: 3px dashed var(--accent-color);
    border-radius: 12px;
    padding: 48px 64px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    color: var(--text-primary);
}

.dropzone-content svg {
    color: var(--accent-color);
    margin-bottom: 16px;
}

.dropzone-content p {
    font-size: 18px;
    font-weight: 500;
    margin: 0;
    color: var(--text-primary);
}
