/* TEF Consult File Portal — shared design system */

:root {
  --navy-900: #0f2647;
  --navy-800: #17365d;
  --navy-700: #1f4e78;
  --navy-600: #2c6497;
  --gold-500: #c9982f;
  --gold-600: #b0801f;
  --bg: #f3f5f9;
  --surface: #ffffff;
  --border: #e3e8ef;
  --text: #1c2531;
  --text-muted: #64748b;
  --danger: #b42318;
  --danger-bg: #fdeceb;
  --success-bg: #eaf7ee;
  --success-text: #1e6b3a;
  --error-bg: #fdeceb;
  --error-text: #8a1c1c;
  --warning-bg: #fef6e7;
  --warning-text: #8a5a00;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 38, 71, 0.06);
  --shadow-md: 0 8px 30px rgba(15, 38, 71, 0.08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --surface: #121b2d;
    --border: #23324a;
    --text: #e7edf6;
    --text-muted: #93a2ba;
    --success-bg: #103a20;
    --success-text: #7fe3a4;
    --error-bg: #3a1414;
    --error-text: #ff9c92;
    --warning-bg: #3a2c0c;
    --warning-text: #f0c25c;
    --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
}

a { color: inherit; }

/* ---------- Login page ---------- */

.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
}

@media (max-width: 860px) {
  .login-page { grid-template-columns: 1fr; }
  .login-hero { display: none; }
}

.login-hero {
  background: linear-gradient(155deg, var(--navy-900), var(--navy-700) 65%, var(--navy-600));
  color: #fff;
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.login-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 85% 15%, rgba(201, 152, 47, 0.25), transparent 45%),
    radial-gradient(circle at 10% 90%, rgba(255, 255, 255, 0.08), transparent 40%);
}

.login-hero > * { position: relative; z-index: 1; }

.hero-mark {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.02em;
}

.brand-logo {
  height: 40px;
  width: auto;
  display: block;
  border-radius: 6px;
  background: #fff;
  padding: 4px;
}

.hero-copy h1 {
  font-size: clamp(28px, 3.4vw, 40px);
  line-height: 1.15;
  margin: 0 0 16px;
  max-width: 480px;
}

.hero-copy p {
  color: rgba(255, 255, 255, 0.78);
  max-width: 420px;
  line-height: 1.6;
}

.hero-features {
  list-style: none;
  padding: 0;
  margin: 28px 0 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 14px;
}

.hero-features li { display: flex; align-items: center; gap: 10px; }
.hero-features li::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--gold-500);
  flex: none;
}

.hero-footer {
  color: rgba(255, 255, 255, 0.55);
  font-size: 13px;
}

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

.login-card {
  width: 100%;
  max-width: 400px;
}

.login-card .mobile-mark {
  display: none;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--navy-800);
  margin-bottom: 28px;
}

@media (max-width: 860px) {
  .login-card .mobile-mark { display: flex; }
}

.login-card h2 {
  margin: 0 0 6px;
  font-size: 24px;
  color: var(--text);
}

.login-card .sub {
  color: var(--text-muted);
  margin-bottom: 28px;
  font-size: 14.5px;
}

.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-weight: 600;
  font-size: 13.5px;
  margin-bottom: 6px;
  color: var(--text);
}

.field input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus {
  outline: none;
  border-color: var(--navy-600);
  box-shadow: 0 0 0 3px rgba(31, 78, 120, 0.15);
}

.login-submit {
  width: 100%;
  padding: 13px;
  margin-top: 6px;
  border: 0;
  border-radius: 9px;
  background: var(--navy-800);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.login-submit:hover { background: var(--navy-700); }

.login-alert {
  background: var(--error-bg);
  color: var(--error-text);
  padding: 11px 14px;
  border-radius: 9px;
  font-size: 14px;
  margin-bottom: 18px;
}

.login-foot {
  margin-top: 28px;
  font-size: 12.5px;
  color: var(--text-muted);
  text-align: center;
}

/* ---------- App shell ---------- */

.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  height: 62px;
  background: var(--navy-800);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 30;
  box-shadow: var(--shadow-sm);
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; white-space: nowrap; }
.brand .brand-logo { height: 30px; }
.brand-name { font-size: 15.5px; }
@media (max-width: 560px) { .brand-name { display: none; } }

.search { flex: 1; display: flex; max-width: 480px; margin: 0 auto 0 12px; }
.search input {
  flex: 1;
  padding: 9px 14px;
  border-radius: 8px 0 0 8px;
  border: 0;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}
