/*
 * Academic Research Portal - Stylesheet
 * Created by IT Students
 * Light academic theme: warm paper background + ink-blue accent + serif headings
 */

/* load the fonts (serif for headings, clean sans for the rest) */
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@500;600;700&family=Inter:wght@400;500;600;700&display=swap');

/* ==================== */
/* Colors (one place)   */
/* ==================== */
:root {
    --paper: #faf8f4;          /* warm off-white background */
    --surface: #ffffff;        /* white cards */
    --surface-soft: #f3f0e9;   /* sunken panels */
    --ink: #1a1816;            /* main text (almost black) */
    --ink-soft: #4a463f;       /* body text */
    --muted: #857f74;          /* small / caption text */
    --rule: #e4dfd4;           /* hairline borders */
    --rule-strong: #d4cdbe;
    --primary: #1e3a5f;        /* ink-blue accent */
    --primary-hover: #16304f;
    --primary-soft: #e6ecf3;   /* tinted background for chips */
    --gold: #a07e2e;           /* rare highlight */
    --success: #2d6a4f;
    --success-soft: #e6f0ea;
    --error: #a13d3d;
    --error-soft: #f6e9e9;
}

/* ==================== */
/* Base                 */
/* ==================== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', system-ui, sans-serif;
    background-color: var(--paper);
    color: var(--ink);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

h1, h2, h3 { font-family: 'Cormorant Garamond', Georgia, serif; color: var(--ink); }

a { color: var(--primary); text-decoration: none; transition: color 0.2s ease; }
a:hover { color: var(--primary-hover); }

/* a small label in caps (eyebrow) */
.eyebrow {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--muted);
}

/* a thin line used to separate things */
.rule { height: 1px; background: var(--rule); border: 0; margin: 16px 0; }

/* ==================== */
/* Navigation Bar       */
/* ==================== */
.navbar {
    background: var(--paper);
    border-bottom: 1px solid var(--rule);
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-container {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 64px;
}
.logo {
    color: var(--ink);
    font-family: 'Cormorant Garamond', serif;
    font-size: 24px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}
/* the small square "seal" before the brand name */
.logo::before {
    content: "K";
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: #fff;
    border-radius: 6px;
    font-size: 18px;
    font-weight: 600;
}
.nav-links { list-style: none; display: flex; gap: 6px; }
.nav-links a {
    color: var(--ink-soft);
    font-size: 14px;
    font-weight: 500;
    padding: 8px 12px;
    border-radius: 8px;
    transition: background 0.2s ease, color 0.2s ease;
}
.nav-links a:hover { color: var(--primary); background: var(--primary-soft); }
.nav-links a.active { color: var(--primary); font-weight: 600; }
.auth-buttons { display: flex; align-items: center; gap: 10px; }

/* user avatar + name + logout when logged in */
.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 6px 5px 5px;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 10px;
}
.user-avatar {
    width: 32px; height: 32px;
    background: var(--primary);
    color: #fff;
    border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600;
    font-size: 14px;
}
.user-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--ink);
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* hide the name on small screens, keep avatar + logout */
@media (max-width: 560px) { .user-name { display: none; } }

/* ==================== */
/* Buttons              */
/* ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.1s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-secondary, .btn-outline {
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--rule-strong);
}
.btn-secondary:hover, .btn-outline:hover { border-color: var(--primary); background: var(--primary-soft); color: var(--ink); }
.btn-danger { background: var(--error); color: #fff; }
.btn-small { padding: 7px 14px; font-size: 14px; }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ==================== */
/* Layout               */
/* ==================== */
.main-content { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 20px; }
.container { max-width: 1100px; margin: 0 auto; padding: 0 20px; }

/* ==================== */
/* Hero + Search        */
/* ==================== */
.hero { text-align: center; padding: 76px 20px 26px; }
.hero-eyebrow { margin-bottom: 14px; }
.hero h1 {
    font-size: 60px;
    font-weight: 600;
    letter-spacing: -0.015em;
    line-height: 1.04;
    margin-bottom: 18px;
}
.hero-text { color: var(--ink-soft); font-size: 18px; max-width: 560px; margin: 0 auto; line-height: 1.55; }

.search-section { padding: 8px 20px 30px; }
.search-box {
    max-width: 660px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--rule-strong);
    border-radius: 14px;
    padding: 7px 7px 7px 16px;
    box-shadow: 0 1px 2px rgba(26,24,22,0.04);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.search-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30,58,95,0.10); }
