/* ============================================================
   Template Docs visual kit  (prefix: tpldoc-)
   Written for the templates pages but can be shared by other
   pages when necessary to prevent duplication of design.
   ============================================================ */

/* ------------------------------------------------------------
   ROOT VARIABLE SYSTEM
   Tokens for the how-to documentation kit only. These are plain
   custom-property declarations: they apply NO styling on their
   own and are consumed exclusively by the .tpldoc-* classes
   below, so the cms.php chrome (header, sidebar, body) is never
   affected. Re-theme the kit by editing values here.
   When you add new .tpldoc-* styles, reuse these tokens.
   ------------------------------------------------------------ */
:root {
    /* Brand / accent */
    --tpldoc-accent:        #007cba;   /* primary accent (buttons, active, links) */
    --tpldoc-accent-soft:   #ebf5fb;   /* tinted accent fill (active item, cards) */
    --tpldoc-accent-deep:   #2c5282;   /* darker accent text */
    --tpldoc-accent-mid:    #2b6cb0;   /* structure "tag" line colour */
    --tpldoc-accent-line:   #bee3f8;   /* light accent border */
    --tpldoc-accent-grad:   #e6f6ff;   /* end stop for the accent gradient */

    /* Chrome & surfaces */
    --tpldoc-chrome:        #1a202c;   /* dark title bar / code background */
    --tpldoc-white:         #ffffff;   /* white surfaces and on-colour text */
    --tpldoc-bg:            #f7fafc;   /* panel body background */
    --tpldoc-bg-soft:       #f1f5f9;   /* soft fill (toolbar, table head, edge) */
    --tpldoc-fill-soft:     #edf2f7;   /* faint fill / faint border */

    /* Borders */
    --tpldoc-border:        #e2e8f0;
    --tpldoc-border-strong: #d6dde5;
    --tpldoc-border-input:  #cbd5e0;

    /* Text */
    --tpldoc-text:          #2d3748;   /* body text */
    --tpldoc-text-muted:    #4a5568;   /* secondary text */
    --tpldoc-text-meta:     #718096;   /* meta / labels */
    --tpldoc-text-faint:    #a0aec0;   /* faint meta / placeholders */

    /* Status */
    --tpldoc-success:       #2f855a;
    --tpldoc-danger:        #e53e3e;
    --tpldoc-danger-text:   #c53030;
    --tpldoc-danger-border: #fbb6b6;
    --tpldoc-warn:          #ed8936;   /* annotation pin */
    --tpldoc-warn-text:     #c05621;   /* placeholder text / reference-table code */
    --tpldoc-warn-bg:       #fffaf0;   /* placeholder / reference-table code bg */
    --tpldoc-doctype:       #805ad5;   /* structure "doctype" line colour */

    /* Window dots */
    --tpldoc-dot-r:         #ed6a5e;
    --tpldoc-dot-y:         #f4bf4f;
    --tpldoc-dot-g:         #61c554;

    /* Code syntax highlighting */
    --tpldoc-code-text:     #e2e8f0;
    --tpldoc-code-comment:  #68d391;
    --tpldoc-code-tag:      #63b3ed;
    --tpldoc-code-ph:       #f6ad55;
    --tpldoc-code-attr:     #d6bcfa;

    /* One-off accents */
    --tpldoc-addrow-edge:   #f0f7fb;   /* structure "add" row edge */
    --tpldoc-addrow-fill:   #fbfdff;   /* structure "add" row body */
    --tpldoc-row-hover:     #fafcfe;   /* table row hover */
    --tpldoc-ring:          0 0 0 3px rgba(0, 124, 186, 0.12);  /* "new" row focus ring */

    /* Typography */
    --tpldoc-font-mono:     'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    --tpldoc-fs-label:      10px;
    --tpldoc-fs-xs:         11px;
    --tpldoc-fs-meta:       11.5px;
    --tpldoc-fs-icon:       12px;
    --tpldoc-fs-code:       12.5px;
    --tpldoc-fs-sm:         13px;
    --tpldoc-fs-base:       14px;
    --tpldoc-fs-lg:         18px;
    --tpldoc-fs-xl:         20px;
    --tpldoc-fs-caption:    0.82rem;
    --tpldoc-fs-note:       0.9rem;

    /* Radii */
    --tpldoc-radius-sm:     4px;
    --tpldoc-radius:        5px;
    --tpldoc-radius-md:     6px;
    --tpldoc-radius-lg:     8px;
    --tpldoc-radius-xl:     10px;
    --tpldoc-radius-pill:   999px;

    /* Shadows */
    --tpldoc-shadow:        0 6px 20px rgba(15, 40, 70, 0.08);
    --tpldoc-shadow-hover:  0 4px 14px rgba(0, 124, 186, 0.15);
}

