/*
 * Refer App — Documentation Styles
 * For use at referrerattribution.com/docs/
 *
 * Uses the same color system and type scale as the app itself,
 * so the docs feel like a natural extension of the product.
 * Designed to slot into a CQIP Static site as content pages.
 */

:root {
    --teal:        #0FC5B8;
    --teal-text:   #0A857D;
    --navy:        #2E3B52;
    --arc:         #3E517B;
    --bg:          #F7F8FA;
    --white:       #ffffff;
    --border:      #E2E5EA;
    --grey-text:   #6E7582;
    --pro-badge:   #E5F9F7;

    --fs-xs:  0.75rem;
    --fs-sm:  0.8125rem;
    --fs-md:  0.875rem;
    --fs-lg:  0.9375rem;
    --fs-xl:  1.125rem;
    --fs-2xl: 1.375rem;
    --fs-3xl: 1.75rem;
}

html { font-size: 100%; }
* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: var(--fs-lg);
    font-weight: 400;
    line-height: 1.7;
    color: var(--navy);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Layout */
.doc-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    grid-template-rows: auto 1fr;
    min-height: 100vh;
}

.doc-header {
    grid-column: 1 / -1;
    background: var(--navy);
    border-bottom: 2px solid var(--teal);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 14px;
}
.doc-header-logo {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    flex: 0 0 auto;
}
.doc-header-title {
    color: #fff;
    font-size: var(--fs-xl);
    font-weight: 700;
    margin: 0;
    text-decoration: none;
}
.doc-header-subtitle {
    color: rgba(255,255,255,0.6);
    font-size: var(--fs-sm);
    margin-left: auto;
    white-space: nowrap;
}

.doc-sidebar {
    background: var(--white);
    border-right: 1px solid var(--border);
    padding: 24px 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.doc-sidebar-section {
    margin-bottom: 6px;
}
.doc-sidebar-label {
    font-size: var(--fs-xs);
    font-weight: 700;
    color: var(--grey-text);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 10px 20px 4px;
    display: block;
}
.doc-sidebar a {
    display: block;
    padding: 6px 20px;
    font-size: var(--fs-sm);
    color: var(--arc);
    text-decoration: none;
    border-left: 2px solid transparent;
    transition: all 0.12s ease;
}
.doc-sidebar a:hover,
.doc-sidebar a.active {
    color: var(--teal-text);
    border-left-color: var(--teal);
    background: var(--pro-badge);
}
.doc-sidebar .pro-link::after {
    content: 'Pro';
    font-size: 10px;
    font-weight: 700;
    color: var(--navy);
    background: var(--teal);
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: 6px;
    vertical-align: middle;
}

.doc-main {
    padding: 40px 48px;
    max-width: 820px;
}

/* Typography */
h1 {
    font-size: var(--fs-3xl);
    font-weight: 800;
    color: var(--navy);
    margin: 0 0 8px;
    line-height: 1.2;
}
.doc-subtitle {
    font-size: var(--fs-xl);
    color: var(--grey-text);
    margin: 0 0 36px;
    font-weight: 400;
}
h2 {
    font-size: var(--fs-2xl);
    font-weight: 700;
    color: var(--navy);
    margin: 40px 0 12px;
    padding-left: 12px;
    border-left: 3px solid var(--teal);
    line-height: 1.3;
}
h3 {
    font-size: var(--fs-xl);
    font-weight: 600;
    color: var(--navy);
    margin: 28px 0 8px;
}
h4 {
    font-size: var(--fs-lg);
    font-weight: 600;
    color: var(--arc);
    margin: 20px 0 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: var(--fs-xs);
}
p { margin: 0 0 16px; }
a { color: var(--teal-text); }
a:hover { color: var(--navy); }

code {
    font-family: "SF Mono", "Fira Code", Consolas, monospace;
    font-size: var(--fs-sm);
    background: #EEF0F4;
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--arc);
}
pre {
    background: var(--navy);
    color: #E2E8F0;
    padding: 20px 24px;
    border-radius: 10px;
    overflow-x: auto;
    font-family: "SF Mono", "Fira Code", Consolas, monospace;
    font-size: var(--fs-sm);
    line-height: 1.6;
    margin: 0 0 24px;
}
pre code {
    background: none;
    padding: 0;
    color: inherit;
    border-radius: 0;
}

