/* Modern CSS Reset */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* CSS Custom Properties */
:root {
    /* Colors */
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --secondary-color: #6b7280;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    
    /* Backgrounds */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-accent: #f1f5f9;
    --bg-dark: #1e293b;
    
    /* Text Colors */
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    
    /* Border & Shadow */
    --border-color: #e2e8f0;
    --border-radius: 8px;
    --border-radius-lg: 12px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    
    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    
    /* Layout */
    --sidebar-width: 240px;
    --header-height: 64px;
    --max-width: 1200px;
}

/* Base Styles */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

/* Login Page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: var(--space-lg);
}

.login-container {
    background: var(--bg-primary);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--space-2xl);
    width: 100%;
    max-width: 420px;
}

.login-header {
    text-align: center;
    margin-bottom: var(--space-xl);
}

.login-header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.login-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.input-group label {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.input-group input {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: all 0.2s ease;
    background: var(--bg-primary);
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgb(59 130 246 / 0.1);
}

.btn-login {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.btn-login:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-login:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* App Layout - CSS Grid */
.app-layout {
    display: grid;
    grid-template-areas: 
        "header header"
        "sidebar main";
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-rows: var(--header-height) 1fr;
    min-height: 100vh;
    background: var(--bg-secondary);
}

/* App Header */
.app-header {
    grid-area: header;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-lg);
    box-shadow: var(--shadow-sm);
}

.header-brand h1 {
    font-size: 1.375rem;
    font-weight: 600;
    color: var(--text-primary);
}

.header-user {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
}

.user-info {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.btn-logout {
    background: var(--error-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    padding: var(--space-sm) var(--space-md);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

/* App Sidebar */
.app-sidebar {
    grid-area: sidebar;
    background: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    padding: var(--space-lg);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: transparent;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    width: 100%;
    color: var(--text-secondary);
}

.nav-btn:hover {
    background: var(--bg-accent);
    color: var(--text-primary);
}

.nav-btn.active {
    background: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-sm);
}

.nav-icon {
    font-size: 1.25rem;
}

.nav-label {
    font-weight: 500;
    font-size: 0.875rem;
}

/* App Main */
.app-main {
    grid-area: main;
    padding: var(--space-xl);
    overflow-y: auto;
    max-width: var(--max-width);
    margin: 0 auto;
    width: 100%;
}

/* Views */
.view {
    display: none;
}

.view.active {
    display: block;
}

.view-header {
    margin-bottom: var(--space-xl);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: var(--space-lg);
}

.view-header h2 {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

.view-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.view-actions {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

/* Upload Area */
.upload-container {
    background: var(--bg-primary);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    padding: var(--space-2xl);
}

.upload-area {
    margin-bottom: var(--space-xl);
}

.drop-zone {
    position: relative;
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: var(--space-2xl);
    text-align: center;
    transition: all 0.2s ease;
    cursor: pointer;
    margin-bottom: var(--space-lg);
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--primary-color);
    background: rgb(59 130 246 / 0.02);
}

.drop-zone input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.drop-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
}

.upload-icon {
    font-size: 3rem;
    opacity: 0.7;
}

.drop-zone-content h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.drop-zone-content p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.file-preview {
    margin-top: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-accent);
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.btn-upload {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    padding: 0.875rem 2rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

.btn-upload:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-upload:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Upload Success */
.upload-success {
    text-align: center;
}

.success-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-lg);
}

.success-icon {
    font-size: 4rem;
}

.success-content h3 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--success-color);
}