/* Faux interface frame &mdash; the "cut-off" interface preview */
.tpldoc-screen {
    border: 1px solid var(--tpldoc-border-strong);
    border-radius: var(--tpldoc-radius-lg);
    background: var(--tpldoc-white);
    box-shadow: var(--tpldoc-shadow);
    margin: 1.25rem 0 0.5rem;
    overflow: hidden;
}
.tpldoc-screen-bar {
    background: var(--tpldoc-chrome);
    height: 32px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 6px;
}
.tpldoc-screen-bar i { color: var(--tpldoc-text-muted); font-size: var(--tpldoc-fs-xs); }
.tpldoc-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.tpldoc-dot.r { background: var(--tpldoc-dot-r); }
.tpldoc-dot.y { background: var(--tpldoc-dot-y); }
.tpldoc-dot.g { background: var(--tpldoc-dot-g); }
.tpldoc-screen-label {
    color: var(--tpldoc-text-faint);
    font-size: var(--tpldoc-fs-xs);
    margin-left: 10px;
    letter-spacing: 0.3px;
}
.tpldoc-screen-body {
    background: var(--tpldoc-bg);
    padding: 16px;
    position: relative;
}

/* The "clip" modifier fades the bottom so the panel reads as a partial view.
   The rgba() below is the fully-transparent form of --tpldoc-bg (#f7fafc). */
.tpldoc-clip .tpldoc-screen-body {
    max-height: 320px;
    overflow: hidden;
}
.tpldoc-clip .tpldoc-screen-body::after {
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 70px;
    background: linear-gradient(to bottom, rgba(247,250,252,0), var(--tpldoc-bg) 88%);
    pointer-events: none;
}

.tpldoc-caption {
    font-size: var(--tpldoc-fs-caption);
    color: var(--tpldoc-text-meta);
    font-style: italic;
    margin: 0 0 1.75rem;
    padding-left: 2px;
}

/* Faux left sidebar fragment */
.tpldoc-sidebar {
    background: var(--tpldoc-white);
    border: 1px solid var(--tpldoc-border);
    border-radius: var(--tpldoc-radius-md);
    width: 230px;
    padding: 10px 0;
    font-size: var(--tpldoc-fs-sm);
}
.tpldoc-side-label {
    color: var(--tpldoc-text-meta);
    font-size: var(--tpldoc-fs-label);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 6px 14px 4px;
}
.tpldoc-side-item {
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--tpldoc-text-muted);
    padding: 7px 14px;
    border-left: 3px solid transparent;
}
.tpldoc-side-item i { width: 14px; text-align: center; color: var(--tpldoc-text-faint); }
.tpldoc-side-item.is-active {
    background: var(--tpldoc-accent-soft);
    color: var(--tpldoc-accent);
    border-left-color: var(--tpldoc-accent);
    font-weight: 600;
}
.tpldoc-side-item.is-active i { color: var(--tpldoc-accent); }

