/* ============================================================
   CloudBox — Design System
   ============================================================ */

:root {
    --primary: #6C5CE7;
    --primary-dark: #5849c2;
    --primary-light: #eeebfc;
    --bg: #f6f7fb;
    --surface: #ffffff;
    --border: #e5e7f0;
    --text: #1e1f2e;
    --text-muted: #8a8ca0;
    --danger: #e74c3c;
    --success: #00b894;
    --radius: 12px;
    --shadow: 0 2px 12px rgba(30, 31, 46, 0.06);
    --shadow-lg: 0 8px 30px rgba(30, 31, 46, 0.12);
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

/* ---------- Auth pages ---------- */
.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #6C5CE7 0%, #a29bfe 100%);
    padding: 20px;
}

.auth-card {
    background: var(--surface);
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.auth-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    margin-bottom: 4px;
}

.logo-icon {
    font-size: 28px;
    background: var(--primary);
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-logo h1 {
    font-size: 24px;
    color: var(--text);
}

.auth-subtitle {
    text-align: center;
    color: var(--text-muted);
    margin: 8px 0 24px;
    font-size: 14px;
}

.auth-form { display: flex; flex-direction: column; gap: 16px; }

.form-group { display: flex; flex-direction: column; gap: 6px; }

.form-group label { font-size: 13px; font-weight: 600; color: var(--text); }

.form-group input {
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus { border-color: var(--primary); }

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 13px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
    background: var(--bg);
    color: var(--text);
    border: 1.5px solid var(--border);
    padding: 13px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

.auth-switch {
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
    color: var(--text-muted);
}

.auth-switch a { color: var(--primary); font-weight: 600; text-decoration: none; }

.alert {
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 13px;
    margin-bottom: 16px;
}

.alert-error { background: #fdecea; color: var(--danger); }
.alert-info { background: var(--primary-light); color: var(--primary-dark); }

/* ---------- App layout ---------- */
.app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    flex-shrink: 0;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 700;
    padding: 0 4px;
}

.btn-new-folder {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-new-folder:hover { background: var(--primary-dark); }

.sidebar-section { flex: 1; overflow-y: auto; }

.sidebar-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 10px;
    padding: 0 4px;
}

.folder-tree { display: flex; flex-direction: column; gap: 2px; }

.folder-item {
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    transition: background 0.15s;
}

.folder-item:hover { background: var(--bg); }
.folder-item.active { background: var(--primary-light); color: var(--primary-dark); font-weight: 600; }

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

.btn-backup {
    width: 100%;
    background: var(--bg);
    border: 1.5px solid var(--border);
    padding: 11px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    color: var(--text);
}

.btn-backup:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary-dark); }

/* ---------- Main content ---------- */
.main {
    flex: 1;
    padding: 24px 32px;
    overflow-y: auto;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 24px;
}

.breadcrumb {
    font-size: 14px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.breadcrumb span {
    cursor: pointer;
}

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

.breadcrumb span:last-child { color: var(--text); font-weight: 600; }

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

.search-box input {
    width: 100%;
    padding: 11px 16px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    outline: none;
    background: var(--surface);
}

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

.user-menu { position: relative; }

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    cursor: pointer;
    font-size: 15px;
}

.avatar-lg { width: 64px; height: 64px; font-size: 24px; }

.user-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: 50px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    overflow: hidden;
    z-index: 10;
}

.user-menu:hover .user-dropdown { display: block; }

.user-dropdown-name {
    padding: 12px 16px;
    font-weight: 600;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}

.user-dropdown a {
    display: block;
    padding: 11px 16px;
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
}

.user-dropdown a:hover { background: var(--bg); }

/* ---------- Upload zone ---------- */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 28px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 20px;
    transition: border-color 0.2s, background 0.2s;
}

.upload-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.upload-link { color: var(--primary); font-weight: 600; cursor: pointer; }

.upload-progress-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }

.upload-progress-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ---------- Content grid ---------- */
.content-header {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 16px;
}

.content-header h2 { font-size: 20px; }
.item-count { color: var(--text-muted); font-size: 13px; }

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 14px;
    text-align: center;
    cursor: pointer;
    position: relative;
    transition: box-shadow 0.15s, transform 0.1s;
}

.card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }

.card-icon { font-size: 36px; margin-bottom: 10px; }

.card-name {
    font-size: 13px;
    font-weight: 600;
    word-break: break-word;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.card-meta { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

.card-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: none;
    gap: 4px;
}

.card:hover .card-actions { display: flex; }

.card-action-btn {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    border: none;
    background: var(--bg);
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-action-btn:hover { background: var(--primary-light); }
.card-action-btn.danger:hover { background: #fdecea; }

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    font-size: 14px;
}

/* ---------- Modals ---------- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(30, 31, 46, 0.45);
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-overlay.open { display: flex; }

.modal {
    background: var(--surface);
    border-radius: 16px;
    padding: 28px;
    width: 100%;
    max-width: 360px;
    box-shadow: var(--shadow-lg);
}

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

.modal input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    outline: none;
    margin-bottom: 18px;
}

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

.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.modal-actions button { padding: 10px 18px; }

/* ---------- Profile page ---------- */
.profile-page { max-width: 700px; }

.profile-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 28px;
}

.profile-header h2 { font-size: 22px; margin-bottom: 4px; }
.text-muted { color: var(--text-muted); font-size: 13px; }

.profile-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
}

.stat-value { font-size: 24px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.profile-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}

.profile-section h3 { font-size: 16px; margin-bottom: 16px; }

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .app { flex-direction: column; }
    .sidebar { width: 100%; flex-direction: row; overflow-x: auto; align-items: center; }
    .sidebar-section { display: none; }
    .topbar { flex-wrap: wrap; }
    .main { padding: 16px; }
}
