:root {
    --bg-color: #f2f2f7;
    --glass-bg: rgba(255, 255, 255, 0.65);
    --glass-border: rgba(255, 255, 255, 0.4);
    --primary-color: #007aff;
    --text-color: #1d1d1f;
    --text-secondary: #86868b;
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(at 0% 0%, hsla(253,16%,7%,1) 0, transparent 50%), 
        radial-gradient(at 50% 0%, hsla(225,39%,30%,1) 0, transparent 50%), 
        radial-gradient(at 100% 0%, hsla(339,49%,30%,1) 0, transparent 50%);
    background-image: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    color: var(--text-color);
    margin: 0;
    height: 100vh;
    display: flex;
    overflow: hidden;
}

/* Glassmorphism Classes */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
}

.sidebar {
    width: 260px;
    height: 96vh;
    margin: 2vh;
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-sizing: border-box;
}

.main-content {
    flex: 1;
    height: 96vh;
    margin: 2vh 2vh 2vh 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.nav-item {
    padding: 12px 16px;
    margin-bottom: 8px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-color);
    text-decoration: none;
    font-weight: 500;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.5);
    transform: translateX(4px);
}

.nav-item.active {
    background: rgba(255, 255, 255, 0.8);
    box-shadow: var(--shadow-sm);
}

.content-page {
    display: none;
    height: 100%;
    padding: 20px;
    box-sizing: border-box;
    overflow-y: auto;
}

.content-page.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Forms and Inputs */
input, select, textarea {
    width: 100%;
    padding: 10px;
    margin: 8px 0;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.8);
    box-sizing: border-box;
    font-size: 14px;
}

input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: #fff;
}

button {
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    background: var(--primary-color);
    color: white;
    font-weight: 600;
    transition: transform 0.1s;
}

button:active {
    transform: scale(0.98);
}

button.secondary {
    background: rgba(0,0,0,0.1);
    color: var(--text-color);
}

button.danger {
    background: #ff3b30;
    color: white;
}

/* Login Page specific */
.login-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    width: 100%;
}

.login-box {
    width: 380px;
    padding: 40px;
    text-align: center;
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(4px);
    z-index: 100;
    justify-content: center;
    align-items: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    width: 500px;
    padding: 30px;
    background: rgba(255, 255, 255, 0.9);
}

/* Log View */
.log-viewer {
    font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
    font-size: 13px;
    white-space: pre-wrap;
    background: rgba(0, 0, 0, 0.8);
    color: #00ff00;
    padding: 20px;
    border-radius: 12px;
    border-radius: 12px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

th, td {
    text-align: left;
    padding: 12px;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

tr:hover {
    background: rgba(255,255,255,0.4);
}

/* --- File Explorer Styles --- */

/* Toolbar */
.toolbar {
    padding: 5px 0;
}

.icon-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: transparent;
    color: var(--text-color);
    border: 1px solid transparent;
    border-radius: 8px;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: rgba(0,0,0,0.05);
}

.icon-btn.active {
    background: rgba(0,0,0,0.1);
    color: var(--primary-color);
}

.btn-group {
    display: flex;
    background: rgba(0,0,0,0.05);
    padding: 2px;
    border-radius: 10px;
}

.btn-group .icon-btn {
    width: 32px;
    height: 32px;
}

/* Breadcrumbs */
.breadcrumbs {
    display: flex;
    align-items: center;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 20px;
    padding: 8px 12px;
    background: rgba(255,255,255,0.4);
    border-radius: 8px;
}

.crumb {
    cursor: pointer;
    color: var(--primary-color);
    font-weight: 500;
}

.crumb:hover {
    text-decoration: underline;
}

.crumb-separator {
    margin: 0 8px;
    color: var(--text-secondary);
}

.crumb.current {
    color: var(--text-secondary);
    cursor: default;
    font-weight: normal;
    text-decoration: none;
}

/* File List Container */
#file-list-container {
    flex: 1;
    overflow-y: auto;
    padding: 0; /* padding handling in child or default */
    position: relative;
    border: 2px solid transparent; /* Prepare for drag border */
    transition: border-color 0.2s, background-color 0.2s;
}

#file-list-container.drag-over {
    border-color: var(--primary-color);
    background-color: rgba(0, 122, 255, 0.05);
}

/* List View Mode */
.list-view table {
    width: 100%;
}

.list-view th {
    position: sticky;
    top: 0;
    background: rgba(255,255,255,0.9);
    backdrop-filter: blur(4px);
    z-index: 10;
}

.file-row {
    cursor: pointer;
    user-select: none; /* Prevent text selection on double click */
}

.file-row.selected {
    background: rgba(0, 122, 255, 0.1); /* Primary color with opacity */
}
.file-row.selected:hover {
    background: rgba(0, 122, 255, 0.2);
}

.file-row td {
    vertical-align: middle;
}

.file-icon {
    font-size: 20px;
    margin-right: 10px;
    vertical-align: middle;
}