/* Tab bar */
.tpldoc-tabs {
    display: flex;
    gap: 2px;
    border-bottom: 2px solid var(--tpldoc-border);
    flex-wrap: wrap;
}
.tpldoc-tab {
    padding: 9px 16px;
    font-size: var(--tpldoc-fs-sm);
    color: var(--tpldoc-text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: default;
    white-space: nowrap;
}
.tpldoc-tab.is-active {
    color: var(--tpldoc-accent);
    border-bottom-color: var(--tpldoc-accent);
    font-weight: 600;
}

/* Generic app buttons */
.tpldoc-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: var(--tpldoc-fs-sm);
    font-weight: 600;
    border: 1px solid var(--tpldoc-border-input);
    background: var(--tpldoc-white);
    color: var(--tpldoc-text);
    padding: 7px 13px;
    border-radius: var(--tpldoc-radius);
    line-height: 1;
}
.tpldoc-btn--primary { background: var(--tpldoc-accent); border-color: var(--tpldoc-accent); color: var(--tpldoc-white); }
.tpldoc-btn--ghost   { background: transparent; border-color: transparent; color: var(--tpldoc-accent); padding-left: 0; }
.tpldoc-btn--danger  { color: var(--tpldoc-danger-text); border-color: var(--tpldoc-danger-border); }
.tpldoc-btn[disabled],
.tpldoc-btn.is-disabled { opacity: 0.45; }
.tpldoc-iconbtn {
    width: 30px; height: 30px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--tpldoc-radius); border: 1px solid var(--tpldoc-border-input); background: var(--tpldoc-white);
    font-size: var(--tpldoc-fs-icon);
}
.tpldoc-iconbtn.ok   { background: var(--tpldoc-success); border-color: var(--tpldoc-success); color: var(--tpldoc-white); }
.tpldoc-iconbtn.no   { background: var(--tpldoc-white); border-color: var(--tpldoc-border-input); color: var(--tpldoc-text-meta); }

.tpldoc-toolbar {
    display: flex;
    justify-content: flex-end;
    padding: 12px 2px;
}

/* Template list rows */
.tpldoc-row {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--tpldoc-white);
    border: 1px solid var(--tpldoc-border);
    border-radius: var(--tpldoc-radius-md);
    padding: 12px 14px;
    margin-bottom: 8px;
    position: relative;
}
.tpldoc-row.is-new { border-color: var(--tpldoc-accent); box-shadow: var(--tpldoc-ring); }
.tpldoc-row-mid { flex: 1; min-width: 0; }
.tpldoc-row-right { display: flex; gap: 7px; align-items: center; }
.tpldoc-name {
    font-size: var(--tpldoc-fs-base);
    font-weight: 600;
    color: var(--tpldoc-text);
}
.tpldoc-meta { font-size: var(--tpldoc-fs-meta); color: var(--tpldoc-text-faint); margin-top: 2px; }

.tpldoc-check {
    width: 18px; height: 18px;
    border-radius: var(--tpldoc-radius-sm);
    border: 1px solid var(--tpldoc-border-input);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: var(--tpldoc-fs-label); color: var(--tpldoc-white); background: var(--tpldoc-white); flex-shrink: 0;
}
.tpldoc-check.is-on { background: var(--tpldoc-success); border-color: var(--tpldoc-success); }

.tpldoc-input {
    width: 100%;
    max-width: 260px;
    font-size: var(--tpldoc-fs-sm);
    padding: 7px 10px;
    border: 1px solid var(--tpldoc-accent);
    border-radius: var(--tpldoc-radius);
    color: var(--tpldoc-text);
    background: var(--tpldoc-white);
}
.tpldoc-input.ghost { color: var(--tpldoc-text-faint); }
.tpldoc-name-edit { display: flex; align-items: center; gap: 6px; }

/* Annotation pins */
.tpldoc-pin {
    display: inline-flex; align-items: center; justify-content: center;
    width: 18px; height: 18px; border-radius: 50%;
    background: var(--tpldoc-warn); color: var(--tpldoc-white);
    font-size: var(--tpldoc-fs-xs); font-weight: 700;
    margin-left: 6px; vertical-align: middle;
    font-style: normal;
}
.tpldoc-legend-pins { list-style: none; margin: 0.75rem 0 0; padding: 0; }
.tpldoc-legend-pins li {
    display: flex; align-items: flex-start; gap: 9px;
    margin-bottom: 7px; font-size: var(--tpldoc-fs-note); color: var(--tpldoc-text-muted);
}

/* Simple code editor mock */
.tpldoc-editor { border: 1px solid var(--tpldoc-border); border-radius: var(--tpldoc-radius-md); overflow: hidden; background: var(--tpldoc-white); }
.tpldoc-editor-bar {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--tpldoc-bg-soft); border-bottom: 1px solid var(--tpldoc-border); padding: 8px 12px;
}
.tpldoc-code {
    background: var(--tpldoc-chrome); color: var(--tpldoc-code-text);
    font-family: var(--tpldoc-font-mono);
    font-size: var(--tpldoc-fs-code); line-height: 1.7;
    padding: 14px 16px;
    white-space: pre; overflow-x: auto;
}
.tpldoc-code .c { color: var(--tpldoc-code-comment); }   /* comment  */
.tpldoc-code .t { color: var(--tpldoc-code-tag); }       /* tag      */
.tpldoc-code .p { color: var(--tpldoc-code-ph); }        /* placeholder */
.tpldoc-code .a { color: var(--tpldoc-code-attr); } 

