:root {
    --primary: #6366f1;
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --bg-dark: #020617;
    /* Slate 950 */
    --card-bg: rgba(30, 41, 59, 0.4);
    /* Glass effect base */
    --card-border: rgba(255, 255, 255, 0.08);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --success: #10b981;
    --danger: #ef4444;
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.36);
    --backdrop-blur: blur(16px);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--bg-dark);
    /* Dynamic background */
    background-image:
        radial-gradient(circle at 15% 50%, rgba(99, 102, 241, 0.15) 0%, transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(168, 85, 247, 0.15) 0%, transparent 25%);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 2rem;
    overflow-x: hidden;
}

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

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Login Page Specifics */
body.login-page {
    align-items: center;
    background: radial-gradient(circle at center, #1e1b4b 0%, #020617 100%);
}

.login-container {
    width: 100%;
    max-width: 420px;
}

.login-card {
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: var(--backdrop-blur);
    -webkit-backdrop-filter: var(--backdrop-blur);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    padding: 3rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    position: relative;
    overflow: hidden;
}

/* Subtle gradient top border for cards */
.login-card::before,
.file-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.5), transparent);
}

.login-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.icon-circle.small {
    width: 56px;
    height: 56px;
    font-size: 1.5rem;
    margin: 0 auto 1.5rem;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2) 0%, rgba(168, 85, 247, 0.2) 100%);
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: #a5b4fc;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.2);
}

.login-header h2 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.input-group {
    position: relative;
    margin-bottom: 1.5rem;
}

.input-group input {
    width: 100%;
    background: rgba(2, 6, 23, 0.5);
    border: 1px solid var(--card-border);
    padding: 1rem 1rem 1rem 3rem;
    border-radius: 12px;
    color: white;
    font-size: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.input-group input:focus {
    outline: none;
    border-color: #818cf8;
    background: rgba(2, 6, 23, 0.8);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
}

.input-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    transition: color 0.3s;
}

.input-group input:focus+.input-icon {
    color: #818cf8;
}

.login-btn {
    width: 100%;
    padding: 1rem;
    background: var(--primary-gradient);
    border: none;
    border-radius: 12px;
    color: white;
    font-weight: 600;
    font-size: 1.05rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(99, 102, 241, 0.5);
    filter: brightness(1.1);
}

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

/* Main App Container */
.container {
    width: 100%;
    max-width: 1200px;
    /* Wider for dashboard feel */
}

header {
    text-align: center;
    margin-bottom: 3.5rem;
    animation: fadeInDown 0.8s ease;
}

header h1 {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #c7d2fe 0%, #6366f1 50%, #a855f7 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-flex;
    align-items: center;
    gap: 16px;
    letter-spacing: -0.03em;
    filter: drop-shadow(0 0 20px rgba(99, 102, 241, 0.3));
}

header p {
    color: var(--text-muted);
    font-size: 1.2rem;
    font-weight: 300;
}

/* Upload Area - Glassmorphism */
.upload-area {
    background: var(--card-bg);
    backdrop-filter: var(--backdrop-blur);
    -webkit-backdrop-filter: var(--backdrop-blur);
    border: 2px dashed rgba(99, 102, 241, 0.3);
    border-radius: 24px;
    padding: 4rem 2rem;
    text-align: center;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    margin-bottom: 4rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.upload-area:hover,
.upload-area.dragover {
    border-color: #a855f7;
    background: rgba(99, 102, 241, 0.1);
    transform: scale(1.01);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.upload-area .icon-circle {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(168, 85, 247, 0.1) 100%);
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    font-size: 2.5rem;
    color: #818cf8;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.1);
}

.upload-area:hover .icon-circle {
    transform: scale(1.15) rotate(5deg);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2) 0%, rgba(168, 85, 247, 0.2) 100%);
    box-shadow: 0 0 30px rgba(99, 102, 241, 0.3);
}

.upload-content h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: white;
}

.upload-content p {
    font-size: 1.1rem;
}

.browse-btn {
    color: #a5b4fc;
    font-weight: 600;
    text-decoration: none;
    border-bottom: 2px solid rgba(165, 180, 252, 0.3);
    padding-bottom: 2px;
    transition: all 0.2s;
}

.browse-btn:hover {
    color: #c7d2fe;
    border-color: #c7d2fe;
}

.limit-text {
    font-size: 0.9rem;
    margin-top: 1rem;
    opacity: 0.6;
}

.progress-container {
    display: none;
    margin-top: 2rem;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.progress-bar {
    background: rgba(255, 255, 255, 0.1);
    height: 6px;
    border-radius: 3px;
}

.progress-fill {
    height: 100%;
    background: var(--primary-gradient);
    border-radius: 3px;
    width: 0%;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.5);
}

/* Gallery Controls */
.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 0 0.5rem;
}

.gallery-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.gallery-actions {
    display: flex;
    gap: 1rem;
}

