:root {
    --bg-color: #111827;
    --card-bg: #1f2937;
    --text-color: #f9fafb;
    --text-secondary: #9ca3af;
    --primary-color: #60a5fa;
    --primary-hover: #3b82f6;
    --border-color: #374151;
    --danger-color: #ef4444;
    --modal-bg: rgba(0, 0, 0, 0.9);
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1200px;
    /* Wider for better file view */
    margin: 0 auto;
    padding: 20px;
    width: 100%;
    box-sizing: border-box;
}

/* Screens */
.screen {
    width: 100%;
    height: 100%;
    overflow-y: auto;
}

.screen.hidden {
    display: none !important;
}

/* Login */
#login-screen {
    display: flex;
    justify-content: center;
    align-items: center;
}

.login-card {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background: var(--bg-color);
    color: var(--text-color);
    box-sizing: border-box;
}

.full-width {
    width: 100%;
}

.error-msg {
    color: var(--danger-color);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

/* Header & Toolbar */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.toolbar {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
    gap: 1rem;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    gap: 0.5rem;
}

.path-breadcrumb {
    color: var(--text-secondary);
    font-family: monospace;
    background: var(--card-bg);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    margin-left: 1rem;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn.primary {
    background-color: var(--primary-color);
    color: white;
}

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

.btn.secondary {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
}

.btn.secondary:hover {
    background-color: var(--border-color);
}

.btn.danger {
    background-color: transparent;
    color: var(--danger-color);
}

.btn.danger:hover {
    background-color: rgba(239, 68, 68, 0.1);
}

.btn.hidden {
    display: none;
}

.btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

/* File List */
.files-section {
    background-color: var(--card-bg);
    border-radius: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border-color);
}

.file-list-header,
.file-item {
    display: grid;
    grid-template-columns: 40px 40px 1fr 100px 180px 100px;
    /* Checkbox, Icon, Name, Size, Date, Actions */
    padding: 0.75rem 1rem;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.file-list-header {
    font-weight: 600;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.02);
}

.file-item:last-child {
    border-bottom: none;
}

.file-item:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

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

.file-name {
    display: flex;
    align-items: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

.file-name.is-folder {
    font-weight: 500;
    color: var(--text-color);
}

.file-name:hover {
    color: var(--primary-color);
}

.file-icon {
    font-size: 1.2rem;
    margin-right: 0.5rem;
}

/* Upload */
.upload-area {
    background-color: var(--card-bg);
    border: 2px dashed var(--border-color);
    border-radius: 1rem;
    padding: 2rem;
    text-align: center;
    margin-bottom: 1rem;
    transition: all 0.3s;
}

.upload-area.dragover {
    border-color: var(--primary-color);
    background-color: rgba(59, 130, 246, 0.05);
    transform: scale(1.02);
}

/* Progress Bar */
#progress-container {
    width: 100%;
    background-color: var(--card-bg);
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
    position: relative;
    height: 1.5rem;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

#progress-bar {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background-color: var(--primary-color);
    width: 0%;
    transition: width 0.2s;
}

#progress-text {
    position: relative;
    z-index: 1;
    font-size: 0.8rem;
    font-weight: 600;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--modal-bg);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 1rem;
    max-width: 90%;
    max-height: 90%;
    overflow: auto;
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.close-modal {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    color: var(--text-secondary);
}

#media-container img,
#media-container video {
    max-width: 100%;
    max-height: 80vh;
    border-radius: 0.5rem;
}

#zip-list {
    list-style: none;
    padding: 0;
}

#zip-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

/* Responsive */
@media (max-width: 768px) {

    .file-list-header,
    .file-item {
        grid-template-columns: 40px 40px 1fr 80px;
    }

    .col-date,
    .file-date,
    .col-actions,
    .file-actions {
        display: none;
    }

    /* Simplify on mobile for now */
}

/* Grid View */
.files-section.grid-view .file-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
    padding: 1rem;
}

.files-section.grid-view .file-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    text-align: center;
    position: relative;
    grid-template-columns: 1fr;
    /* Reset grid layout from list view */
}

.files-section.grid-view .file-list-header {
    display: none;
    /* Hide header in grid view */
}

.files-section.grid-view .col-select {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
}

.files-section.grid-view .col-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.files-section.grid-view .file-name {
    width: 100%;
    margin-bottom: 0.5rem;
    justify-content: center;
}

.files-section.grid-view .col-size,
.files-section.grid-view .col-date {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: block;
    /* Show in grid */
}

.files-section.grid-view .col-actions {
    margin-top: 0.5rem;
    display: block;
}

/* Modal Improvements */
.modal-content {
    position: relative;
    /* Context for sticky */
}

.close-modal {
    position: sticky;
    top: 0;
    right: 0;
    float: right;
    /* Fallback */
    background: var(--card-bg);
    /* Opaque background behind X */
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 10;
    margin-bottom: 1rem;
    margin-top: -1rem;
    /* Adjust for padding */
    margin-right: -1rem;
}