.search-icon { color: var(--muted); flex-shrink: 0; transition: color 0.2s ease; }
.search-box:focus-within .search-icon { color: var(--primary); }
.search-box input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 16px;
    padding: 11px 6px;
    background: transparent;
    color: var(--ink);
    font-family: 'Inter', sans-serif;
}
.search-box input::placeholder { color: var(--muted); }
.search-btn {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 9px;
    padding: 11px 24px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    flex-shrink: 0;
    transition: background 0.2s ease, transform 0.1s ease;
}
.search-btn:hover { background: var(--primary-hover); }
.search-btn:active { transform: translateY(1px); }

/* example query chips under the search bar */
.search-examples { max-width: 660px; margin: 16px auto 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 500;
    color: var(--primary);
    background: var(--primary-soft);
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 6px 14px;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
}
.chip:hover { border-color: rgba(30,58,95,0.30); }

/* "How it works" strip on the landing page */
.how-section { max-width: 940px; margin: 46px auto 0; padding: 0 20px; }
.how-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.how-card {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 12px;
    padding: 24px 22px;
}
.how-icon {
    width: 42px; height: 42px;
    border-radius: 10px;
    background: var(--primary-soft);
    color: var(--primary);
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 14px;
}
.how-card h3 { font-size: 20px; font-weight: 600; margin-bottom: 6px; }
.how-card p { color: var(--ink-soft); font-size: 14px; line-height: 1.55; }
@media (max-width: 760px) { .how-grid { grid-template-columns: 1fr; } }

/* results header (title + count on one row) */
.results-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    border-bottom: 1px solid var(--rule);
    padding-bottom: 14px;
    margin-bottom: 22px;
    gap: 16px;
}
.results-header h2 { font-size: 30px; font-weight: 600; }
.results-header #resultsCount { color: var(--muted); font-size: 14px; margin: 0; }

/* ==================== */
/* Results + Cards      */
/* ==================== */
.results-section { padding: 10px 0 50px; }
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.document-card {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 12px;
    padding: 22px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
.document-card:hover {
    border-color: var(--rule-strong);
    box-shadow: 0 6px 24px rgba(26,24,22,0.07);
    transform: translateY(-2px);
}
.document-card h3 {
    font-size: 21px;
    font-weight: 600;
    line-height: 1.25;
    margin-bottom: 6px;
}
.document-card:hover h3 { color: var(--primary); }
.card-author { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.card-keywords { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.card-summary { color: var(--ink-soft); font-size: 14px; line-height: 1.6; }

.keyword-tag {
    display: inline-block;
    background: var(--surface-soft);
    color: var(--ink-soft);
    border: 1px solid var(--rule);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
}

.card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--rule);
}
.relevance-score { color: var(--primary); font-weight: 600; font-size: 13px; }
.card-date { color: var(--muted); font-size: 13px; }
.view-link { color: var(--primary); font-weight: 600; font-size: 14px; }

/* ==================== */
/* Forms (login etc.)   */
/* ==================== */
.form-container {
    max-width: 420px;
    margin: 60px auto;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 14px;
    padding: 36px;
    box-shadow: 0 4px 16px rgba(26,24,22,0.05);
}
.form-container h1, .page-header h1 { font-size: 40px; font-weight: 600; margin-bottom: 8px; }
.form-subtitle { color: var(--ink-soft); margin-bottom: 24px; }
.form-group { margin-bottom: 18px; }
.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--ink-soft);
    margin-bottom: 7px;
}
.form-group input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--rule-strong);
    border-radius: 8px;
    font-size: 15px;
    font-family: 'Inter', sans-serif;
    color: var(--ink);
    background: var(--surface);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30,58,95,0.10);
}
.form-hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.form-actions { margin-top: 24px; }
.form-footer { text-align: center; margin-top: 20px; color: var(--ink-soft); font-size: 14px; }

/* a small accent rule under headings */
.accent-rule { width: 48px; height: 2px; background: var(--primary); border: 0; margin: 16px 0; }

/* divider with text ("or") */
.divider { display: flex; align-items: center; gap: 14px; margin: 22px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--rule); }
.divider span { font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }

/* ==================== */
/* Messages             */
/* ==================== */
.error-message {
    background: var(--error-soft);
    color: var(--error);
    border: 1px solid rgba(161,61,61,0.25);
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 16px;
    display: none;
}
.success-message {
    background: var(--success-soft);
    color: var(--success);
    border: 1px solid rgba(45,106,79,0.25);
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 16px;
    display: none;
}