/* Structure association dropdown / default radio */
.tpldoc-field { margin-bottom: 12px; }
.tpldoc-field-label { font-size: var(--tpldoc-fs-xs); font-weight: 700; color: var(--tpldoc-text-meta); text-transform: uppercase; letter-spacing: .5px; display: block; margin-bottom: 5px; }
.tpldoc-select {
    display: inline-flex; align-items: center; justify-content: space-between;
    min-width: 240px; font-size: var(--tpldoc-fs-sm); padding: 8px 12px;
    border: 1px solid var(--tpldoc-border-input); border-radius: var(--tpldoc-radius); background: var(--tpldoc-white); color: var(--tpldoc-text);
}
.tpldoc-select i { color: var(--tpldoc-text-faint); margin-left: 12px; }
.tpldoc-radio { display: inline-flex; align-items: center; gap: 8px; font-size: var(--tpldoc-fs-sm); color: var(--tpldoc-text-muted); }
.tpldoc-radio .ring {
    width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--tpldoc-accent);
    display: inline-flex; align-items: center; justify-content: center;
}
.tpldoc-radio .ring::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--tpldoc-accent); }

/* "Where to next" link card */
.tpldoc-next {
    display: flex; align-items: center; gap: 16px;
    background: linear-gradient(135deg, var(--tpldoc-accent-soft), var(--tpldoc-accent-grad));
    border: 1px solid var(--tpldoc-accent-line); border-radius: var(--tpldoc-radius-xl);
    padding: 1.25rem 1.5rem; margin: 1rem 0;
    text-decoration: none; color: inherit;
}
.tpldoc-next:hover { box-shadow: var(--tpldoc-shadow-hover); text-decoration: none; }
.tpldoc-next .ic {
    width: 46px; height: 46px; flex-shrink: 0; border-radius: var(--tpldoc-radius-xl);
    background: var(--tpldoc-accent); color: var(--tpldoc-white); display: flex; align-items: center; justify-content: center;
    font-size: var(--tpldoc-fs-xl);
}
.tpldoc-next h4 { margin: 0 0 2px; color: var(--tpldoc-accent-deep); font-size: 1.05rem; }
.tpldoc-next p  { margin: 0; color: var(--tpldoc-text-muted); font-size: var(--tpldoc-fs-note); }
.tpldoc-next .go { margin-left: auto; color: var(--tpldoc-accent); font-size: var(--tpldoc-fs-lg); }

/* Inline keycap-style label for a control name */
.tpldoc-ctl {
    display: inline-block; font-weight: 600; font-size: 0.85em;
    background: var(--tpldoc-fill-soft); border: 1px solid var(--tpldoc-border-strong); border-radius: var(--tpldoc-radius-sm);
    padding: 1px 7px; color: var(--tpldoc-text); white-space: nowrap;
}

.tpldoc-back { display: inline-flex; align-items: center; gap: 8px; font-size: .9rem; color: var(--tpldoc-accent); margin-bottom: 1rem; }

@media (max-width: 768px) {
    .tpldoc-sidebar { width: 100%; }
    .tpldoc-row { flex-wrap: wrap; }
    .tpldoc-next { flex-wrap: wrap; }
}


/* ============================================================
   Structure editor visuals that were specifically created for the
   advancted templates page. Reuse as needed unless it's necessary
   to create new classes
   ============================================================ */