.search input::placeholder { color: rgba(255, 255, 255, 0.65); }
.search input:focus { outline: none; background: #fff; color: var(--text); }
.search input:focus::placeholder { color: var(--text-muted); }
.search button {
  border: 0;
  padding: 0 14px;
  border-radius: 0 8px 8px 0;
  background: var(--navy-600);
  color: #fff;
  cursor: pointer;
}

.icon-btn.only-mobile { display: none; background: none; border: 0; color: #fff; font-size: 20px; cursor: pointer; }
@media (max-width: 860px) { .icon-btn.only-mobile { display: block; } }

.user-menu { position: relative; margin-left: auto; }
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--gold-500);
  color: var(--navy-900);
  display: grid;
  place-items: center;
  font-weight: 800;
  cursor: pointer;
}
.user-dropdown {
  position: absolute;
  right: 0;
  top: 46px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  padding: 14px;
  min-width: 200px;
  display: none;
  z-index: 40;
}
.user-menu.open .user-dropdown { display: block; }
.user-dropdown .user-name { font-weight: 700; }
.user-dropdown a, .user-dropdown .link-btn {
  display: block;
  margin-top: 10px;
  font-size: 14px;
  text-decoration: none;
  color: var(--navy-700);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-align: left;
}
.user-dropdown .link-btn { color: var(--danger); font-weight: 600; }

.body { flex: 1; display: flex; min-height: 0; }

.sidebar {
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 12px;
  flex: none;
}

.sidebar-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 0 10px 10px;
  font-weight: 700;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin: 2px 0;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  font-size: 14.5px;
  font-weight: 500;
}
.nav-item:hover { background: var(--bg); }
.nav-item.active { background: rgba(31, 78, 120, 0.1); color: var(--navy-700); font-weight: 700; }
.nav-icon { font-size: 16px; }

.sidebar-footer {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.sidebar-footer a {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 14px;
}
.sidebar-footer a:hover { background: var(--bg); color: var(--text); }

.sidebar-backdrop { display: none; }

@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    top: 62px; bottom: 0; left: 0;
    z-index: 25;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-md);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop {
    display: none;
    position: fixed; inset: 62px 0 0 0;
    background: rgba(0,0,0,0.35);
    z-index: 20;
  }
  .sidebar-backdrop.open { display: block; }
}

