/* =========================================================================
   views/files.css — Files manager (Drive-style) + file preview modal
   Split from the old monolithic styles/views.css. LOAD ORDER MATTERS:
   the <link> order in Magnet CRM.html / Client App.html reproduces the
   original file order, so the cascade is unchanged — add new rules to the
   matching feature file, not the end of the list.
   ========================================================================= */
/* ---- Files manager (Google Drive-style) ---------------------------- */
.cfiles { display: flex; flex-direction: column; gap: var(--space-5); }
.cfiles-bar { display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap; }
.cfiles-search { width: 280px; max-width: 100%; }
.cfiles-crumb { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cfiles-crumb-link { font-size: var(--text-md); font-weight: var(--fw-medium); color: var(--text-soft); border-radius: var(--radius-sm); padding: 2px 6px; transition: background var(--dur) var(--ease), color var(--dur) var(--ease); }
@media (hover: hover) and (pointer: fine) {
  .cfiles-crumb-link:hover { background: var(--surface-hover); color: var(--text); }
}
.cfiles-crumb-link.cur { color: var(--text-strong); font-weight: var(--fw-semibold); }
.cfiles-crumb-sep { color: var(--gray-300); }

.cfiles-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--space-3); position: relative; min-height: 320px; align-content: start; user-select: none; }
/* with no files, centre the empty state instead of dropping it in the top-left
   grid cell — the .empty-state already centres its own content. */
.cfiles-grid:has(> .empty-state) { display: flex; align-items: center; justify-content: center; }
.cfile-card { display: flex; align-items: center; gap: var(--space-3); padding: 10px 8px 10px 12px; border-radius: var(--radius-lg); background: var(--gray-50); cursor: pointer; transition: background var(--dur) var(--ease), box-shadow var(--dur) var(--ease); height: max-content; }
@media (hover: hover) and (pointer: fine) {
  .cfile-card:hover { background: var(--gray-100); }
}
.cfile-card.sel { background: var(--info-bg); }
.cfile-card.sel .cfile-name { color: var(--info-600); }

/* size/modified columns — only shown in list view */
.cfile-col { display: none; }