.file-result {
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.result-item {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    text-align: left;
}

.result-item label {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.result-item span {
    color: var(--text-primary);
    word-break: break-all;
}

.url-copy {
    display: flex;
    gap: var(--space-sm);
}

.url-copy input {
    flex: 1;
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-secondary);
    font-family: monospace;
    font-size: 0.875rem;
}

.btn-copy {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    padding: var(--space-sm) var(--space-md);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.success-actions {
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
    justify-content: center;
}

/* File List */
.files-container {
    background: var(--bg-primary);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    padding: var(--space-xl);
    min-height: 400px;
}

.file-item {
    display: flex;
    align-items: center;
    padding: var(--space-lg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    margin-bottom: var(--space-md);
    transition: all 0.2s ease;
    background: var(--bg-primary);
}

.file-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.file-icon {
    font-size: 1.5rem;
    margin-right: var(--space-lg);
    min-width: 40px;
    text-align: center;
}

.file-info {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-meta {
    display: flex;
    gap: var(--space-lg);
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.file-actions {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

/* Loading State */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-2xl);
    text-align: center;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: var(--space-md);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border: 1px solid transparent;
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

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

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

.btn-secondary {
    background: var(--bg-accent);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--secondary-color);
    color: white;
}

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

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

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

/* Controls */
.select-control {
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
}

.select-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgb(59 130 246 / 0.1);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-lg);
    padding: var(--space-xl) 0;
}

.page-info {
    color: var(--text-secondary);
    font-weight: 500;
    min-width: 100px;
    text-align: center;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--bg-primary);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
}

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

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--space-sm);
    border-radius: var(--border-radius);
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: var(--bg-accent);
    color: var(--text-primary);
}

.modal-body {
    padding: var(--space-lg);
    max-height: calc(90vh - 80px);
    overflow-y: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    min-height: 300px;
}

.modal-body img {
    max-width: 100%;
    max-height: 70vh;
    height: auto;
    object-fit: contain;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
}

.modal-body video {
    max-width: 100%;
    max-height: 70vh;
    height: auto;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
}

.modal-body audio {
    width: 100%;
    max-width: 500px;
}

.modal-body iframe {
    width: 100%;
    height: 70vh;
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
}

.modal-body pre {
    text-align: left;
    white-space: pre-wrap;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    background: var(--bg-accent);
    padding: var(--space-lg);
    border-radius: var(--border-radius);
    max-height: 500px;
    overflow-y: auto;
    font-size: 0.875rem;
    line-height: 1.5;
}

.modal-body .preview-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-lg);
    padding: var(--space-2xl);
    color: var(--text-secondary);
}

/* Alert */
.alert {
    padding: var(--space-md);
    border-radius: var(--border-radius);
    margin-bottom: var(--space-lg);
    font-weight: 500;
    font-size: 0.875rem;
}

.alert-success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-error {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.alert-info {
    background: #eff6ff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
}

/* No Files State */
.no-files {
    text-align: center;
    padding: var(--space-2xl);
    color: var(--text-secondary);
    font-size: 1.125rem;
    background: var(--bg-accent);
    border-radius: var(--border-radius);
    border: 2px dashed var(--border-color);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .app-layout {
        grid-template-areas: 
            "header"
            "main";
        grid-template-columns: 1fr;
        grid-template-rows: var(--header-height) 1fr;
    }
    
    .app-sidebar {
        display: none;
    }
}

@media (max-width: 768px) {
    :root {
        --space-lg: 1rem;
        --space-xl: 1.5rem;
        --space-2xl: 2rem;
    }
    
    .login-container {
        padding: var(--space-xl);
        margin: var(--space-md);
    }
    
    .app-main {
        padding: var(--space-lg);
    }
    
    .view-header {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-md);
    }
    
    .view-actions {
        justify-content: space-between;
    }
    
    .upload-container {
        padding: var(--space-lg);
    }
    
    .drop-zone {
        padding: var(--space-xl);
    }
    
    .success-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .file-item {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-md);
    }
    
    .file-actions {
        justify-content: center;
    }
    
    .pagination {
        flex-direction: column;
        gap: var(--space-md);
    }
    
    .url-copy {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .modal-content {
        max-width: 95vw;
        max-height: 95vh;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
    
    .success-actions .btn {
        width: auto;
    }
}