.content { flex: 1; padding: 24px; min-width: 0; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.breadcrumbs { font-size: 14.5px; color: var(--text-muted); display: flex; align-items: center; flex-wrap: wrap; }
.breadcrumbs a { text-decoration: none; color: var(--navy-700); font-weight: 600; }
.breadcrumbs a:hover { text-decoration: underline; }
.breadcrumbs .sep { margin: 0 8px; color: var(--border); }
.breadcrumbs .current { color: var(--text); font-weight: 700; }

.toolbar { display: flex; gap: 10px; }

.btn {
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:hover { background: var(--bg); }
.btn.primary { background: var(--navy-800); border-color: var(--navy-800); color: #fff; }
.btn.primary:hover { background: var(--navy-700); }
.btn.secondary { background: transparent; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }

.search-context {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 14px;
  font-size: 13.5px;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.search-context a { color: var(--navy-700); font-weight: 600; text-decoration: none; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.file-table { width: 100%; border-collapse: collapse; }
.file-table th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 12px 18px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-weight: 700;
}
.file-table td {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  vertical-align: middle;
}
.file-table tr:last-child td { border-bottom: 0; }
.file-table tr:hover td { background: rgba(31, 78, 120, 0.03); }

.name-cell { display: table-cell; }
.item-link { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); font-weight: 600; }
.item-link:hover { color: var(--navy-700); }

.muted { color: var(--text-muted); }
.small { font-size: 12px; }

.icon { width: 22px; height: 22px; flex: none; display: inline-block; position: relative; }

.icon-folder {
  background: var(--gold-500);
  clip-path: polygon(0 15%, 40% 15%, 50% 28%, 100% 28%, 100% 85%, 0 85%);
  border-radius: 2px;
}

.icon-file {
  background: #9aa8bd;
  clip-path: polygon(20% 0, 70% 0, 100% 25%, 100% 100%, 20% 100%);
}
.icon-file::after {
  content: "";
  position: absolute;
  top: 0; right: 0;
  width: 30%; height: 25%;
  background: rgba(255, 255, 255, 0.55);
  clip-path: polygon(0 0, 100% 100%, 0 100%);
}

.badge-pdf { background: #d64545; }
.badge-doc { background: #2b6cb0; }
.badge-sheet { background: #1e8e5a; }
.badge-slide { background: #d97a1f; }
.badge-image { background: #7c53d0; }
.badge-archive { background: #6b7280; }
.badge-video { background: #c2185b; }
.badge-audio { background: #0d9488; }
.badge-text { background: #64748b; }
.badge-code { background: #17365d; }
.badge-file { background: #9aa8bd; }

.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.row-actions form { display: inline; }

.icon-btn {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  width: 32px; height: 32px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 15px;
  display: inline-grid;
  place-items: center;
  text-decoration: none;
}
.icon-btn:hover { background: var(--bg); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-bg); color: var(--danger); }

.empty-state { padding: 64px 24px; text-align: center; color: var(--text-muted); }
.empty-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.6; }

.toast {
  padding: 12px 16px;
  border-radius: 9px;
  margin-bottom: 14px;
  font-size: 14px;
  font-weight: 500;
}
.toast.success { background: var(--success-bg); color: var(--success-text); }
.toast.error { background: var(--error-bg); color: var(--error-text); }
.toast.warning { background: var(--warning-bg); color: var(--warning-text); }
.toast.info, .toast.debug { background: var(--bg); color: var(--text-muted); }

/* ---------- Modals ---------- */

.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 20, 35, 0.5);
  z-index: 50;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-md);
}
.modal h3 { margin: 0 0 16px; font-size: 18px; }
.modal label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 6px; }
.modal input[type=text], .modal input[type=file] {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  margin-bottom: 6px;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.modal.modal-large {
  max-width: min(960px, 100%);
  width: 100%;
  height: min(80vh, 800px);
  display: flex;
  flex-direction: column;
  padding: 16px 16px 20px;
}
.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.preview-head h3 { margin: 0; font-size: 16px; word-break: break-all; }
.preview-body {
  flex: 1;
  min-height: 0;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  overflow: auto;
  display: flex;
}
.preview-message {
  margin: auto;
  color: var(--text-muted);
  font-size: 14px;
  padding: 40px;
  text-align: center;
}
.preview-image {
  max-width: 100%;
  max-height: 100%;
  margin: auto;
  object-fit: contain;
}
.preview-pdf { width: 100%; height: 100%; border: 0; }
.preview-text {
  width: 100%;
  margin: 0;
  padding: 14px 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}
.preview-sheet-wrap { width: 100%; overflow: auto; }
.preview-sheet { border-collapse: collapse; font-size: 13px; }
.preview-sheet th, .preview-sheet td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  white-space: nowrap;
  text-align: left;
}
.preview-sheet th {
  background: var(--surface);
  font-weight: 600;
  position: sticky;
  top: 0;
}

/* ---------- Preview: header actions, sheet tabs, documents, media ---------- */
.preview-head-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.preview-head-actions .btn { padding: 6px 12px; font-size: 13px; white-space: nowrap; }
[hidden] { display: none !important; }

.preview-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin-bottom: 8px;
  padding-bottom: 2px;
}
.preview-tab {
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.preview-tab.active {
  background: var(--navy-800);
  border-color: var(--navy-800);
  color: #fff;
}

.preview-doc {
  width: 100%;
  padding: 18px 22px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}
.preview-doc h4 { margin: 18px 0 8px; font-size: 15px; color: var(--navy-700); }
.preview-doc h4:first-child { margin-top: 0; }
.preview-doc p { margin: 0 0 10px; }
.preview-doc .preview-sheet-wrap { margin: 12px 0 16px; }
.preview-slide {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px 16px;
  margin-bottom: 12px;
}

.preview-video { width: 100%; max-height: 100%; margin: auto; background: #000; }
.preview-audio { width: 100%; margin: auto; padding: 0 20px; }
.preview-note { width: 100%; padding: 10px 16px; border-top: 1px solid var(--border); }

/* ---------- Delete confirmation ---------- */
.delete-head { display: flex; align-items: flex-start; gap: 10px; }
.delete-head h3 { margin: 0 0 12px; font-size: 17px; line-height: 1.35; }
.delete-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--danger-bg);
  color: var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
}
.delete-target {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 8px;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  word-break: break-all;
}
.delete-detail { margin: 0 0 10px; }
.delete-warning {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
}
