/* Modern Design System */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg-main: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.7);
    --bg-input: rgba(15, 23, 42, 0.6);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.1);
    --error: #ef4444;
    --success: #10b981;
    --glass-blur: blur(12px);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
    --breadcrumb-bg: rgba(30, 41, 59, 0.4);
    --drop-area-bg: rgba(15, 23, 42, 0.3);
    --file-item-bg: rgba(30, 41, 59, 0.5);
    --modal-bg: rgba(15, 23, 42, 0.95);
    --modal-header-bg: rgba(30, 41, 59, 0.5);
    --folder-bg: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(168, 85, 247, 0.1) 100%);
    --nav-btn-bg: rgba(255, 255, 255, 0.1);
    --nav-btn-color: white;
    --scrollbar-thumb: #334155;
    --scrollbar-thumb-hover: #475569;
    --media-overlay: linear-gradient(to top, rgba(15, 23, 42, 0.9), transparent);
    --body-gradient-1: rgba(99, 102, 241, 0.15);
    --body-gradient-2: rgba(99, 102, 241, 0.1);
}

[data-theme="light"] {
    --bg-main: #f1f5f9;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-input: rgba(248, 250, 252, 0.95);
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: rgba(0, 0, 0, 0.08);
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    --breadcrumb-bg: rgba(255, 255, 255, 0.7);
    --drop-area-bg: rgba(255, 255, 255, 0.5);
    --file-item-bg: rgba(241, 245, 249, 0.8);
    --modal-bg: rgba(241, 245, 249, 0.97);
    --modal-header-bg: rgba(255, 255, 255, 0.8);
    --folder-bg: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(168, 85, 247, 0.08) 100%);
    --nav-btn-bg: rgba(0, 0, 0, 0.08);
    --nav-btn-color: #0f172a;
    --scrollbar-thumb: #cbd5e1;
    --scrollbar-thumb-hover: #94a3b8;
    --media-overlay: linear-gradient(to top, rgba(15, 23, 42, 0.75), transparent);
    --body-gradient-1: rgba(99, 102, 241, 0.08);
    --body-gradient-2: rgba(99, 102, 241, 0.05);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-main);
    background-image:
        radial-gradient(at 0% 0%, var(--body-gradient-1) 0px, transparent 50%),
        radial-gradient(at 100% 100%, var(--body-gradient-2) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

h1, h2, h3 {
    font-weight: 700;
    letter-spacing: -0.025em;
    margin-bottom: 1rem;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-main);
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

/* Button Styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    transition: var(--transition);
    text-decoration: none;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
}

.btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.4);
}

.btn:active {
    transform: translateY(0);
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    border-radius: 0.5rem;
}

/* Form Styles */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-muted);
}

input[type="text"], 
input[type="password"] {
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    color: var(--text-main);
    font-size: 1rem;
    transition: var(--transition);
    backdrop-filter: var(--glass-blur);
}

input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
}

/* Login Page */
.login-form {
    max-width: 440px;
    margin: 10vh auto;
    padding: 3rem;
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border);
    border-radius: 1.5rem;
    box-shadow: var(--shadow);
    text-align: center;
    animation: fadeIn 0.6s ease-out;
}

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

.login-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.login-header img {
    width: 64px;
    height: 64px;
    filter: drop-shadow(0 0 10px rgba(99, 102, 241, 0.5));
}

.login-form h1 {
    font-size: 2rem;
    background: linear-gradient(to right, #818cf8, #c084fc);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-form p {
    color: var(--text-muted);
    margin-bottom: 2.5rem;
}

/* Gallery Page Header */
.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
    padding: 0 2rem;
    height: 80px; /* Precise height for alignment */
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border);
    border-radius: 1.25rem;
    box-shadow: var(--shadow);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    height: 100%;
}

.logo {
    height: 48px; /* Restored size for better visibility */
    width: auto;
    filter: drop-shadow(0 0 10px rgba(99, 102, 241, 0.4));
    display: block;
}

.gallery-header h1 {
    margin: 0;
    font-size: 1.75rem;
    line-height: 1;
    background: linear-gradient(to right, #818cf8, #c084fc);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 700;
}

.header-actions {
    display: flex;
    align-items: center;
    height: 100%;
}

.header-actions .btn {
    margin: 0;
}

.error-message {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--error);
    padding: 1rem 1.5rem;
    margin-bottom: 2rem;
    border-radius: 0.75rem;
    border: 1px solid rgba(239, 68, 68, 0.2);
    display: flex;
    align-items: center;
}

/* Breadcrumb Styles */
.current-path {
    margin-bottom: 2rem;
}

.breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--breadcrumb-bg);
    border-radius: 0.75rem;
    border: 1px solid var(--border);
}

.breadcrumb-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
}

.breadcrumb-link:hover {
    color: var(--primary);
}

.breadcrumb-separator {
    color: rgba(255, 255, 255, 0.2);
}

