/* 아이티프렌드 자료실 — Berryz-style folder explorer */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #1a1d26;
  --muted: #6b7280;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --staff: #0f766e;
  --staff-hover: #0d9488;
  --danger: #dc2626;
  --row-hover: #f0f7ff;
  --folder: #f59e0b;
  --file: #64748b;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  --radius: 10px;
  --font: "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-ghost {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-ghost:hover:not(:disabled) { background: #f8fafc; }
.btn-danger {
  background: #fff;
  border-color: #fecaca;
  color: var(--danger);
  font-size: 0.8rem;
  padding: 0.25rem 0.55rem;
}
.btn-danger:hover:not(:disabled) { background: #fef2f2; }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.85rem; }
.btn-block { width: 100%; }

/* —— Gate —— */
.gate-page {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #eef2ff 0%, #f8fafc 50%, #ecfeff 100%);
}
.gate {
  text-align: center;
  padding: 2rem;
}
.gate-title {
  margin: 0 0 1.75rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: -0.02em;
}
.gate-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
}
.gate-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 180px;
  min-height: 120px;
  padding: 1.5rem 2rem;
  border-radius: 16px;
  font-size: 1.35rem;
  font-weight: 700;
  text-decoration: none;
  color: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  transition: transform 0.15s, box-shadow 0.15s;
}
.gate-btn:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(15, 23, 42, 0.16); }
.gate-btn-customer { background: linear-gradient(135deg, #2563eb, #3b82f6); }
.gate-btn-staff { background: linear-gradient(135deg, #0f766e, #14b8a6); }
.gate-btn-home { background: linear-gradient(135deg, #334155, #475569); }

/* —— Login —— */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.75rem;
  box-shadow: var(--shadow);
}
.login-card h1 {
  margin: 0.75rem 0 1.25rem;
  font-size: 1.25rem;
}
.login-card label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  font-weight: 600;
}
.login-card input {
  font: inherit;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
}
.form-error { color: var(--danger); font-size: 0.85rem; margin: 0 0 0.75rem; }

/* —— Explorer chrome —— */
.ex-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.ex-header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.ex-header-left h1 {
  margin: 0.15rem 0 0;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}
.back-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
}
.back-link:hover { color: var(--accent); }
.ex-toolbar { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.ex-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1.25rem 3rem;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.15rem;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}
.crumb {
  background: none;
  border: none;
  font: inherit;
  color: var(--accent);
  cursor: pointer;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
}
.crumb:hover { background: #eff6ff; }
.crumb-sep { color: var(--muted); user-select: none; }
.crumb-current { color: var(--text); font-weight: 600; cursor: default; }
.crumb-current:hover { background: none; }

.path-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.path-label {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: auto;
}

.ex-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.ex-table thead th {
  text-align: left;
  padding: 0.65rem 0.9rem;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
  white-space: nowrap;
  user-select: none;
}
.th-btn {
  background: none;
  border: none;
  font: inherit;
  font-weight: 600;
  color: inherit;
  cursor: pointer;
  padding: 0;
}
.th-btn:hover { color: var(--accent); }
.sortable.sort-asc .th-btn::after { content: " ▲"; font-size: 0.7em; }
.sortable.sort-desc .th-btn::after { content: " ▼"; font-size: 0.7em; }

.ex-table tbody td {
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.ex-table tbody tr:last-child td { border-bottom: none; }
.ex-table tbody tr.row-item { cursor: pointer; }
.ex-table tbody tr.row-item:hover { background: var(--row-hover); }

.col-name { width: 52%; }
.col-date { width: 22%; white-space: nowrap; color: var(--muted); }
.col-type { width: 18%; color: var(--muted); }
.col-act { width: 8%; text-align: right; }

.name-cell {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}
.name-cell .label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon svg { width: 20px; height: 20px; display: block; }
.icon-folder svg { fill: var(--folder); }
.icon-file svg { fill: var(--file); }
.icon-up svg { fill: var(--muted); }

.row-parent .label { color: var(--muted); font-weight: 500; }

.loading-cell, .empty-state {
  text-align: center;
  color: var(--muted);
  padding: 2.5rem 1rem;
}
.empty-state { margin: 1rem 0 0; }

/* Progress overlay — multi-file queue */
.progress-panel {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}
.progress-panel[hidden] {
  display: none !important;
}
.progress-inner {
  background: var(--surface);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  width: min(480px, 100%);
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.2);
}
.progress-queue {
  width: min(520px, 100%);
  max-height: min(80vh, 640px);
  display: flex;
  flex-direction: column;
}
.progress-head {
  margin-bottom: 0.75rem;
}
.progress-head #progress-label {
  margin: 0;
  font-weight: 700;
  font-size: 1.05rem;
}
.progress-summary {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
}
.upload-queue {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: auto;
  max-height: min(55vh, 420px);
  border: 1px solid #e5e7eb;
  border-radius: 10px;
}
.upload-item {
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid #f1f5f9;
}
.upload-item:last-child {
  border-bottom: 0;
}
.upload-item-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.45rem;
}
.upload-item-name {
  font-size: 0.9rem;
  font-weight: 600;
  word-break: break-all;
  line-height: 1.35;
}
.upload-item-status {
  flex-shrink: 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}
.upload-item.is-waiting .upload-item-status { color: var(--muted); }
.upload-item.is-active .upload-item-status { color: var(--accent, #2563eb); }
.upload-item.is-done .upload-item-status { color: #059669; }
.upload-item.is-error .upload-item-status { color: #dc2626; }
.upload-item .progress-track {
  height: 8px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}
.upload-item .progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #60a5fa);
  border-radius: 999px;
  transition: width 0.15s ease;
}
.upload-item.is-done .progress-bar {
  background: linear-gradient(90deg, #059669, #34d399);
  width: 100% !important;
}
.upload-item.is-error .progress-bar {
  background: #fca5a5;
}
.upload-item-pct {
  margin: 0.35rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

@media (max-width: 640px) {
  .col-type { display: none; }
  .ex-table thead th.col-type,
  .ex-table tbody td.col-type { display: none; }
  .gate-btn { min-width: 140px; min-height: 100px; font-size: 1.15rem; }
}

/* Selection / move */
.col-check {
  width: 2.25rem;
  text-align: center;
  vertical-align: middle;
}
.col-check input {
  width: 1rem;
  height: 1rem;
  cursor: pointer;
}
.row-item.selected {
  background: #eff6ff;
}
.move-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 120;
  padding: 1rem;
}
.move-modal[hidden] {
  display: none !important;
}
.move-dialog {
  background: var(--surface);
  border-radius: 12px;
  width: min(480px, 100%);
  max-height: min(80vh, 560px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.22);
  padding: 1.25rem 1.35rem 1rem;
}
.move-dialog h2 {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
}
.move-hint {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.875rem;
}
.move-crumb {
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}
.move-list {
  flex: 1;
  overflow: auto;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  min-height: 180px;
  max-height: 320px;
}
.move-folder {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
  padding: 0.65rem 0.85rem;
  border: 0;
  border-bottom: 1px solid #f1f5f9;
  background: transparent;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.move-folder:hover {
  background: #f8fafc;
}
.move-folder:last-child {
  border-bottom: 0;
}
.move-empty {
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}
.move-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.85rem;
}

.col-act {
  white-space: nowrap;
}
.col-act .btn {
  margin-left: 0.25rem;
}
.col-act .btn:first-child {
  margin-left: 0;
}

.icon-pdf svg { fill: #dc2626; }
.icon-word svg { fill: #2563eb; }
.icon-excel svg { fill: #059669; }
.icon-ppt svg { fill: #ea580c; }
.icon-image svg { fill: #7c3aed; }
.icon-zip svg { fill: #ca8a04; }
.icon-video svg { fill: #db2777; }
.icon-audio svg { fill: #0891b2; }
.icon-text svg { fill: #64748b; }
.icon-exe svg { fill: #475569; }

.upload-item-left {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  min-width: 0;
  flex: 1;
}
.upload-item-left .icon {
  flex-shrink: 0;
  margin-top: 0.1rem;
}
.upload-item-left .upload-item-name {
  flex: 1;
}

/* File list and manufacturer downloads */
.archive-columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 17.5rem;
  gap: 1.25rem;
  align-items: start;
}
.file-list { min-width: 0; }
.file-list h2 {
  margin: 0 0 0.65rem;
  font-size: 1.25rem;
  line-height: 1.4;
  letter-spacing: -0.025em;
}
.maker-group + .maker-group {
  border-top: 1px solid var(--border);
  padding-top: 0.85rem;
}
@media (max-width: 52rem) {
  .archive-columns { grid-template-columns: minmax(0, 1fr); }
}

.maker-links {
  margin: 0;
  padding: 0.9rem 1rem;
  background: #fff;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.maker-group { min-width: 0; }
.maker-title {
  margin: 0 0 0.45rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted, #64748b);
  letter-spacing: 0.02em;
}
.maker-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.maker-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  border: 1px solid #dbe3ef;
  background: #f8fafc;
  color: #0f172a;
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.2;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.maker-chip:hover {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
}
@media (max-width: 640px) {
  .maker-links { padding: 0.75rem; }
  .maker-chip { font-size: 0.78rem; }
}

.icon-img img {
  width: 20px;
  height: 20px;
  display: block;
  object-fit: contain;
  image-rendering: auto;
}

/* Staff / customer root switch */
.root-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.35rem;
  padding: 0.2rem;
  background: #f1f5f9;
  border-radius: 10px;
}
.root-switch-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 4.5rem;
  padding: 0.4rem 0.85rem;
  border-radius: 8px;
  font-size: 0.92rem;
  font-weight: 700;
  color: #64748b;
  text-decoration: none;
  border: 1px solid transparent;
}
.root-switch-btn:hover {
  color: #0f172a;
  background: #fff;
}
.root-switch-btn.is-active {
  color: #0f172a;
  background: #fff;
  border-color: #e2e8f0;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

/* —— 업체 전용자료: 고객 검색 —— */
.company-search {
  background: linear-gradient(135deg, #eff6ff 0%, #ffffff 70%);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}
.company-search-form { margin: 0; }
.company-search-label {
  display: block;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.55rem;
  color: var(--text);
}
.company-search-row { display: flex; gap: 0.5rem; }
.company-search-row input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 1rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: #fff;
}
.company-search-row input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.company-search-hint { margin: 0.5rem 0 0; font-size: 0.82rem; color: var(--muted); }
.company-search-msg {
  margin: 0.65rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}
.company-search-msg.is-error {
  color: #9a3412;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  font-weight: 600;
}
.company-active {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
  padding: 0.6rem 0.8rem;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 8px;
  font-size: 0.92rem;
  color: #065f46;
}
.company-active[hidden], .company-admin[hidden], .company-search-msg[hidden] { display: none; }
.company-active-admin { margin: 0 0 0.75rem; }

/* —— 업체 전용자료: 관리자 —— */
.btn-company-admin { border-color: var(--staff); color: var(--staff); }
.btn-company-admin[aria-expanded="true"] { background: var(--staff); color: #fff; }
.company-admin {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--staff);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}
.company-admin-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.company-admin-head h2 { margin: 0; font-size: 1.05rem; letter-spacing: -0.02em; }
.company-admin-desc { margin: 0.4rem 0 0.8rem; font-size: 0.83rem; color: var(--muted); }
.company-create-form { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.75rem; }
.company-create-form input {
  flex: 1 1 200px;
  min-width: 0;
  font: inherit;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
}
.company-table td.col-act { white-space: nowrap; }
.company-table .company-aliases { color: var(--muted); font-size: 0.85rem; }
.company-table tbody tr { cursor: default; }

@media (max-width: 640px) {
  .company-search-row { flex-direction: column; }
  .company-search-row .btn { width: 100%; }
}

.btn[hidden] { display: none; }