/* ==================== */
/* Page header          */
/* ==================== */
.page-header { padding: 50px 0 10px; }
.page-header p { color: var(--ink-soft); }

/* ==================== */
/* Upload page          */
/* ==================== */
.upload-container { max-width: 720px; margin: 0 auto; padding: 20px; }
.upload-area {
    border: 2px dashed var(--rule-strong);
    border-radius: 12px;
    padding: 50px 20px;
    text-align: center;
    background: var(--surface);
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
}
.upload-area:hover, .upload-area.dragover { border-color: var(--primary); background: var(--primary-soft); }
.upload-icon { width: 60px; height: 60px; margin: 0 auto 16px; color: var(--primary); }
.upload-area h3 { font-size: 22px; font-weight: 600; margin-bottom: 8px; }
.upload-hint { color: var(--muted); font-size: 14px; margin-top: 6px; }

.selected-file {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--success-soft);
    border: 1px solid rgba(45,106,79,0.25);
    border-radius: 12px;
    padding: 18px;
    margin-top: 18px;
}
.file-icon { color: var(--success); }
.file-info { flex: 1; }
.file-name { font-weight: 600; color: var(--ink); }
.file-size { color: var(--muted); font-size: 13px; }

/* card used to wrap upload / review forms */
.card {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 14px;
    padding: 28px;
    box-shadow: 0 4px 16px rgba(26,24,22,0.05);
}

/* step indicator (1 - 2 - 3) */
.step-indicator { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 20px 0 28px; }
.step { display: flex; align-items: center; gap: 8px; }
.step-number {
    width: 34px; height: 34px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 14px;
    background: var(--surface-soft);
    color: var(--muted);
    border: 1px solid var(--rule-strong);
}
.step.active .step-number { background: var(--primary); color: #fff; border-color: var(--primary); }
.step-text { font-size: 14px; color: var(--muted); }
.step.active .step-text { color: var(--ink); font-weight: 600; }
.step-line { width: 40px; height: 2px; background: var(--rule-strong); border-radius: 2px; }

/* keyword selection on the review step */
.keywords-select { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.keywords-select .keyword-tag { cursor: pointer; }
.keywords-select .keyword-tag.selected { background: var(--primary); color: #fff; border-color: var(--primary); }
.custom-keyword-input { display: flex; gap: 10px; margin-top: 12px; }
.custom-keyword-input input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--rule-strong);
    border-radius: 8px;
    font-size: 15px;
    font-family: 'Inter', sans-serif;
}
.summary-box {
    background: var(--surface-soft);
    border: 1px solid var(--rule);
    border-radius: 10px;
    padding: 16px;
    color: var(--ink-soft);
    font-size: 14px;
    line-height: 1.6;
}
.titles-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.title-option {
    cursor: pointer;
    padding: 8px 14px;
    border: 1px solid var(--rule);
    border-radius: 8px;
    background: var(--surface);
    font-size: 14px;
    color: var(--ink-soft);
}
.title-option.selected { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ==================== */
/* Document detail page */
/* ==================== */
.document-page { max-width: 1040px; margin: 0 auto; padding: 30px 20px 60px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-soft); font-size: 14px; margin-bottom: 24px; }
.back-link:hover { color: var(--primary); }

/* two columns: wide reading area + sticky sidebar */
.doc-layout { display: grid; grid-template-columns: 1fr 320px; gap: 36px; align-items: start; }
.doc-main { min-width: 0; }
.doc-main h1 { font-size: 44px; font-weight: 600; line-height: 1.08; letter-spacing: -0.01em; margin-top: 4px; }
.document-meta { margin-top: 12px; color: var(--ink-soft); font-size: 16px; }
.doc-block { margin-top: 28px; }
.doc-label { font-size: 12px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; font-family: 'Inter', sans-serif; }

.keywords-list { display: flex; flex-wrap: wrap; gap: 8px; }
.keywords-list .keyword-tag {
    background: var(--primary-soft);
    color: var(--primary);
    border-color: transparent;
    padding: 6px 12px;
    font-size: 13px;
    transition: border-color 0.2s ease;
}
.keywords-list .keyword-tag:hover { border: 1px solid rgba(30,58,95,0.30); }

.document-summary {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 12px;
    padding: 22px 24px;
}
.document-summary p { font-family: 'Cormorant Garamond', Georgia, serif; font-size: 20px; line-height: 1.6; color: var(--ink-soft); margin: 0; }

/* sticky sidebar card with the actions + details */
.doc-side { position: sticky; top: 88px; }
.doc-card {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 14px;
    padding: 20px;
    box-shadow: 0 4px 16px rgba(26,24,22,0.05);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.doc-card .rule { margin: 8px 0; }
.doc-card .doc-label { margin-bottom: 4px; }

/* details list (definition list) */
.doc-details { display: grid; grid-template-columns: auto 1fr; gap: 10px 14px; font-size: 14px; }
.doc-details dt { color: var(--muted); }
.doc-details dd { color: var(--ink); font-weight: 500; text-align: right; }
.doc-details dd:last-of-type { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--muted); font-weight: 400; }

/* inline PDF preview (simple iframe) */
.pdf-frame-wrap { border: 1px solid var(--rule); border-radius: 12px; overflow: hidden; }
.pdf-frame-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px;
    background: var(--surface-soft);
    border-bottom: 1px solid var(--rule);
    font-size: 14px; font-weight: 500; color: var(--ink);
}
.btn-ghost-sm {
    background: none; border: none; cursor: pointer;
    color: var(--muted); font-size: 15px; line-height: 1;
    padding: 4px 8px; border-radius: 6px;
    transition: color 0.2s ease, background 0.2s ease;
}
.btn-ghost-sm:hover { color: var(--ink); background: var(--rule); }
.pdf-frame { width: 100%; height: 72vh; border: none; background: var(--surface-soft); display: block; }

