/* ============================================
   RESET & BASE
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #8b5cf6;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border: #475569;
    --hover: #475569;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-lg: rgba(0, 0, 0, 0.5);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* ============================================
   LOGIN SCREEN
   ============================================ */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px var(--shadow-lg);
    border: 1px solid var(--border);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header h1 {
    font-size: 28px;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

.form-group {
    margin-bottom: 20px;
}

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

.form-group input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 15px;
    transition: all 0.2s;
}

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

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

/* ============================================
   BUTTONS
   ============================================ */
.btn-primary {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
}

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

.btn-secondary {
    padding: 10px 20px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 18px;
}

.btn-icon:hover {
    background: var(--hover);
    border-color: var(--primary);
    transform: scale(1.05);
}

/* ============================================
   APP CONTAINER
   ============================================ */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.app-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.app-title {
    font-size: 24px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ============================================
   TOOLBAR
   ============================================ */
.toolbar {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex-shrink: 0;
}

.breadcrumb-container {
    overflow-x: auto;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.breadcrumb-item {
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    white-space: nowrap;
}

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

.breadcrumb-separator {
    color: var(--text-muted);
    user-select: none;
}

.toolbar-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.search-box {
    flex: 1;
    position: relative;
    max-width: 400px;
}

.search-box input {
    width: 100%;
    padding: 10px 40px 10px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
}

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

.btn-clear-search {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 16px;
}

.btn-clear-search:hover {
    background: var(--hover);
    color: var(--text-primary);
}

.sort-select {
    padding: 10px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
}

.sort-select:focus {
    outline: none;
    border-color: var(--primary);
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    position: relative;
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 100;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.error-banner {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.btn-close-error {
    background: transparent;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 20px;
    padding: 0 8px;
}

.file-container {
    position: relative;
}

/* ============================================
   FILE LIST (LIST VIEW)
   ============================================ */
.file-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.file-item {
    display: flex;
    align-items: center;
    padding: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    transition: all 0.2s;
    cursor: pointer;
    gap: 16px;
}

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

.file-icon {
    font-size: 32px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

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

.file-name {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 4px;
    color: var(--text-primary);
    word-break: break-word;
}

.file-meta {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.file-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.file-action-btn {
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.file-action-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

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

.file-action-btn.primary:hover {
    background: var(--primary-dark);
}

/* ============================================
   FILE LIST (GRID VIEW)
   ============================================ */
.file-list.grid-view {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.file-list.grid-view .file-item {
    flex-direction: column;
    text-align: center;
    padding: 24px 16px;
}

.file-list.grid-view .file-icon {
    font-size: 48px;
    width: 64px;
    height: 64px;
    margin: 0 auto;
}

.file-list.grid-view .file-info {
    width: 100%;
}

.file-list.grid-view .file-name {
    font-size: 14px;
    margin-bottom: 8px;
}

.file-list.grid-view .file-meta {
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
}

.file-list.grid-view .file-actions {
    width: 100%;
    flex-direction: column;
    margin-top: 12px;
}

.file-list.grid-view .file-action-btn {
    width: 100%;
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* ============================================
   MODAL
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 16px;
    width: 100%;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px var(--shadow-lg);
    border: 1px solid var(--border);
    overflow: hidden;
}

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

.modal-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    word-break: break-word;
    flex: 1;
    margin-right: 16px;
}

.modal-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.modal-body {
    flex: 1;
    overflow: auto;
    padding: 24px;
}

.preview-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    gap: 16px;
    color: var(--text-muted);
}

/* ============================================
   PREVIEW CONTENT
   ============================================ */
.preview-image {
    max-width: 100%;
    max-height: 70vh;
    margin: 0 auto;
    display: block;
    border-radius: 8px;
    box-shadow: 0 8px 24px var(--shadow);
}

.preview-video {
    max-width: 100%;
    max-height: 70vh;
    margin: 0 auto;
    display: block;
    border-radius: 8px;
}

.preview-pdf {
    width: 100%;
    height: 70vh;
    border: none;
    border-radius: 8px;
}

.preview-unsupported {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.preview-unsupported-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* ============================================
   TEXT VIEWER
   ============================================ */
.text-viewer-modal {
    max-width: 1200px;
}

/* ============================================
   RENAME & MOVE MODALS
   ============================================ */
.small-modal {
    max-width: 500px;
}

.modal-form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 20px;
}

.form-hint {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
}

.text-viewer {
    background: var(--bg-primary);
    padding: 20px;
    border-radius: 8px;
    overflow-x: auto;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 70vh;
    border: 1px solid var(--border);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    .header-right {
        width: 100%;
        justify-content: space-between;
    }

    .toolbar {
        padding: 12px 16px;
    }

    .toolbar-actions {
        flex-direction: column;
        width: 100%;
    }

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

    .file-item {
        flex-wrap: wrap;
    }

    .file-actions {
        width: 100%;
        margin-top: 12px;
    }

    .file-action-btn {
        flex: 1;
    }

    .file-list.grid-view {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

    .modal-content {
        max-width: 95vw;
        max-height: 95vh;
    }
}

/* ============================================
   SCROLLBAR
   ============================================ */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 5px;
}

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