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

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --bg: #0f1117;
    --card: #1a1d29;
    --border: #2a2e3f;
    --text: #e5e7eb;
    --text-muted: #9ca3af;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

/* Login Page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.login-box {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 48px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.4);
}

.login-box h1 {
    font-size: 32px;
    margin-bottom: 8px;
    text-align: center;
    color: var(--text);
}

.subtitle {
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 32px;
    font-size: 14px;
}

.login-hint {
    text-align: center;
    margin-top: 20px;
    font-size: 12px;
    color: var(--text-muted);
}

/* Dashboard Layout */
#dashboardPage {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 100;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text);
}

.sidebar-nav {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 10px;
    margin-bottom: 6px;
    transition: all 0.2s ease;
    cursor: pointer;
    font-size: 15px;
}

.nav-item:hover {
    background: rgba(99, 102, 241, 0.1);
    color: var(--text);
}

.nav-item.active {
    background: var(--primary);
    color: white;
}

.nav-item.admin-only {
    display: none;
}

.nav-item.admin-only.visible {
    display: flex;
}

.icon {
    font-size: 18px;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    padding: 8px;
    background: var(--bg);
    border-radius: 8px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.user-name {
    font-weight: 500;
    font-size: 14px;
    color: var(--text);
}

.user-role {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.main-content {
    margin-left: 260px;
    flex: 1;
    padding: 40px;
    min-height: 100vh;
}

.page-header {
    margin-bottom: 32px;
}

.page-header h1 {
    font-size: 36px;
    margin-bottom: 8px;
    color: var(--text);
}

.content-view {
    animation: fadeIn 0.3s ease;
}

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

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px;
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.2);
}

.stat-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.stat-value {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text);
}

.stat-label {
    color: var(--text-muted);
    font-size: 14px;
}

/* Card */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px;
    margin-bottom: 24px;
}

.card h3 {
    margin-bottom: 20px;
    font-size: 20px;
    color: var(--text);
}

/* Forms */
.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}

input[type="text"],
input[type="password"],
input[type="email"],
select,
textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
}

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

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

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

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

.btn-danger:hover {
    background: #dc2626;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

.btn-block {
    width: 100%;
    display: flex;
}

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

/* Files Layout */
.files-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 24px;
}

.directory-sidebar .card {
    padding: 16px;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    width: 100%;
    margin-bottom: 4px;
}

.sidebar-item:hover {
    background: var(--bg);
    color: var(--text);
}

.sidebar-item.active {
    background: var(--primary);
    color: white;
}

.search-box {
    margin-bottom: 20px;
}

.search-box input {
    width: 100%;
}

/* Table */
.table-container {
    overflow-x: auto;
}

.files-table {
    width: 100%;
    border-collapse: collapse;
}

.files-table thead tr {
    border-bottom: 1px solid var(--border);
}

.files-table th {
    text-align: left;
    padding: 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.files-table td {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    color: var(--text);
}

.files-table tbody tr {
    transition: background 0.2s;
}

.files-table tbody tr:hover {
    background: var(--bg);
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.loading {
    color: var(--text-muted);
    padding: 40px 16px !important;
}

.file-name {
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.file-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.action-btn {
    padding: 6px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 12px;
}

.action-btn:hover {
    color: var(--text);
    border-color: var(--primary);
}

.action-btn.danger:hover {
    color: var(--danger);
    border-color: var(--danger);
}

/* Upload Area */
.upload-card {
    max-width: 600px;
    margin: 0 auto;
}

.upload-area {
    border: 2px dashed var(--border);
    border-radius: 16px;
    padding: 60px 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    margin-bottom: 24px;
}

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

.upload-area.dragging {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
    transform: scale(1.02);
}

.upload-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.upload-area p {
    margin: 8px 0;
    color: var(--text);
}

.upload-hint {
    font-size: 12px;
    color: var(--text-muted) !important;
    margin-top: 12px !important;
}

.file-preview-info {
    background: var(--bg);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    text-align: center;
    color: var(--text);
}

.file-preview-info strong {
    display: block;
    margin-bottom: 8px;
    color: var(--text-muted);
}

.progress-bar {
    height: 8px;
    background: var(--bg);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 16px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-dark));
    width: 0%;
    transition: width 0.3s;
}

.success-box {
    text-align: center;
}

.success-message {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 20px;
    color: var(--success);
}

.uploaded-url {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.uploaded-url input {
    flex: 1;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.error-message {
    color: var(--danger);
    font-size: 14px;
    margin-top: 16px;
    text-align: center;
    padding: 12px;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 8px;
    display: none;
}

.error-message.show {
    display: block;
}

/* Recent Files */
.recent-files-list {
    display: grid;
    gap: 12px;
}

.recent-file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: var(--bg);
    border-radius: 10px;
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.recent-file-item:hover {
    border-color: var(--primary);
    transform: translateX(4px);
}

.recent-file-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.recent-file-icon {
    font-size: 24px;
}

.recent-file-name {
    font-weight: 500;
    font-size: 14px;
    color: var(--text);
}

.recent-file-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--card);
    color: var(--text);
    padding: 16px 24px;
    border-radius: 10px;
    border: 1px solid var(--border);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s;
    z-index: 1000;
    min-width: 300px;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

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

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

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

.modal-content {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

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

.modal-header h2 {
    margin: 0;
    font-size: 20px;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--border);
    color: var(--text);
}

.modal-content form {
    padding: 24px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.modal-actions button {
    flex: 1;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 200px;
    }
    
    .main-content {
        margin-left: 200px;
        padding: 20px;
    }
    
    .files-layout {
        grid-template-columns: 1fr;
    }
    
    .directory-sidebar {
        display: none;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .login-box {
        padding: 32px 24px;
    }
    
    .page-header h1 {
        font-size: 28px;
    }
    
    .modal-content {
        width: 95%;
    }
}