@media (max-width: 880px) {
    .doc-layout { grid-template-columns: 1fr; }
    .doc-side { position: static; }
}

/* ==================== */
/* States               */
/* ==================== */
.loading { text-align: center; padding: 50px 20px; color: var(--muted); }
.spinner {
    width: 36px; height: 36px;
    border: 3px solid var(--rule);
    border-top-color: var(--primary);
    border-radius: 50%;
    margin: 0 auto 14px;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state, .error-state { text-align: center; padding: 60px 20px; }
.empty-icon, .empty-state .icon { width: 56px; height: 56px; margin: 0 auto 16px; color: var(--muted); }
.empty-state h3 { font-size: 26px; font-weight: 600; margin-bottom: 8px; }
.empty-state p { color: var(--ink-soft); margin-bottom: 20px; }

/* success page after upload */
.upload-success { text-align: center; max-width: 560px; margin: 40px auto; }
.success-icon {
    width: 60px; height: 60px;
    background: var(--success-soft);
    border: 1px solid rgba(45,106,79,0.3);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 18px;
    color: var(--success);
}
.upload-success .eyebrow { color: var(--success); }
.upload-success h2 { font-size: 34px; font-weight: 600; margin: 8px 0 10px; }
.success-sub { color: var(--ink-soft); font-size: 15px; margin-bottom: 26px; }

/* card showing the uploaded title + keywords */
.success-card {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 12px;
    padding: 22px;
    text-align: left;
    margin-bottom: 26px;
    box-shadow: 0 1px 2px rgba(26,24,22,0.04);
}
.success-card-label {
    font-size: 11px; font-weight: 600; letter-spacing: 0.14em;
    text-transform: uppercase; color: var(--muted);
    margin: 0 0 6px;
}
.success-card-title {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 24px; font-weight: 600; color: var(--ink);
    line-height: 1.2; margin: 0 0 18px;
}
.success-card .keywords-list .keyword-tag {
    background: var(--primary-soft); color: var(--primary);
    border-color: transparent; padding: 5px 11px; font-size: 13px;
}
.success-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.success-link {
    display: inline-block; margin-top: 16px;
    color: var(--muted); font-size: 14px;
}
.success-link:hover { color: var(--primary); }

/* ==================== */
/* Footer               */
/* ==================== */
.footer {
    border-top: 1px solid var(--rule);
    background: var(--surface);
    padding: 28px 20px;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
    margin-top: 40px;
}

/* ==================== */
/* Mobile               */
/* ==================== */
@media (max-width: 640px) {
    .hero h1 { font-size: 40px; }
    .nav-links { display: none; }
    .results-grid { grid-template-columns: 1fr; }
    .search-box { flex-direction: column; }
    .form-container { margin: 30px 16px; padding: 24px; }
}
