@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable.css');

:root {
  --color-primary: #5E4C8A;
  --color-primary-dark: #473966;
  --color-primary-light: #EFEAF7;
  --color-secondary: #0F4C82;
  --color-bg: #F4F6F8;
  --color-surface: #FFFFFF;
  --color-border: #E5E8EB;
  --color-text: #1E1E23;
  --color-text-muted: #767678;
  --color-danger: #E0433D;
  --color-danger-bg: #FDEBEA;
  --color-success: #1B8A5A;
  --color-success-bg: #E7F6EF;

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px rgba(30, 20, 50, 0.05);
  --shadow-md: 0 4px 16px rgba(30, 20, 50, 0.08);
  --shadow-lg: 0 12px 32px rgba(30, 20, 50, 0.14);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  letter-spacing: -0.01em;
  background: var(--color-bg);
  color: var(--color-text);
}

/* ---------- Top nav ---------- */
.topnav {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 60px;
  padding: 0 20px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topnav .brand-logo { height: 28px; display: block; }
.topnav .nav-links { display: flex; align-items: center; gap: 4px; margin-left: 8px; }
.topnav .nav-link {
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-decoration: none;
  transition: background 120ms ease, color 120ms ease;
}
.topnav .nav-link:hover { background: var(--color-primary-light); color: var(--color-primary); }
.topnav .nav-link.active { background: var(--color-primary-light); color: var(--color-primary); }
.topnav .nav-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.topnav .user-email { font-size: 13px; color: var(--color-text-muted); font-weight: 600; }
.topnav .role-badge {
  font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: var(--radius-full);
  background: var(--color-primary-light); color: var(--color-primary);
}

/* ---------- Shell / layout ---------- */
.shell { width: min(1080px, 100%); margin: 0 auto; padding: 24px 20px 60px; }
.shell-with-sidebar {
  width: min(1280px, 100%);
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  align-items: start;
  gap: 20px;
}
.main-content { min-width: 0; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.page-header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.page-title { font-size: 20px; font-weight: 800; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 480px; }
.page-desc { font-size: 13px; color: var(--color-text-muted); margin: 4px 0 0; }
.bulk-count { font-weight: 800; }

/* ---------- Folder sidebar (자료실) ---------- */
.folder-sidebar {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 14px;
  position: sticky;
  top: 80px;
}
.folder-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 800;
  color: var(--color-text-muted);
  padding: 4px 6px 10px;
}
.folder-add-btn { padding: 4px 6px; }
.folder-list { display: flex; flex-direction: column; gap: 2px; }
.folder-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  border-radius: var(--radius-md);
  padding: 2px;
  transition: background 120ms ease;
}
.folder-item:hover { background: var(--color-bg); }
.folder-item.active { background: var(--color-primary-light); }
.folder-item.active .folder-item-name { color: var(--color-primary); }
.folder-item-name {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 8px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text);
  cursor: pointer;
}
.folder-item-name svg { flex: none; color: var(--color-text-muted); }
.folder-item.active .folder-item-name svg { color: var(--color-primary); }
.folder-item-name span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-item-actions { display: flex; align-items: center; gap: 2px; flex: none; }
.folder-action-btn {
  width: 24px; height: 24px; flex: none;
  display: grid; place-items: center;
  border: 0; background: transparent; border-radius: var(--radius-sm);
  color: var(--color-text-muted); cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}
.folder-action-btn:hover { background: var(--color-primary-light); color: var(--color-primary); }
.folder-action-btn.folder-action-danger:hover { background: var(--color-danger-bg); color: var(--color-danger); }
.empty-state-sm { padding: 16px 8px; text-align: center; color: var(--color-text-muted); font-size: 12px; }

/* ---------- Sort select ---------- */
.sort-select { width: auto; padding: 9px 30px 9px 12px; font-size: 13px; font-weight: 600; }

/* ---------- Card ---------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-padded { padding: 20px; }

/* ---------- Buttons ---------- */
.btn {
  font: 700 14px/1 inherit;
  letter-spacing: -0.01em;
  border-radius: var(--radius-md);
  padding: 10px 16px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  cursor: pointer;
  transition: background 120ms ease, transform 80ms ease, box-shadow 120ms ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-secondary { background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); }
