@import url("/styles.css");

:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #fff;
  background: #000;
  --gold: #e0bb43;
  --blue: #2563eb;
  --indigo: #4f46e5;
  --green: #4ade80;
  --red: #f87171;
  --muted: #9ca3af;
  --line: rgba(255,255,255,.1);
}

html, body { min-height: 100%; margin: 0; overflow: auto; }
body { background: radial-gradient(circle at 78% 8%, rgba(37,99,235,.32), transparent 34%), linear-gradient(to bottom right, #000, #1e3a8a) fixed; }
button, input { font: inherit; }
button, a { color: inherit; }
[hidden] { display: none !important; }

.admin-shell { min-height: 100vh; }
.login-view { display: grid; min-height: 100vh; place-items: center; padding: 28px; }
.login-card { display: grid; width: min(100%, 460px); gap: 17px; padding: 38px; border: 1px solid var(--line); border-radius: 14px; background: rgba(5,10,20,.86); box-shadow: 0 30px 90px rgba(0,0,0,.4); backdrop-filter: blur(18px); }
.login-card > img { width: 245px; max-width: 85%; margin-bottom: 8px; }
.eyebrow { color: #8faaff; font-size: 11px; font-weight: 800; letter-spacing: .16em; }
.login-card h1, .upload-card h1 { margin: 0; font-size: clamp(32px, 5vw, 48px); letter-spacing: -.045em; }
.login-card > p, .upload-card p { margin: -7px 0 4px; color: var(--muted); font-size: 15px; line-height: 1.6; }
.login-card label { display: grid; gap: 8px; color: #c8ced9; font-size: 13px; font-weight: 700; }
.login-card input { min-height: 48px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 9px; outline: none; background: rgba(255,255,255,.045); color: white; }
.login-card input:focus { border-color: rgba(79,124,255,.8); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.primary-button { min-height: 49px; border: 0; border-radius: 9px; background: linear-gradient(90deg, var(--blue), var(--indigo)); color: white; font-size: 13px; font-weight: 800; letter-spacing: .08em; cursor: pointer; }
.primary-button:disabled { opacity: .55; cursor: wait; }
.form-message { min-height: 18px; color: #ffb0b5; font-size: 13px; }
.back-link { justify-self: center; color: var(--muted); font-size: 13px; text-decoration: none; }
.back-link:hover { color: white; }

.admin-header { display: flex; align-items: center; gap: 13px; min-height: 82px; padding: 14px max(24px, calc((100% - 1180px) / 2)); border-bottom: 1px solid var(--line); background: rgba(0,0,0,.55); backdrop-filter: blur(16px); }
.admin-header img { width: 185px; }
.header-title { margin-right: auto; padding-left: 17px; border-left: 1px solid var(--line); }
.header-title strong, .header-title span { display: block; }
.header-title strong { font-size: 15px; }
.header-title span { margin-top: 3px; color: var(--muted); font-size: 12px; }
.quiet-button, .refresh-button { display: inline-flex; align-items: center; justify-content: center; min-height: 39px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.045); color: #dce1e9; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-decoration: none; cursor: pointer; }
.quiet-button:hover, .refresh-button:hover { background: rgba(255,255,255,.09); }

.admin-content { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 44px 0 70px; }
.prompt-card { margin-bottom: 20px; padding: 25px; border: 1px solid var(--line); border-radius: 12px; background: rgba(0,0,0,.82); box-shadow: inset 0 1px 0 rgba(255,255,255,.025); }
.prompt-heading { margin-bottom: 16px; }
.prompt-heading h2 { margin: 5px 0 0; font-size: 23px; }
.prompt-heading p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.prompt-save { min-width: 118px; padding: 10px 18px; }
#system-prompt,
#developer-system-prompt { display: block; box-sizing: border-box; width: 100%; min-height: 190px; resize: vertical; padding: 17px; border: 1px solid rgba(255,255,255,.15); border-radius: 9px; outline: none; background: #000; color: #fff; font: 14px/1.65 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; caret-color: white; }
#system-prompt:focus,
#developer-system-prompt:focus { border-color: rgba(79,124,255,.9); box-shadow: 0 0 0 3px rgba(37,99,235,.16); }
.developer-prompt-card { border-color: rgba(79,124,255,.28); }
.prompt-footer { display: flex; justify-content: space-between; gap: 15px; margin-top: 9px; color: var(--muted); font-size: 11px; }
.upload-card { display: flex; align-items: center; justify-content: space-between; gap: 28px; padding: 30px; border: 1px solid var(--line); border-radius: 12px; background: rgba(65,65,25,.05); backdrop-filter: blur(12px); }
.upload-card p { max-width: 680px; margin-top: 8px; }
.knowledge-actions { display: grid; flex: 0 0 min(100%, 360px); gap: 10px; }
.folder-picker { display: grid; gap: 6px; }
.folder-picker > span { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .12em; }
.folder-picker select { box-sizing: border-box; width: 100%; min-height: 44px; padding: 8px 36px 8px 12px; border: 1px solid var(--line); border-radius: 9px; outline: none; background: #071126; color: white; cursor: pointer; }
.folder-picker select:focus { border-color: rgba(79,124,255,.8); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.folder-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.folder-button { min-height: 38px; padding: 8px 10px; border: 1px solid rgba(79,124,255,.3); border-radius: 8px; background: rgba(79,124,255,.09); color: #b7c7ff; font-size: 10px; font-weight: 800; letter-spacing: .05em; cursor: pointer; }
.folder-button:hover { border-color: rgba(79,124,255,.65); background: rgba(79,124,255,.16); }
.folder-button.danger { border-color: rgba(248,113,113,.25); background: rgba(248,113,113,.07); color: #ff9ea6; }
.folder-button.danger:hover { border-color: rgba(248,113,113,.55); background: rgba(248,113,113,.14); }
.folder-button:disabled { opacity: .4; cursor: not-allowed; }
.upload-button { display: flex; flex: 0 0 auto; align-items: center; gap: 10px; min-height: 54px; padding: 12px 20px; border: 1px solid rgba(224,187,67,.4); border-radius: 10px; background: rgba(224,187,67,.1); color: #f4d76f; font-size: 12px; font-weight: 800; letter-spacing: .08em; cursor: pointer; }
.upload-button span { font-size: 25px; line-height: .7; }
.upload-button:hover { border-color: rgba(224,187,67,.8); background: rgba(224,187,67,.17); }
.upload-button:disabled { opacity: .5; cursor: wait; }

.upload-progress { margin-top: 14px; padding: 15px 18px; border: 1px solid rgba(79,124,255,.34); border-radius: 10px; background: rgba(8,13,23,.88); }
.upload-progress > div:first-child { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.upload-progress strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-progress span { color: var(--muted); font-size: 12px; white-space: nowrap; }
.progress-track { height: 5px; margin-top: 11px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.07); }
.progress-track i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), var(--indigo)); transition: width .3s ease; }

.documents-card { margin-top: 20px; padding: 25px; border: 1px solid var(--line); border-radius: 12px; background: rgba(5,10,20,.76); backdrop-filter: blur(14px); }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 17px; }
.section-heading h2 { margin: 0; font-size: 23px; }
.section-heading p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.documents-list { display: grid; gap: 10px; }
.admin-document { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 17px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.025); }
.document-main { min-width: 0; }
.document-line { display: flex; align-items: center; gap: 10px; }
.document-line strong { overflow: hidden; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.status-pill { flex: 0 0 auto; padding: 4px 8px; border-radius: 999px; background: rgba(79,124,255,.13); color: #9eb5ff; font-size: 10px; font-weight: 800; }
.status-pill.ready { background: rgba(74,222,128,.1); color: var(--green); }
.status-pill.error { background: rgba(248,113,113,.1); color: #ff9ea6; }
.document-meta { display: flex; flex-wrap: wrap; gap: 7px 15px; margin-top: 7px; color: var(--muted); font-size: 11px; }
.document-progress { height: 4px; margin-top: 10px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.07); }
.document-progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--blue), var(--indigo)); }
.admin-document.ready .document-progress i { background: linear-gradient(90deg, #20935c, var(--green)); }
.delete-button { min-height: 38px; padding: 8px 13px; border: 1px solid rgba(248,113,113,.25); border-radius: 8px; background: rgba(248,113,113,.08); color: #ff9ea6; font-size: 11px; font-weight: 800; cursor: pointer; }
.delete-button:hover { border-color: rgba(248,113,113,.55); background: rgba(248,113,113,.15); }
.delete-button:disabled { opacity: .4; cursor: not-allowed; }
.empty-state { padding: 45px 20px; color: var(--muted); text-align: center; }
.trash-note { margin: 15px 4px 0; color: var(--muted); font-size: 11px; text-align: center; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 20; max-width: 420px; padding: 13px 16px; border: 1px solid rgba(79,124,255,.3); border-radius: 10px; background: #071126; color: white; font-size: 13px; opacity: 0; transform: translateY(8px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }

.password-dialog { width: min(92vw, 520px); padding: 0; border: 1px solid var(--line); border-radius: 14px; background: #070d19; color: white; box-shadow: 0 35px 100px rgba(0,0,0,.7); }
.password-dialog::backdrop { background: rgba(0,0,0,.72); backdrop-filter: blur(6px); }
.password-form { display: grid; gap: 16px; padding: 28px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.dialog-heading h2 { margin: 5px 0 0; font-size: 25px; }
.dialog-close { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 50%; background: rgba(255,255,255,.04); color: var(--muted); font-size: 25px; line-height: 1; cursor: pointer; }
.password-form > p { margin: -5px 0 2px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.password-form label { display: grid; gap: 8px; color: #c8ced9; font-size: 13px; font-weight: 700; }
.password-form input { min-height: 46px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; outline: none; background: rgba(255,255,255,.045); color: white; }
.password-form input:focus { border-color: rgba(79,124,255,.8); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }
.dialog-actions .primary-button { padding: 10px 17px; }

@media (max-width: 760px) {
  .admin-header { flex-wrap: wrap; padding-inline: 18px; }
  .admin-header img { width: 150px; }
  .header-title { order: 3; width: 100%; padding: 8px 0 0; border: 0; border-top: 1px solid var(--line); }
  .admin-content { width: min(100% - 24px, 1180px); padding-top: 25px; }
  .upload-card { align-items: stretch; flex-direction: column; padding: 22px; }
  .knowledge-actions { flex-basis: auto; }
  .prompt-heading { align-items: stretch; flex-direction: column; }
  .prompt-save { width: 100%; }
  .upload-button { justify-content: center; }
  .admin-document { grid-template-columns: 1fr; }
  .delete-button { justify-self: start; }
  .password-form { padding: 22px; }
  .dialog-actions { align-items: stretch; flex-direction: column-reverse; }
}
