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

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --secondary: #64748b;
    --bg: #f8fafc;
    --card: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --radius: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

/* ── Login ─────────────────────────────────── */

.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-box {
    background: var(--card);
    padding: 40px;
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-box h1 {
    margin-bottom: 24px;
    font-size: 24px;
    color: var(--text);
}

.login-box input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
}

.login-box input:focus {
    border-color: var(--primary);
}

.login-box button {
    width: 100%;
    margin-top: 12px;
    padding: 12px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 15px;
    cursor: pointer;
    transition: background 0.2s;
}

.login-box button:hover {
    background: var(--primary-hover);
}

.login-error {
    color: var(--danger);
    margin-top: 12px;
    font-size: 14px;
    min-height: 20px;
}

/* ── App Layout ────────────────────────────── */

.app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.header h1 {
    font-size: 20px;
}

/* ── Buttons ───────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover { background: var(--danger-hover); }

.btn-secondary {
    background: var(--secondary);
    color: #fff;
}
.btn-secondary:hover { background: #475569; }

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

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

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

/* ── Toolbar ───────────────────────────────── */

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.toolbar-left {
    flex: 1;
    min-width: 0;
}

.toolbar-right {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    overflow-x: auto;
}

.breadcrumb-item {
    color: var(--primary);
    text-decoration: none;
    white-space: nowrap;
}

.breadcrumb-item:hover {
    text-decoration: underline;
}

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

/* ── Drop Zone ─────────────────────────────── */

.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
    transition: all 0.2s;
}

.drop-zone-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    color: var(--text-muted);
}

.drop-icon {
    width: 32px;
    height: 32px;
    margin-bottom: 8px;
}

.drop-zone.active {
    border-color: var(--primary);
    background: #eff6ff;
}

/* ── Upload Progress ───────────────────────── */

.upload-progress {
    position: relative;
    height: 28px;
    background: var(--bg);
    border-radius: var(--radius);
    margin-bottom: 16px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.upload-progress-bar {
    height: 100%;
    background: var(--primary);
    transition: width 0.3s;
    width: 0%;
}

.upload-progress-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: var(--text);
}

/* ── Select All Bar ────────────────────────── */

.select-all-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: #eff6ff;
    border-radius: var(--radius);
    margin-bottom: 8px;
    font-size: 13px;
}

.selected-count {
    color: var(--text-muted);
}

/* ── File List ─────────────────────────────── */

.file-list-container {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    overflow: hidden;
}

.file-list {
    width: 100%;
    border-collapse: collapse;
}

.file-list th {
    text-align: left;
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}

.file-list td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.file-list tr:last-child td {
    border-bottom: none;
}

.file-list tr:hover td {
    background: #f1f5f9;
}

.col-check {
    width: 40px;
    text-align: center;
}

.col-name { min-width: 200px; }
.col-size { width: 100px; }
.col-modified { width: 170px; }
.col-actions { width: 220px; }

.file-name {
    display: flex;
    align-items: center;
    gap: 8px;
}

.file-icon {
    flex-shrink: 0;
    color: var(--text-muted);
}

.folder-link, .file-name-text, .file-preview-link {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-preview-link {
    color: var(--primary);
    text-decoration: none;
    cursor: pointer;
}

.file-preview-link:hover {
    text-decoration: underline;
}

.folder-link {
    color: var(--primary);
    text-decoration: none;
    cursor: pointer;
    font-weight: 500;
}

.folder-link:hover {
    text-decoration: underline;
}

.file-size {
    color: var(--text-muted);
    font-size: 13px;
}

.file-modified {
    color: var(--text-muted);
    font-size: 13px;
}

.file-actions {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.file-actions .btn {
    font-size: 12px;
    padding: 4px 8px;
}

/* ── Empty / Loading ───────────────────────── */

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}

.loading {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    margin: 0 auto 12px;
    animation: spin 0.8s linear infinite;
}

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

/* ── Modal ─────────────────────────────────── */

.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.4);
}

.modal-content {
    position: relative;
    background: var(--card);
    border-radius: var(--radius);
    padding: 24px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.modal-content h3 {
    margin-bottom: 16px;
    font-size: 18px;
}

.link-group {
    margin-bottom: 16px;
}

.link-group label {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.link-row {
    display: flex;
    gap: 8px;
}

.link-row input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    background: var(--bg);
    color: var(--text);
}

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

#confirmMessage {
    white-space: pre-line;
    line-height: 1.6;
}

/* ── Responsive ────────────────────────────── */

@media (max-width: 768px) {
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-right {
        overflow-x: auto;
    }

    .col-modified { display: none; }

    .file-actions .btn span {
        display: none;
    }

    .header h1 {
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .app { padding: 12px; }

    .col-size { display: none; }

    .file-list th, .file-list td {
        padding: 8px;
    }
}