.btn-secondary:hover { border-color: var(--color-primary); color: var(--color-primary); }
.btn-ghost { background: transparent; color: var(--color-primary); padding: 8px 10px; }
.btn-ghost:hover { background: var(--color-primary-light); }
.btn-danger { background: var(--color-danger-bg); color: var(--color-danger); }
.btn-danger:hover { background: var(--color-danger); color: #fff; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Inputs ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 700; color: var(--color-text); }
.input {
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 11px 14px;
  font-size: 14px;
  font-family: inherit;
  color: var(--color-text);
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
  width: 100%;
}
.input:focus { border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-light); }
.input::placeholder { color: #B3B3B8; }
textarea.input { resize: vertical; min-height: 90px; }
select.input { appearance: none; }

/* ---------- Login page ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(160deg, #F4F6F8 0%, #ECE7F5 100%);
}
.login-card {
  width: min(400px, 100%);
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px 32px 32px;
  text-align: center;
}
.login-card .logo-img { height: 46px; margin: 0 auto 20px; display: block; }
.brand-heading { margin: 0 0 6px; }
.brand-heading-title {
  margin: 0;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--color-text);
  font-family: 'Pretendard Variable', Pretendard, sans-serif;
}
.brand-heading-accent {
  background: linear-gradient(120deg, var(--color-primary) 0%, var(--color-secondary) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.login-card .login-sub { font-size: 13px; color: var(--color-text-muted); margin: 14px 0 26px; }
.login-form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.login-search-input {
  border: 2px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.login-search-input:focus-within { border-color: var(--color-primary); box-shadow: 0 4px 14px rgba(94,76,138,.14); }
.login-search-input svg { flex: none; color: var(--color-text-muted); }
.login-search-input input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; padding: 12px 0; font-size: 14px; font-family: inherit; }
.login-error {
  display: none;
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
}
.login-footer { margin-top: 22px; font-size: 12px; color: #B3B3B8; }

/* ---------- File list ---------- */
.file-list { display: flex; flex-direction: column; }
.file-item:last-child .file-row { border-bottom: none; }
.file-item:not(:last-child) { border-bottom: 1px solid var(--color-border); }
.file-row {
  display: grid;
  grid-template-columns: 28px 1fr 140px 180px 100px;
  gap: 12px;
  align-items: center;
  padding: 16px 20px;
}
.file-row:hover { background: #FAFAFB; }
.file-select-wrap, .file-select-all-wrap { display: flex; align-items: center; }
.file-checkbox, #select-all-checkbox {
  width: 17px; height: 17px; accent-color: var(--color-primary); cursor: pointer;
}
.file-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.file-icon {
  width: 38px; height: 38px; flex: none; border-radius: var(--radius-md);
  display: grid; place-items: center; font-size: 11px; font-weight: 800;
  background: var(--color-primary-light); color: var(--color-primary);
}
.file-icon.docx { background: #E5EEF7; color: var(--color-secondary); }
.file-icon.hwp { background: #E7F0FE; color: #1B5FCB; }
.file-icon.pdf { background: var(--color-danger-bg); color: var(--color-danger); }
.file-icon.ppt { background: #FDECE7; color: #C6521A; }
.file-info { min-width: 0; }
.file-name { font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-memo-btn {
  margin-top: 3px;
  border: 0; background: transparent; padding: 0; cursor: pointer;
  font-size: 12px; color: var(--color-text-muted); display: inline-flex; align-items: center; gap: 4px;
}
.file-memo-btn:hover { color: var(--color-primary); }
.file-memo-btn .memo-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--color-primary); }
.file-uploader { font-size: 13px; color: var(--color-text-muted); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-date { font-size: 13px; color: var(--color-text-muted); font-weight: 600; }
.file-actions { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.file-list-head {
  display: grid;
  grid-template-columns: 28px 1fr 140px 180px 100px;
  gap: 12px;
  padding: 12px 20px;
  font-size: 12px;
  font-weight: 800;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
}
.empty-state { padding: 60px 20px; text-align: center; color: var(--color-text-muted); }
.empty-state svg { color: var(--color-border); margin-bottom: 12px; }

/* ---------- Inline memo editor ---------- */
.memo-editor {
  padding: 0 20px 18px 68px;
  background: #FAFAFB;
}
.memo-editor textarea { min-height: 70px; }
.memo-editor-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.memo-editor .modal-memo-view { margin-top: 4px; }

/* ---------- Pagination ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 16px 20px;
  border-top: 1px solid var(--color-border);
}
.page-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.page-btn:hover:not(:disabled) { border-color: var(--color-primary); color: var(--color-primary); }
.page-btn.active { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- Drag and drop upload zone ---------- */
.drop-zone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: 28px 16px;
  text-align: center;
  cursor: pointer;
  color: var(--color-text-muted);
  transition: border-color 120ms ease, background 120ms ease;
}
.drop-zone svg { color: var(--color-primary); margin-bottom: 8px; }
.drop-zone-text { font-size: 13px; font-weight: 600; color: var(--color-text); }
.drop-zone-link { color: var(--color-primary); text-decoration: underline; }
.drop-zone-sub { font-size: 12px; color: var(--color-text-muted); margin-top: 6px; }
.drop-zone:hover, .drop-zone.drag-over { border-color: var(--color-primary); background: var(--color-primary-light); }

.selected-file-list { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; max-height: 160px; overflow-y: auto; }
.selected-file-chip {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 12px; background: var(--color-bg); border-radius: var(--radius-md); font-size: 13px;
}
.selected-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.selected-file-remove {
  border: 0; background: transparent; cursor: pointer; color: var(--color-text-muted);
  font-size: 16px; line-height: 1; flex: none; padding: 0 4px;
}
.selected-file-remove:hover { color: var(--color-danger); }

/* ---------- Password change modal ---------- */
.password-error {
  display: none;
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 14px;
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20, 15, 30, 0.45);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-box {
  width: min(480px, 100%);
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-title { font-size: 16px; font-weight: 800; margin: 0 0 4px; }
.modal-sub { font-size: 12px; color: var(--color-text-muted); margin: 0 0 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.modal-memo-view { white-space: pre-wrap; font-size: 14px; line-height: 1.6; background: var(--color-bg); border-radius: var(--radius-md); padding: 14px; min-height: 60px; color: var(--color-text); }

/* ---------- Folder permission modal ---------- */
.permission-user-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 6px;
}
.permission-user-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms ease;
}
.permission-user-item:hover { background: var(--color-bg); }
.permission-user-item input { width: 16px; height: 16px; accent-color: var(--color-primary); cursor: pointer; flex: none; }
.permission-user-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Table (admin users) ---------- */
.user-table { width: 100%; border-collapse: collapse; }
.user-table th {
  text-align: left; font-size: 12px; font-weight: 800; color: var(--color-text-muted);
  padding: 12px 16px; border-bottom: 1px solid var(--color-border);
}
.user-table td { padding: 14px 16px; border-bottom: 1px solid var(--color-border); font-size: 14px; }
.user-table tr:last-child td { border-bottom: none; }
.role-tag { font-size: 11px; font-weight: 800; padding: 3px 9px; border-radius: var(--radius-full); }
.role-tag.admin { background: var(--color-primary-light); color: var(--color-primary); }
.role-tag.user { background: #F0F0F2; color: var(--color-text-muted); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(10px);
  background: var(--color-text); color: #fff; padding: 12px 20px; border-radius: var(--radius-md);
  font-size: 13px; font-weight: 600; box-shadow: var(--shadow-lg); z-index: 200;
  opacity: 0; pointer-events: none; transition: opacity 180ms ease, transform 180ms ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--color-danger); }

@media (max-width: 900px) {
  .shell-with-sidebar { grid-template-columns: 1fr; }
  .folder-sidebar { position: static; }
}

@media (max-width: 720px) {
  .file-row, .file-list-head { grid-template-columns: 24px 1fr 90px; }
  .file-uploader, .file-date { display: none; }
  .topnav .nav-links { display: none; }
  .topnav .user-email { display: none; }
  .memo-editor { padding-left: 20px; }
  .page-title { max-width: 200px; }
}
