/* Mini Drive — single stylesheet, no external dependencies. */

:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --border: #e3e6eb;
    --text: #1f2430;
    --muted: #6b7280;
    --primary: #2563eb;
    --primary-hover: #1d4fd1;
    --danger: #dc2626;
    --success: #16a34a;
    --warning: #d97706;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 18px rgba(0,0,0,.06);
    --shadow-lg: 0 10px 40px rgba(0,0,0,.15);
}

* { box-sizing: border-box; }

html, body {
    margin: 0; padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ====== Buttons ====== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 8px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 14px; font-weight: 500;
    line-height: 1.25;
    cursor: pointer; user-select: none;
    text-decoration: none;
    white-space: nowrap;
    transition: transform .08s ease, background .15s ease, border-color .15s ease;
}
.btn:hover { background: #f0f2f6; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
.btn-secondary { background: var(--surface); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: rgba(0,0,0,.04); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.btn-google {
    width: 100%;
    padding: 12px 16px;
    background: #fff;
    border: 1px solid var(--border);
    font-weight: 500;
}

/* ====== Login / Error ====== */
.login-body, .error-body {
    min-height: 100vh;
    display: grid; place-items: center;
    background: linear-gradient(180deg, #f6f7f9 0%, #ecedf3 100%);
    padding: 16px;
}
.login-card, .error-card {
    background: var(--surface);
    padding: 40px 32px;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    max-width: 380px; width: 100%;
    text-align: center;
}
.login-logo { font-size: 40px; }
.login-card h1 { margin: 8px 0 4px; font-size: 24px; }
.login-sub { color: var(--muted); margin: 0 0 24px; }
.login-foot { color: var(--muted); font-size: 12px; margin: 18px 0 0; }
.error-code { font-size: 64px; font-weight: 700; color: var(--muted); }
.alert { padding: 10px 12px; border-radius: 8px; margin-bottom: 16px; font-size: 13px; text-align: left; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* ====== Dashboard topbar ====== */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.brand { font-weight: 600; font-size: 16px; color: var(--text); }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.user-email { color: var(--muted); font-size: 13px; }

/* ====== Toolbar ====== */
.toolbar {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 16px 24px;
    background: var(--bg);
    flex-wrap: wrap;
}
.toolbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Long-vs-short button labels; CSS swaps them at the mobile breakpoint */
.btn-long { display: inline; }
.btn-short { display: none; }
.breadcrumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 14px; }
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--primary); text-decoration: none; }
.breadcrumbs .crumb-sep { color: #cbd0d8; }
.breadcrumbs .crumb-current { color: var(--text); font-weight: 500; }

.view-toggle { display: flex; gap: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.view-btn {
    border: 0; background: var(--surface);
    padding: 8px 12px; font-size: 16px; cursor: pointer;
}
.view-btn.active { background: var(--primary); color: #fff; }

/* ====== Content ====== */
.content { padding: 0 24px 48px; }
.loading { padding: 40px; text-align: center; color: var(--muted); }
.section-title { margin: 24px 0 12px; color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.empty-state {
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px;
    text-align: center;
    color: var(--muted);
}

/* ====== Grid view ====== */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 14px;
}
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex; flex-direction: column;
    transition: box-shadow .15s ease, border-color .15s ease;
    position: relative;
}
.card:hover { box-shadow: var(--shadow); border-color: #d1d5db; }
.card.selected { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary), var(--shadow); }

/* ===== Checkboxes — small, GitHub/macOS-ish ===== */
.select-toggle {
    box-sizing: border-box;
    width: 16px; height: 16px;
    padding: 0;
    display: inline-grid; place-items: center;
    background: #fff;
    border: 1px solid #c5cad3;
    border-radius: 4px;
    cursor: pointer;
    transition: background .12s ease, border-color .12s ease, opacity .12s ease;
}
.select-toggle:hover { border-color: #8b94a4; }
.select-toggle svg { display: none; width: 10px; height: 10px; color: #fff; }

/* Selected: blue fill with a white check */
.card.selected .select-toggle,
.list-row.selected .select-toggle {
    background: var(--primary);
    border-color: var(--primary);
}
.card.selected .select-toggle svg,
.list-row.selected .select-toggle svg { display: block; }

/* Grid: checkbox tucked in the top-left corner, hidden until needed */
.card .select-toggle {
    position: absolute; top: 8px; left: 8px;
    opacity: 0;
    z-index: 2;
}
.card:hover .select-toggle,
.card.selected .select-toggle,
body.has-selection .card .select-toggle { opacity: 1; }

/* List: always visible, no positioning */
.list-row.selected { background: #eff6ff; }
.list-row .select-toggle { opacity: 1; }
.card-thumb {
    position: relative;
    aspect-ratio: 4 / 3;
    background: #f0f2f6;
    display: grid; place-items: center;
    overflow: hidden;
}
.card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.card-thumb .icon { font-size: 44px; }
.card-thumb .thumb-icon {
    width: 64px; height: 80px;
    display: grid; place-items: center;
}
.card-thumb .thumb-icon .file-icon,
.card-thumb .thumb-icon .folder-icon { width: 100%; height: 100%; }
.folder-card .card-thumb .thumb-icon { width: 80px; height: 64px; }
.card-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; }
.card-title {
    font-size: 14px; font-weight: 500;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card-sub { color: var(--muted); font-size: 12px; display: flex; gap: 8px; justify-content: space-between; }
.visibility-badge {
    display: inline-block;
    font-size: 11px; font-weight: 600;
    padding: 2px 6px; border-radius: 6px;
    text-transform: uppercase; letter-spacing: .04em;
}
.visibility-public { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.visibility-private { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }

/* Card menu */
.menu-toggle {
    position: absolute; top: 6px; right: 6px;
    background: rgba(255,255,255,.92);
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 28px; height: 28px;
    display: grid; place-items: center;
    cursor: pointer;
}
.menu {
    position: fixed;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    min-width: 200px;
    overflow: hidden;
}
.menu button {
    display: flex; align-items: center; gap: 8px;
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    background: transparent; border: 0; cursor: pointer;
    font-size: 13px; color: var(--text);
}
.menu button:hover:not(:disabled) { background: #f3f4f6; }
.menu button:disabled { opacity: .5; cursor: not-allowed; }
.menu .danger { color: var(--danger); }
.menu .sep { height: 1px; background: var(--border); margin: 4px 0; }
.icon-svg { flex: 0 0 auto; color: var(--muted); }
.menu button:hover .icon-svg { color: var(--text); }
.btn .icon-svg { color: currentColor; }

/* Folder card */
.folder-card { cursor: pointer; }
.folder-card .card-thumb { aspect-ratio: 4 / 2; background: #eef2ff; }
.folder-card .card-thumb .icon { font-size: 36px; }

/* ====== List view ====== */
.list { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.list-row {
    display: grid;
    grid-template-columns: 24px 32px 1fr 100px 140px 90px 40px;
    gap: 12px;
    align-items: center;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
    position: relative;
}
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: #fafbfc; }
.list-row .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .meta { color: var(--muted); font-size: 12px; }
.list-row .row-icon {
    width: 32px; height: 40px;
    display: grid; place-items: center;
}
.list-row .row-icon .file-icon,
.list-row .row-icon .folder-icon { width: 100%; height: 100%; }
.list-row .row-icon .row-thumb {
    width: 32px; height: 32px;
    object-fit: cover; border-radius: 4px;
    border: 1px solid var(--border);
}
.list-row .menu-toggle { position: static; }
.list-row .select-cell { display: grid; place-items: center; }
.list-header {
    display: grid;
    grid-template-columns: 24px 32px 1fr 100px 140px 90px 40px;
    gap: 12px;
    padding: 8px 14px;
    color: var(--muted); font-size: 12px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .04em;
    background: #f8f9fb;
    border-bottom: 1px solid var(--border);
}

/* ====== Modals ====== */
.modal {
    position: fixed; inset: 0;
    background: rgba(15,23,42,.45);
    display: grid; place-items: center;
    padding: 16px;
    z-index: 100;
}
.modal.hidden { display: none; }
.modal-card {
    background: var(--surface);
    border-radius: 14px;
    padding: 24px;
    width: 100%; max-width: 440px;
    box-shadow: var(--shadow-lg);
}
.modal-card h2 { margin: 0 0 16px; font-size: 18px; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 13px; }
.field input[type=text], .field input[type=file], .field select, .field input[type=number] {
    width: 100%; padding: 9px 11px;
    border: 1px solid var(--border); border-radius: 8px;
    font-size: 14px; background: #fff;
}
.field input:focus, .field select:focus { outline: 2px solid #bfdbfe; border-color: var(--primary); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* ====== Dropzone (in upload modal) ====== */
.dropzone {
    display: block;
    border: 2px dashed var(--border);
    border-radius: 12px;
    background: #fafbfc;
    padding: 28px 16px;
    text-align: center;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, transform .08s ease;
}
.dropzone:hover { background: #f3f5f9; border-color: #c9cfd9; }
.dropzone.is-dragover {
    background: #eef4ff;
    border-color: var(--primary);
    transform: scale(1.005);
}
.dropzone-icon { color: var(--muted); display: block; margin: 0 auto 10px; }
.dropzone-title { font-weight: 500; color: var(--text); }
.dropzone-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.dropzone-link { color: var(--primary); text-decoration: underline; }
.dropzone-files { margin-top: 10px; text-align: left; max-height: 240px; overflow-y: auto; }
.queue-summary { color: var(--muted); font-size: 12px; margin-bottom: 6px; padding: 0 2px; }
.dropzone-files .file-pill {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 10px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 4px;
    font-size: 13px;
}
.dropzone-files .file-pill .pill-name {
    flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dropzone-files .file-pill .pill-size { color: var(--muted); font-size: 12px; }
.dropzone-files .file-pill .pill-remove {
    background: transparent; border: 0; cursor: pointer;
    color: var(--muted); padding: 0 2px; font-size: 16px; line-height: 1;
}
.dropzone-files .file-pill .pill-remove:hover { color: var(--danger); }

/* ====== Global drop overlay ====== */
.drop-overlay {
    position: fixed; inset: 0;
    background: rgba(37, 99, 235, .08);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 300;
    display: grid; place-items: center;
    pointer-events: none;
    transition: opacity .12s ease;
}
.drop-overlay.hidden { display: none; }
.drop-overlay-card {
    background: var(--surface);
    border: 2px dashed var(--primary);
    border-radius: 16px;
    padding: 32px 48px;
    text-align: center;
    color: var(--primary);
    box-shadow: var(--shadow-lg);
}
.drop-overlay-title { font-size: 18px; font-weight: 600; margin-top: 12px; }
.drop-overlay-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }

.upload-progress { margin-top: 14px; }
.upload-progress.hidden { display: none; }
.progress { height: 8px; background: #eef2f7; border-radius: 6px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--primary); width: 0; transition: width .15s ease; }
.progress-label { margin-top: 6px; color: var(--muted); font-size: 12px; text-align: right; }

/* ====== Bulk action bar ====== */
.bulk-bar {
    position: sticky; top: 12px; z-index: 50;
    margin: 0 24px 16px;
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px 8px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(15, 23, 42, .08);
    animation: bulkSlideIn .15s ease;
}
.bulk-bar.hidden { display: none; }
.bulk-count {
    display: inline-flex; align-items: center;
    padding: 4px 10px;
    background: #eef4ff;
    color: var(--primary);
    border-radius: 8px;
    font-weight: 600;
    font-size: 12px;
    white-space: nowrap;
}
.bulk-actions { display: flex; gap: 6px; margin-left: auto; }
.bulk-bar .btn { padding: 6px 12px; font-size: 13px; }
@keyframes bulkSlideIn { from { transform: translateY(-6px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (max-width: 720px) { .bulk-bar { margin: 0 14px 12px; flex-wrap: wrap; } }
.select-all-row {
    display: flex; align-items: center; gap: 8px;
    margin: 12px 0 0;
    color: var(--muted); font-size: 13px;
}
.select-all-row button {
    background: transparent; border: 0;
    color: var(--primary); cursor: pointer;
    font-size: 13px; padding: 2px 4px;
}
.select-all-row button:hover { text-decoration: underline; }

/* ====== Toasts ====== */
.toasts { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { padding: 10px 14px; border-radius: 10px; background: #1f2430; color: #fff; box-shadow: var(--shadow-lg); font-size: 13px; max-width: 320px; }
.toast.success { background: #047857; }
.toast.error { background: #b91c1c; }

/* ====== Folder view page (public) ====== */
.folder-view { max-width: 1080px; margin: 24px auto; padding: 0 16px 48px; }
.folder-crumbs { margin-bottom: 16px; }
.folder-view .view-title { font-size: 22px; margin: 0 0 4px; }
.folder-view .grid { margin-top: 8px; }
.folder-view .card.folder-card .card-thumb { aspect-ratio: 4 / 2; background: #eef2ff; }
.folder-view a.card { text-decoration: none; color: inherit; }
.folder-view a.card:hover { text-decoration: none; }

/* ====== File view page ====== */
.view-body { background: var(--bg); min-height: 100vh; }
.view-header {
    padding: 10px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.view-header-row {
    display: flex; align-items: baseline; flex-wrap: wrap;
    gap: 0 12px;
    row-gap: 6px;
    line-height: 1.4;
}
.view-header-row .brand { margin-right: 4px; }
.view-header-row > * { min-width: 0; }
.view-header-row .view-crumbs {
    margin: 0;
    border-left: 1px solid var(--border);
    padding-left: 12px;
}
.view-header-row .view-title {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
    color: var(--text);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    min-width: 0; max-width: 60vw;
    border-left: 1px solid var(--border);
    padding-left: 12px;
}
.view-header-row .view-meta {
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
    margin-left: -6px;
}
.view-header-row .visibility-badge { margin-left: auto; }
@media (max-width: 720px) {
    .view-header { padding: 8px 14px; }
    .view-header-row .view-crumbs,
    .view-header-row .view-title { border-left: 0; padding-left: 0; }
}
.view-main {
    max-width: 920px; margin: 20px auto; padding: 0 16px;
}
.view-crumbs {
    display: flex; align-items: center; flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 12px;
    font-size: 13px;
    line-height: 1.4;
    color: var(--muted);
}
.view-crumbs a { color: var(--muted); text-decoration: none; }
.view-crumbs a:hover { color: var(--primary); }
.view-crumbs .crumb-back {
    color: var(--text);
    font-weight: 500;
}
.view-crumbs .crumb-back:hover { color: var(--primary); }
.view-crumbs .crumb-sep { color: #cbd0d8; padding: 0 2px; }
.view-title { font-size: 22px; margin: 0 0 4px; word-break: break-word; }
.view-meta { color: var(--muted); margin-bottom: 18px; }
.view-preview {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: grid; place-items: center;
    min-height: 280px;
    overflow: hidden;
}
.view-preview img, .view-preview video { max-width: 100%; max-height: 70vh; border-radius: 6px; }
.view-preview iframe { display: block; width: 100%; height: 70vh; border: 0; }
.generic-preview { text-align: center; }
.big-icon { font-size: 80px; margin-bottom: 12px; }

/* Actions stay in one row even on small screens — labels switch to short. */
.view-actions {
    display: flex; gap: 8px; margin-top: 16px;
    flex-wrap: nowrap;
}
.view-actions .btn {
    flex: 1 1 0;
    min-width: 0;
    padding: 8px 10px;
}
.view-body { overflow-x: hidden; }

/* ====== Responsive ====== */
@media (max-width: 720px) {
    .topbar { padding: 10px 14px; gap: 8px; }
    .toolbar { padding: 12px 14px; }
    .content { padding: 0 14px 32px; }
    .list-row, .list-header { grid-template-columns: 22px 28px 1fr 70px 36px; }
    /* Hide Size+Modified on narrow screens; keep checkbox, icon, name, access, menu */
    .list-row .meta, .list-header span:nth-child(4),
    .list-header span:nth-child(5) { display: none; }
    .list-row .row-icon { width: 28px; height: 34px; }
    .user-email, .avatar { display: none; }
    .brand { font-size: 15px; }

    /* Switch long button labels to short ones */
    .btn-long { display: none; }
    .btn-short { display: inline; }
    .btn { padding: 7px 12px; font-size: 13px; }

    /* "Select all" becomes a small ghost icon on mobile */
    #btn-select-all { padding: 6px 10px; }

    /* Bulk action bar — slightly tighter */
    .bulk-bar { gap: 8px; padding: 6px 8px 6px 12px; }
    .bulk-bar .btn { padding: 5px 10px; font-size: 12px; }
    .bulk-count { padding: 3px 8px; font-size: 11px; }

    /* File view header — give title room when meta wraps */
    .view-header-row .view-title { max-width: 100%; }
}
@media (max-width: 380px) {
    .view-toggle { display: none; }
    .toolbar-actions { gap: 6px; }
}