/* Components */
.pro-badge {
    display: inline-flex;
    align-items: center;
    background: var(--teal);
    color: var(--navy);
    font-size: var(--fs-xs);
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    margin-left: 10px;
    vertical-align: middle;
    letter-spacing: 0.02em;
}
.free-badge {
    display: inline-flex;
    align-items: center;
    background: var(--border);
    color: var(--grey-text);
    font-size: var(--fs-xs);
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    margin-left: 10px;
    vertical-align: middle;
    letter-spacing: 0.02em;
}

.callout {
    border-left: 3px solid var(--teal);
    background: var(--pro-badge);
    padding: 14px 18px;
    border-radius: 0 8px 8px 0;
    margin: 20px 0;
    font-size: var(--fs-md);
}
.callout strong { color: var(--navy); }
.callout--warn {
    border-left-color: #C8553D;
    background: #FBEAE8;
}
.callout--note {
    border-left-color: var(--arc);
    background: #F0F2F8;
}

/* Illustration panels — inline ASCII-style diagrams rendered
   as clean styled boxes, used wherever a visual helps more
   than prose alone */
.diagram {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 24px;
    margin: 20px 0 28px;
    overflow-x: auto;
}
.diagram pre {
    background: none;
    color: var(--navy);
    padding: 0;
    margin: 0;
    border-radius: 0;
    font-size: var(--fs-sm);
}

/* Example tables */
.example-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    font-size: var(--fs-sm);
    margin: 0 0 24px;
}
.example-table th {
    background: var(--bg);
    font-weight: 600;
    color: var(--arc);
    text-align: left;
    padding: 10px 14px;
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}
.example-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--navy);
    vertical-align: top;
}
.example-table tr:last-child td { border-bottom: none; }
.example-table .channel-tag {
    display: inline-block;
    background: var(--pro-badge);
    color: var(--teal-text);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: var(--fs-xs);
    font-weight: 600;
}

/* Step list */
.steps { list-style: none; padding: 0; margin: 0 0 24px; }
.steps li {
    display: flex;
    gap: 14px;
    margin-bottom: 18px;
    align-items: flex-start;
}
.steps li::before {
    content: attr(data-n);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    min-width: 28px;
    background: var(--navy);
    color: #fff;
    border-radius: 50%;
    font-size: var(--fs-xs);
    font-weight: 700;
    margin-top: 2px;
}

/* Inline field reference */
.field-ref {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2px 8px;
    font-size: var(--fs-sm);
    font-weight: 500;
}

/* Score bar — used for Health Score illustration */
.score-bar-wrap {
    background: var(--bg);
    border-radius: 6px;
    height: 10px;
    overflow: hidden;
    width: 200px;
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
}
.score-bar {
    height: 100%;
    background: var(--teal);
    border-radius: 6px;
}

/* Definition list (glossary) */
dl.glossary { margin: 0; }
dl.glossary dt {
    font-weight: 700;
    color: var(--navy);
    font-size: var(--fs-lg);
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}
dl.glossary dt:first-child { margin-top: 0; padding-top: 0; border-top: none; }
dl.glossary dd {
    margin: 6px 0 0 0;
    color: var(--navy);
    line-height: 1.7;
}
dl.glossary .term-code {
    font-family: monospace;
    font-size: var(--fs-sm);
    color: var(--arc);
    font-weight: 400;
    margin-left: 6px;
}

/* Page nav */
.doc-page-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    gap: 16px;
}
.doc-page-nav a {
    display: flex;
    flex-direction: column;
    gap: 4px;
    text-decoration: none;
    max-width: 45%;
}
.doc-page-nav .nav-label {
    font-size: var(--fs-xs);
    color: var(--grey-text);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.doc-page-nav .nav-title {
    font-size: var(--fs-md);
    font-weight: 600;
    color: var(--teal-text);
}
.doc-page-nav .next { text-align: right; margin-left: auto; }

/* Responsive */
@media (max-width: 768px) {
    .doc-layout {
        grid-template-columns: 1fr;
    }
    .doc-sidebar {
        display: none;
    }
    .doc-main {
        padding: 24px 20px;
    }
    h1 { font-size: var(--fs-2xl); }
}