.tpldoc-structure { font-family: var(--tpldoc-font-mono); font-size: var(--tpldoc-fs-code); background: var(--tpldoc-white); border: 1px solid var(--tpldoc-border); border-radius: var(--tpldoc-radius-md); overflow: hidden; }
.tpldoc-sline { display: grid; grid-template-columns: 34px 1fr; align-items: stretch; border-bottom: 1px solid var(--tpldoc-bg-soft); }
.tpldoc-sline:last-child { border-bottom: none; }
.tpldoc-edge { background: var(--tpldoc-bg); border-right: 1px solid var(--tpldoc-fill-soft); display: flex; align-items: center; justify-content: center; }
.tpldoc-edge-icon { width: 18px; height: 18px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 9px; color: var(--tpldoc-white); }
.tpldoc-edge-add { background: var(--tpldoc-accent); }
.tpldoc-edge-remove { background: var(--tpldoc-danger); }
.tpldoc-sline.addrow { min-height: 16px; }
.tpldoc-sline.addrow .tpldoc-edge { background: var(--tpldoc-addrow-edge); }
.tpldoc-sline.addrow .tpldoc-content { background: var(--tpldoc-addrow-fill); }
.tpldoc-content { padding: 5px 12px; white-space: pre-wrap; word-break: break-word; }
/* line-type colour coding (mirrors the editor's getLineClass) */
.tpldoc-l-doctype { color: var(--tpldoc-doctype); }
.tpldoc-l-tag     { color: var(--tpldoc-accent-mid); }
.tpldoc-l-comment { color: var(--tpldoc-text-meta); font-style: italic; }
.tpldoc-l-ph      { color: var(--tpldoc-warn-text); background: var(--tpldoc-warn-bg); font-weight: 600; }
.tpldoc-l-html    { color: var(--tpldoc-text); }

.tpldoc-legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 0.75rem 0 0; font-size: var(--tpldoc-fs-caption); }
.tpldoc-legend span { display: inline-flex; align-items: center; gap: 6px; color: var(--tpldoc-text-muted); }
.tpldoc-swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* element selector */
.tpldoc-selector { display: flex; align-items: center; gap: 6px; background: var(--tpldoc-accent-soft); border: 1px dashed var(--tpldoc-accent); border-radius: var(--tpldoc-radius); padding: 6px; }
.tpldoc-selector .toggle { width: 28px; height: 28px; border-radius: var(--tpldoc-radius); background: var(--tpldoc-white); border: 1px solid var(--tpldoc-border-input); display: inline-flex; align-items: center; justify-content: center; font-size: var(--tpldoc-fs-base); }

/* file-option chips */
.tpldoc-fileopts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tpldoc-chip { display: inline-flex; align-items: center; gap: 5px; font-size: var(--tpldoc-fs-meta); font-weight: 600; padding: 3px 9px; border-radius: var(--tpldoc-radius-pill); border: 1px solid var(--tpldoc-border-input); color: var(--tpldoc-text-meta); background: var(--tpldoc-white); }
.tpldoc-chip.is-on { color: var(--tpldoc-white); background: var(--tpldoc-accent); border-color: var(--tpldoc-accent); }
.tpldoc-chip.placement { color: var(--tpldoc-accent-deep); background: var(--tpldoc-accent-soft); border-color: var(--tpldoc-accent-line); }

/* placeholder reference table */
.tpldoc-table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: var(--tpldoc-fs-note); }
.tpldoc-table th { text-align: left; background: var(--tpldoc-bg-soft); color: var(--tpldoc-text); padding: 9px 12px; border-bottom: 2px solid var(--tpldoc-border); font-size: .8rem; text-transform: uppercase; letter-spacing: .4px; }
.tpldoc-table td { padding: 9px 12px; border-bottom: 1px solid var(--tpldoc-fill-soft); color: var(--tpldoc-text-muted); vertical-align: top; }
.tpldoc-table td code { background: var(--tpldoc-warn-bg); color: var(--tpldoc-warn-text); padding: 1px 6px; border-radius: var(--tpldoc-radius-sm); white-space: nowrap; }
.tpldoc-table tr:hover td { background: var(--tpldoc-row-hover); }

.tpldoc-typehead { display: flex; align-items: center; gap: 12px; }
.tpldoc-typehead .badge { width: 40px; height: 40px; flex-shrink: 0; border-radius: 9px; background: var(--tpldoc-accent); color: var(--tpldoc-white); display: flex; align-items: center; justify-content: center; font-size: var(--tpldoc-fs-lg); }

@media (max-width: 768px) {
    .tpldoc-row { flex-wrap: wrap; }
    .tpldoc-table { display: block; overflow-x: auto; }
}