/* Grid View Mode */
.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 15px;
    padding: 10px;
}

.file-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px 10px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.file-card:hover {
    background: rgba(255,255,255,0.6);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.file-card.selected {
    background: rgba(0, 122, 255, 0.1);
    border: 1px solid var(--primary-color);
}

.file-card-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 40px;
}

.file-card-name {
    font-size: 13px;
    word-break: break-word;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    max-width: 100%;
}

/* Context Menu */
.context-menu {
    display: none;
    position: absolute;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0,0,0,0.1);
    box-shadow: var(--shadow-md);
    border-radius: 10px;
    z-index: 1000;
    width: 160px;
    overflow: hidden;
    padding: 5px;
}

.menu-item {
    padding: 8px 12px;
    font-size: 14px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.1s;
}

.menu-item:hover {
    background: var(--primary-color);
    color: white;
}

.menu-item.delete:hover {
    background: #ff3b30;
}

/* Upload Progress Panel */
.upload-progress-panel {
    display: none; /* hidden by default */
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 320px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0,0,0,0.1);
    box-shadow: var(--shadow-md);
    border-radius: 12px;
    padding: 15px;
    z-index: 2000;
}

.upload-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 500;
}

.progress-track {
    width: 100%;
    height: 6px;
    background: rgba(0,0,0,0.1);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color);
    width: 0%;
    transition: width 0.1s linear;
}

/* Toast Notification (Keep for simple messages) */
.toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
}

.toast {
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 14px;
    margin-bottom: 10px;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.toast.show {
    opacity: 1;
}

/* Loading Overlay (New Popup Style) */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    z-index: 20000;
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.loading-overlay.active {
    display: flex;
}

.loading-content {
    background: white;
    padding: 30px 50px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

/* Spinner for overlay */
.spinner-large {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --- Mobile / Responsive Design --- */
@media (max-width: 768px) {
    /* Layout Adjustments */
    body {
        flex-direction: column;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        height: 100vh;
        width: 280px;
        margin: 0;
        z-index: 2000;
        transform: translateX(-110%);
        transition: transform 0.3s ease-in-out;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(20px);
        box-shadow: 2px 0 20px rgba(0,0,0,0.2);
        overflow-y: auto;
    }

    .sidebar.show {
        transform: translateX(0);
    }

    /* Mobile Header */
    .mobile-header {
        display: flex !important;
        align-items: center;
        padding: 10px 15px;
        background: rgba(255, 255, 255, 0.85);
        backdrop-filter: blur(10px);
        border-bottom: 1px solid rgba(0,0,0,0.1);
        z-index: 1000;
        height: 50px;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
    }

    .mobile-menu-btn {
        background: none;
        border: none;
        padding: 5px;
        margin-right: 15px;
        color: var(--text-color);
        cursor: pointer;
        display: flex;
        align-items: center;
    }

    /* Main Content */
    .main-content {
        margin: 50px 0 0 0; /* Top margin for header */
        height: calc(100vh - 50px);
        width: 100%;
        border-radius: 0;
    }

    .content-page {
        padding: 10px;
    }

    .glass-panel {
        border-radius: 0;
        border: none;
        background: rgba(255, 255, 255, 0.6);
        box-shadow: none;
    }
    
    /* Pages specific fix */
    #page-logs .glass-panel {
        padding: 10px !important;
    }

    .log-viewer {
        font-size: 11px;
        padding: 10px;
    }

    /* Modals */
    .modal-content {
        width: 90%;
        max-height: 90vh;
        overflow-y: auto;
        padding: 20px;
        margin: 20px;
    }

    /* Login Page */
    .login-box {
        width: 90%;
        max-width: 380px;
        padding: 30px 20px;
    }

    /* Tables */
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    /* Toolbar adjustments for File Manager */
    .toolbar {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .search-box {
        width: 100% !important;
        margin-top: 5px;
        order: 10;
    }
    
    .breadcrumbs {
        white-space: nowrap;
        overflow-x: auto;
        padding-bottom: 5px; /* for scrollbar */
    }

    /* File List */
    .file-row td {
        padding: 10px 5px;
    }
    
    .list-view th:nth-child(3),
    .list-view td:nth-child(3), /* Size */
    .list-view th:nth-child(4),
    .list-view td:nth-child(4) { /* Date */
        display: none; /* Hide Size and Date on very small screens if needed, or keeping them and scrolling is fine */
    }
    
    /* Actually keeping them with scroll is better usually, let's override the 'display:none' if user prefers scrolling */
    .list-view th:nth-child(3),
    .list-view td:nth-child(3),
    .list-view th:nth-child(4),
    .list-view td:nth-child(4) {
        display: table-cell; 
    }
}

/* Default state for mobile header */
.mobile-header {
    display: none;
}

/* Overlay for sidebar */
.sidebar-overlay {
    position: fixed;
    top: 0; 
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1500;
    display: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.sidebar-overlay.show {
    display: block;
    opacity: 1;
}