.search-bar {
    position: relative;
}

.search-bar input {
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 0.75rem 1rem 0.75rem 2.8rem;
    color: white;
    width: 240px;
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.search-bar input:focus {
    width: 300px;
    background: rgba(30, 41, 59, 0.9);
    border-color: #818cf8;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
    outline: none;
}

.search-bar i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.action-btn,
.refresh-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid var(--card-border);
    background: rgba(30, 41, 59, 0.6);
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-btn:hover,
.refresh-btn:hover,
.action-btn.active {
    background: rgba(99, 102, 241, 0.2);
    color: #818cf8;
    border-color: rgba(99, 102, 241, 0.4);
    transform: translateY(-2px);
}

.action-btn.danger {
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
}

.action-btn.danger:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
    color: #fff;
}

.action-btn.hidden {
    display: none;
}

/* File Grid */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 2rem;
    padding-bottom: 4rem;
}

.file-card {
    background: rgba(30, 41, 59, 0.4);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    cursor: pointer;
}

.file-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 255, 255, 0.1);
    background: rgba(30, 41, 59, 0.6);
}

.file-card.selected {
    border-color: #818cf8;
    box-shadow: 0 0 0 2px #818cf8, 0 20px 40px -10px rgba(99, 102, 241, 0.3);
    transform: translateY(-4px);
}

.file-card .check-overlay {
    background: var(--primary-gradient);
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    position: absolute;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.8rem;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.2s;
    z-index: 10;
}

.file-card.selected .check-overlay {
    opacity: 1;
    transform: scale(1);
}

.preview-container {
    height: 160px;
    background: #0f172a;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-bottom: 1px solid var(--border);
    /* Optional */
}

.preview-container img {
    height: 100%;
    width: 100%;
    object-fit: cover;
    opacity: 0.9;
    transition: all 0.5s ease;
}

.file-card:hover .preview-container img {
    transform: scale(1.1);
    opacity: 1;
}

.file-card.folder {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.9));
    border-left: 4px solid #818cf8;
}

.file-card.folder .preview-container {
    background: rgba(99, 102, 241, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-card.folder .file-icon {
    font-size: 3.5rem;
    color: #818cf8;
    filter: drop-shadow(0 0 10px rgba(99, 102, 241, 0.4));
    transition: transform 0.3s ease;
}

.file-card.folder:hover .file-icon {
    transform: scale(1.1);
}

.file-info {
    padding: 1.25rem;
}

.file-name {
    font-size: 0.95rem;
    font-weight: 500;
    margin-bottom: 0.35rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-date {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.copy-btn {
    background: rgba(99, 102, 241, 0.1);
    color: #a5b4fc;
    padding: 0.6rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    width: 100%;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.copy-btn:hover {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* Context Menu */
.context-menu {
    position: absolute;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 0.5rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    z-index: 100;
    min-width: 180px;
    display: none;
}

.context-menu-item {
    border-radius: 6px;
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    margin-bottom: 2px;
    color: #cbd5e1;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.2s;
}

.context-menu-item:hover {
    background: var(--primary-gradient);
    color: white;
}

.context-menu-item.danger {
    color: #fca5a5;
}

.context-menu-item.danger:hover {
    background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
    color: white;
}

/* Breadcrumbs */
.breadcrumbs {
    background: rgba(30, 41, 59, 0.4);
    padding: 0.75rem 1.25rem;
    border-radius: 12px;
    display: inline-flex;
    margin-bottom: 1.5rem;
    border: 1px solid var(--card-border);
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.breadcrumb-item {
    color: var(--text-muted);
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s;
}

.breadcrumb-item:hover {
    color: #818cf8;
    text-decoration: none;
}

.breadcrumb-separator {
    margin: 0 0.5rem;
    opacity: 0.5;
    color: var(--card-border);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backdrop-filter: blur(8px);
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal {
    background: #0f172a;
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 2rem;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
}

.modal h3 {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: white;
}

.modal input {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-main);
    /* Fallback */
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid var(--card-border);
    border-radius: 6px;
    color: var(--text-main);
    margin-bottom: 1.5rem;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

.btn-primary {
    background: var(--primary-gradient);
    box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.3);
    padding: 0.6rem 1.25rem;
    font-weight: 500;
    border: none;
    color: white;
    border-radius: 6px;
    cursor: pointer;
}

.btn-primary:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    color: #cbd5e1;
    padding: 0.6rem 1.25rem;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

/* Toasts */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    z-index: 1000;
}

.toast {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    color: white;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.3s ease;
    min-width: 300px;
}

.toast.success {
    border-left: 4px solid var(--success);
}

.toast.error {
    border-left: 4px solid var(--danger);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.file-card {
    animation: fadeIn 0.5s ease backwards;
}

/* Stagger animation for grid items would require JS or nth-child, keeping it simple for now */

/* Load spinner */
.loading-spinner {
    grid-column: 1 / -1;
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}