/* list view — full-width rows with Size + Modified columns */
.cfiles-view-list .cfiles-grid { grid-template-columns: 1fr; gap: 2px; min-height: 220px; }
.cfiles-view-list .cfile-card { border-radius: var(--radius-md); padding: 8px 8px 8px 12px; }
.cfiles-view-list .cfile-ico { width: 32px; height: 32px; }
.cfiles-view-list .cfile-ico svg { width: 17px; height: 17px; }
.cfiles-view-list .cfile-id { flex: 1 1 auto; flex-direction: row; align-items: center; gap: var(--space-3); }
.cfiles-view-list .cfile-id .cfile-name { flex: 0 1 auto; min-width: 0; }
.cfiles-view-list .cfile-meta { display: none; }
.cfiles-view-list .cfile-col { display: block; flex: 0 0 auto; font-size: var(--text-sm); color: var(--text-soft); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cfiles-view-list .cfile-size { width: 92px; }
.cfiles-view-list .cfile-modified { width: 104px; padding-right: var(--space-2); }

/* Sync button — full-colour Drive logo */
.files-sync-ico { display: inline-flex; width: 16px; height: 14px; }
.files-sync-ico svg { width: 100%; height: 100%; }

/* files grid/list view switch */
.files-viewseg button { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; padding: 0 8px; }
.files-viewseg button svg { width: 17px; height: 17px; }
.cfile-ico { flex-shrink: 0; width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-md); background: var(--surface); color: var(--text-soft); }
.cfile-ico svg { width: 19px; height: 19px; }
/* Google-Drive-style folder: a solid filled folder glyph, no tile, a touch larger. */
.cfile-ico.fk-folder { background: transparent; color: var(--primary-500); }
.cfile-ico.fk-folder svg { width: 30px; height: 30px; }
.cfile-ico.fk-pdf, .cfile-ico.fk-doc { color: var(--file-pdf); }
.cfile-ico.fk-sheet { color: var(--file-sheet); }
.cfile-ico.fk-img { color: var(--file-img); }
.cfile-ico.fk-video { color: var(--info-600); }
.cfile-ico.fk-fig { color: var(--file-fig); }
/* optimistic "uploading" card while a drop is saving */
.cfile-card.is-uploading { opacity: 0.55; }
/* Info / details modal */
.cfile-info { display: flex; flex-direction: column; }
.cfile-info-row { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 9px 0; border-bottom: 0.5px solid var(--border); font-size: var(--text-sm); }
.cfile-info-row:last-child { border-bottom: 0; }
.cfile-info-k { color: var(--text-soft); flex-shrink: 0; }
.cfile-info-v { color: var(--text-strong); text-align: right; word-break: break-word; font-variant-numeric: tabular-nums; }
.cfile-ico.cfile-ico--thumb { background: var(--gray-100); padding: 0; overflow: hidden; }
.cfile-ico.cfile-ico--thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---- file preview modal (Drive-style) ---- */
.cfile-preview { display: flex; align-items: center; justify-content: center; min-height: 240px; }
.cfile-preview--img { background: var(--gray-100); border-radius: var(--radius-md); padding: var(--space-3); }
.cfile-preview--img img { max-width: 100%; max-height: min(64vh, 560px); border-radius: var(--radius-sm); object-fit: contain; display: block; }
.cfile-preview--frame { width: 100%; }
.cfile-preview--frame iframe { width: 100%; height: min(64vh, 560px); border: 0; border-radius: var(--radius-md); background: var(--gray-100); }
.cfile-preview--none { flex-direction: column; gap: var(--space-3); color: var(--text-soft); text-align: center; padding: var(--space-5) 0; }
.cfile-preview-ico { width: 56px; height: 56px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-md); background: var(--surface); }
.cfile-preview-ico svg { width: 28px; height: 28px; }
.cfile-preview-actions { display: flex; justify-content: flex-end; gap: var(--space-2); width: 100%; }
.cfile-id { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cfile-name { font-size: var(--text-sm); font-weight: var(--fw-semibold); color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cfile-meta { font-size: var(--text-xs); color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cfile-kebab { flex-shrink: 0; border-color: transparent; background: transparent; opacity: 0; transition: opacity var(--dur) var(--ease), background var(--dur) var(--ease); }
.cfile-card.sel .cfile-kebab { opacity: 1; }
@media (hover: hover) and (pointer: fine) {
  .cfile-card:hover .cfile-kebab { opacity: 1; }
}
.cfile-rename { flex: 1; min-width: 0; font-size: var(--text-sm); font-weight: var(--fw-semibold); color: var(--text); padding: 3px 7px; border: 1px solid var(--primary-400); border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--ring-primary); outline: none; }

/* context menu (reuses .filter-menu) */
.cfiles { position: relative; }
.cfile-menu { position: fixed; min-width: 184px; z-index: var(--z-popover); }
.cfile-menu-opt { justify-content: flex-start; gap: var(--space-3); }
.cfile-menu-ico { display: inline-flex; align-items: center; justify-content: center; color: var(--text-soft); }
.cfile-menu-ico svg { width: 16px; height: 16px; margin: 0; color: inherit; }
.cfile-menu-label { color: var(--text); }
.cfile-menu-opt.danger .cfile-menu-ico, .cfile-menu-opt.danger .cfile-menu-label { color: var(--danger-600); }
@media (hover: hover) and (pointer: fine) {
  .cfile-menu-opt.danger:hover { background: var(--danger-bg, color-mix(in srgb, var(--danger-600) 9%, white)); }
}
.cfile-menu-sep { height: 1px; background: var(--border); margin: 5px 4px; }
.menu-grouplabel { font-size: var(--text-xs); font-weight: var(--fw-semibold); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; padding: 4px 10px 3px; }
.lead-actions-menu .filter-opt[data-stage-set] { justify-content: space-between; }
.lead-actions-menu .filter-opt[data-stage-set] svg { width: 15px; height: 15px; color: var(--primary-600); }

/* shared two-step stage picker (table / drawer / quick-actions) */
.stage-picker { min-width: 232px; }
.sp-stage { justify-content: space-between; }
.sp-stage > svg { width: 15px; height: 15px; color: var(--primary-600); flex: none; }
.sp-caret { display: inline-flex; margin-left: auto; }
.sp-caret svg { width: 15px; height: 15px; color: var(--text-soft); }
.sp-title { display: flex; align-items: center; gap: 7px; }
.sp-title-dot { display: inline-flex; }
.sp-fu { justify-content: space-between; background: var(--gray-50); }
@media (hover: hover) and (pointer: fine) {
  .sp-fu:hover { background: var(--gray-100); }
}
.sp-fu .cfile-menu-label { white-space: nowrap; }
.sp-fu[data-fu="custom"] { background: var(--gray-50); }
@media (hover: hover) and (pointer: fine) {
  .sp-fu[data-fu="custom"]:hover { background: var(--gray-100); }
}
.sp-when { margin-left: auto; padding-left: 12px; font-size: var(--text-xs); color: var(--text-soft); font-weight: var(--fw-medium); white-space: nowrap; }
.sp-fu .sp-caret { margin-left: 0; }
.sp-back .cfile-menu-ico svg { width: 15px; height: 15px; }
/* Follow-Up custom date: the Design-System date picker, scaled down to fit */
.sp-dtp { padding: 2px 6px 6px; }
.sp-dtp .cal-area--date { min-height: 0; }
.sp-dtp .cal-head { margin-bottom: 4px; }
.sp-dtp .cal-head .month { font-size: var(--text-sm); font-weight: var(--fw-semibold); color: var(--text-strong); }
.sp-dtp .cal-nav { width: 24px; height: 24px; }
.sp-dtp .cal-nav svg { width: 15px; height: 15px; }
.sp-dtp .sched-cal { gap: 3px; }
.sp-dtp .sched-cal .dow { font-size: 10px; padding: 1px 0; }
.sp-dtp .sched-cal .day { border-radius: var(--radius-sm); font-size: var(--text-xs); }
.sched-cal .day[data-disabled] { opacity: 0.3; pointer-events: none; color: var(--text-soft); background: transparent; }

/* account dropdown (sidebar) */
.account-menu { z-index: var(--z-popover); }
.account-menu-head { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-2) var(--space-3); }
.account-menu-id { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.account-menu-name { font-size: var(--text-sm); font-weight: var(--fw-semibold); color: var(--text-strong); }
.account-menu-email { font-size: var(--text-xs); color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* drag-and-drop upload affordances */
.cfiles-grid.cfiles-dropping { outline: 2px dashed var(--primary-400); outline-offset: 4px; border-radius: var(--radius-lg); background: color-mix(in srgb, var(--primary-500) 5%, transparent); }
.cfile-card.cfiles-drop-target { background: var(--primary-50); box-shadow: inset 0 0 0 2px var(--primary-400); }

/* the empty grid centres its content like the notes empty state */
.cfiles-empty { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 56vh; padding: var(--space-6); text-align: center; }
.cfiles-empty--art { padding: var(--space-4); }
.cfiles-empty-ico { width: 52px; height: 52px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-lg); background: var(--gray-100); color: var(--text-soft); margin-bottom: var(--space-2); }
.cfiles-empty-ico svg { width: 26px; height: 26px; }
.cfiles-empty h3 { font-size: var(--text-lg); font-weight: var(--fw-semibold); color: var(--text-strong); }
.cfiles-empty p { font-size: var(--text-sm); color: var(--text-muted); }

/* (the .app-toast styles moved to styles/components.css — it's the app-wide
   toast, not a Files pattern; it only ever lived here by accident) */

/* drag-to-select marquee */
.cfiles-marquee { position: absolute; z-index: 5; border: 1px solid var(--primary-400); background: color-mix(in srgb, var(--primary-500) 12%, transparent); border-radius: var(--radius-xs); pointer-events: none; }

/* selection toolbar */
.cfiles-selbar { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: var(--z-popover); display: flex; align-items: center; gap: var(--space-4); padding: 8px 10px 8px 14px; border-radius: var(--radius-xl); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); animation: popIn var(--dur) var(--ease); }
.cfiles-selbar-count { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); color: var(--text-muted); white-space: nowrap; }
.cfiles-selbar-count b { color: var(--text-strong); font-weight: var(--fw-semibold); }
.cfiles-selbar-clear { width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); color: var(--text-soft); transition: background var(--dur) var(--ease), color var(--dur) var(--ease); }
@media (hover: hover) and (pointer: fine) {
  .cfiles-selbar-clear:hover { background: var(--nav-hover-bg); color: var(--text-strong); }
}
.cfiles-selbar-clear svg { width: 15px; height: 15px; }
.cfiles-selbar-actions { display: flex; align-items: center; gap: 6px; padding-left: var(--space-4); border-left: 1px solid var(--border); }

@media (max-width: 980px) {
  .cd-grid { grid-template-columns: 1fr; }
}
.sched-alt { height: 36px; border-radius: var(--radius-sm); color: var(--text-muted); font-size: var(--text-sm); font-weight: var(--fw-medium); transition: background var(--dur) var(--ease), color var(--dur) var(--ease); }
@media (hover: hover) and (pointer: fine) {
  .sched-alt:hover { background: var(--nav-hover-bg); color: var(--text-strong); }
}