/* Gallery Controls */
.gallery-controls {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.upload-section, .create-dir-section {
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    padding: 1.5rem;
    border-radius: 1.25rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.upload-section h3, .create-dir-section h3 {
    font-size: 1.1rem;
    color: var(--text-main);
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Gallery Grid */
.gallery-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.5rem;
}

.gallery-item {
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    border-radius: 1rem;
    border: 1px solid var(--border);
    overflow: hidden;
    transition: var(--transition);
    position: relative;
    aspect-ratio: 1/1;
    cursor: pointer;
}

.gallery-item:hover {
    transform: scale(1.02);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.4);
    border-color: rgba(99, 102, 241, 0.4);
}

.item-actions {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    opacity: 0;
    transform: translateY(-10px);
    transition: var(--transition);
    z-index: 20;
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.gallery-item:hover .item-actions {
    opacity: 1;
    transform: translateY(0);
}

.delete-btn {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(4px);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.5rem;
    color: #ef4444;
    cursor: pointer;
    transition: var(--transition);
}

.delete-btn:hover {
    background: #ef4444;
    color: white;
}

.rename-btn, .move-btn {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(4px);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.5rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    margin-right: 0.25rem;
}

.rename-btn:hover {
    background: #3b82f6;
    color: white;
}

.move-btn:hover {
    background: #8b5cf6;
    color: white;
}

.item-actions form {
    display: inline;
}

.folder, .media-item {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: var(--text-main);
    height: 100%;
    position: relative;
}

.folder {
    justify-content: center;
    align-items: center;
    background: var(--folder-bg);
}

.folder-icon {
    font-size: 4rem;
    margin-bottom: 0.5rem;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.2));
}

.media-preview {
    width: 100%;
    height: 100%;
    position: relative;
}

.image-preview, .thumbnail-bg {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    transition: transform 0.5s ease;
}

.gallery-item:hover .image-preview,
.gallery-item:hover .thumbnail-bg {
    transform: scale(1.1);
}

.media-item span, .folder span {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1.5rem 0.75rem 0.5rem;
    background: var(--media-overlay);
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}

/* Drop Area */
.drop-area {
    border: 2px dashed rgba(99, 102, 241, 0.3);
    border-radius: 1rem;
    padding: 2rem;
    text-align: center;
    transition: var(--transition);
    background: var(--drop-area-bg);
}

.drop-area.highlight {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.drop-area p {
    color: var(--text-muted);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.file-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.file-item {
    background: var(--file-item-bg);
    border-radius: 0.5rem;
    padding: 0.25rem;
    border: 1px solid var(--border);
    font-size: 0.7rem;
}

.file-preview {
    width: 100%;
    aspect-ratio: 1/1;
    object-fit: cover;
    border-radius: 0.25rem;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: var(--modal-bg);
    backdrop-filter: blur(8px);
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1.5rem;
    width: 92%;
    max-width: 1200px;
    height: 85vh;
    margin: auto;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.modal-header {
    background: var(--modal-header-bg);
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.1rem;
}

.close {
    font-size: 1.75rem;
    font-weight: 300;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    line-height: 1;
}

.close:hover {
    color: var(--error);
}

.close-rename, .close-move {
    font-size: 1.75rem;
    font-weight: 300;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    line-height: 1;
}

.close-rename:hover, .close-move:hover {
    color: var(--error);
}

.modal-body {
    padding: 0;
    height: calc(100% - 65px);
    background: black;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

#modal-image, #modal-video {
    max-height: 100%;
    max-width: calc(100% - 128px);
    object-fit: contain;
}

.nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: var(--nav-btn-bg);
    backdrop-filter: blur(4px);
    color: var(--nav-btn-color);
    width: 48px;
    height: 48px;
    border: 1px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
    opacity: 0.7;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.prev-btn { left: 1rem; }
.next-btn { right: 1rem; }

.nav-btn:hover {
    opacity: 1;
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Responsive */
@media (max-width: 1024px) {
    .gallery-controls {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    .gallery-header {
        flex-direction: column;
        gap: 1.5rem;
        text-align: center;
        padding: 1.5rem;
    }
    
    .gallery-items {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 1rem;
    }
    
    .login-form {
        margin: 5vh 1rem;
        padding: 2rem;
    }

    .nav-btn {
        width: 44px;
        height: 44px;
        font-size: 1.25rem;
    }
}

@media (max-width: 480px) {
    .gallery-items {
        grid-template-columns: 1fr 1fr;
    }
}

/* Video Overlay Improvements */
.video-overlay {
    background: rgba(15, 23, 42, 0.4);
}

.play-overlay {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(4px);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.gallery-item:hover .play-overlay {
    background: rgba(255, 255, 255, 0.25);
    border-color: white;
    transform: scale(1.1);
}

/* Theme Toggle Button */
.theme-toggle {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    transition: var(--transition);
    flex-shrink: 0;
}

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

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
    display: none;
}

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

:root:not([data-theme="light"]) .theme-toggle .icon-sun {
    display: block;
}