/* ===== TowerCoverage Wiki theme =====
   Brand palette pulled from TowerCoverage.com:
   primary blue #247fb5, light blue #419ed6, dark #232323 / #1F2124, accent orange #d48217 */
:root {
    --tc-blue: #247fb5;
    --tc-blue-light: #419ed6;
    --tc-blue-pale: #d9edf7;
    --tc-dark: #232323;
    --tc-dark-2: #1f2124;
    --tc-orange: #d48217;
    --tc-orange-light: #ffa837;
    --tc-text: #24313b;
    --tc-muted: #6b7a86;
    --tc-border: #e2e8ee;
    --tc-bg: #f4f7fa;
    --tc-white: #ffffff;
    --tc-sidebar-w: 280px;
    --tc-header-h: 60px;
    --tc-radius: 8px;
    --tc-shadow: 0 1px 3px rgba(31,33,36,.08), 0 6px 24px rgba(36,127,181,.08);
    font-synthesis: none;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--tc-text);
    background: var(--tc-bg);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--tc-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Header ---------- */
.tc-header {
    position: sticky;
    top: 0;
    z-index: 50;
    height: var(--tc-header-h);
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 0 20px;
    background: linear-gradient(180deg, var(--tc-dark) 92%, var(--tc-blue) 100%);
    color: #fff;
    box-shadow: 0 2px 10px rgba(0,0,0,.25);
}

.tc-brand { display: flex; align-items: center; gap: 12px; color: #fff; }
.tc-brand:hover { text-decoration: none; }
.tc-brand-mark {
    display: inline-grid;
    place-items: center;
    width: 38px; height: 38px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--tc-blue) 0%, var(--tc-blue-light) 100%);
    font-weight: 800;
    letter-spacing: .5px;
    box-shadow: 0 2px 8px rgba(36,127,181,.5);
}
.tc-brand-text { font-size: 1.15rem; font-weight: 600; }
.tc-brand-text span { color: var(--tc-blue-light); font-weight: 400; }

.tc-search { position: relative; flex: 1; max-width: 560px; }
.tc-search input {
    width: 100%;
    height: 38px;
    padding: 0 14px;
    border: 1px solid rgba(255,255,255,.15);
    border-radius: 20px;
    background: rgba(255,255,255,.12);
    color: #fff;
    font-size: .95rem;
    outline: none;
    transition: background .15s, border-color .15s;
}
.tc-search input::placeholder { color: rgba(255,255,255,.7); }
.tc-search input:focus { background: #fff; color: var(--tc-text); border-color: var(--tc-blue-light); }
.tc-search input:focus::placeholder { color: var(--tc-muted); }

.tc-search-suggest {
    position: absolute;
    top: 44px; left: 0; right: 0;
    background: #fff;
    border: 1px solid var(--tc-border);
    border-radius: var(--tc-radius);
    box-shadow: var(--tc-shadow);
    overflow: hidden;
    z-index: 60;
}
.tc-search-suggest a {
    display: block;
    padding: 10px 14px;
    color: var(--tc-text);
    border-bottom: 1px solid var(--tc-border);
}
.tc-search-suggest a:last-child { border-bottom: 0; }
.tc-search-suggest a:hover, .tc-search-suggest a.active { background: var(--tc-blue-pale); text-decoration: none; }
.tc-search-suggest .s-title { font-weight: 600; }
.tc-search-suggest .s-cat { font-size: .78rem; color: var(--tc-muted); }

.tc-header-actions { display: flex; align-items: center; gap: 14px; margin-left: auto; }
.tc-header-actions > a { color: rgba(255,255,255,.85); font-size: .9rem; }
.tc-header-actions > a:hover { color: #fff; }
.tc-user { color: var(--tc-blue-light); font-weight: 600; font-size: .9rem; }
.tc-inline-form { display: inline; margin: 0; }

.tc-menu-toggle {
    display: none;
    background: none; border: 0; color: #fff;
    font-size: 1.5rem; cursor: pointer;
}

/* ---------- Buttons ---------- */
.tc-btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 6px;
    border: 1px solid transparent;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
    text-align: center;
}
.tc-btn:hover { text-decoration: none; }
.tc-btn-primary { background: var(--tc-blue); color: #fff; }
.tc-btn-primary:hover { background: var(--tc-blue-light); color: #fff; }
.tc-btn-ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.3); }
.tc-btn-ghost:hover { background: rgba(255,255,255,.12); color: #fff; }
.tc-btn-block { width: 100%; }
.tc-content .tc-btn-ghost { color: var(--tc-blue); border-color: var(--tc-border); }
.tc-content .tc-btn-ghost:hover { background: var(--tc-blue-pale); }

/* ---------- Shell / layout ---------- */
.tc-shell { display: flex; min-height: calc(100vh - var(--tc-header-h)); }

.tc-sidebar {
    width: var(--tc-sidebar-w);
    flex: 0 0 var(--tc-sidebar-w);
    background: var(--tc-white);
    border-right: 1px solid var(--tc-border);
    padding: 22px 0;
    overflow-y: auto;
    position: sticky;
    top: var(--tc-header-h);
    height: calc(100vh - var(--tc-header-h));
}
.tc-nav-group { margin-bottom: 18px; }
.tc-nav-group h3 {
    margin: 0 0 6px;
    padding: 0 22px;
    font-size: .72rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--tc-muted);
}
.tc-nav-group ul { list-style: none; margin: 0; padding: 0; }
.tc-nav-group li a {
    display: block;
    padding: 7px 22px;
    color: var(--tc-text);
    font-size: .92rem;
    border-left: 3px solid transparent;
}
.tc-nav-group li a:hover { background: var(--tc-blue-pale); text-decoration: none; }
.tc-nav-group li a.active {
    background: var(--tc-blue-pale);
    border-left-color: var(--tc-blue);
    color: var(--tc-blue);
    font-weight: 600;
}

.tc-content {
    flex: 1;
    min-width: 0;
    padding: 34px 44px;
    display: flex;
    flex-direction: column;
}

/* ---------- Article ---------- */
.tc-article {
    background: var(--tc-white);
    border: 1px solid var(--tc-border);
    border-radius: var(--tc-radius);
    box-shadow: var(--tc-shadow);
    padding: 34px 40px;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
}
.tc-article-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.tc-breadcrumb { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--tc-blue); font-weight: 700; }
.tc-article h1 { margin: 6px 0 10px; font-size: 2rem; color: var(--tc-dark); }
.tc-summary { color: var(--tc-muted); font-size: 1.05rem; margin: 0 0 8px; }

.tc-prose { font-size: 1rem; }
.tc-prose h2 { font-size: 1.5rem; color: var(--tc-dark); margin: 28px 0 10px; }
.tc-prose h3 { font-size: 1.2rem; color: var(--tc-blue); margin: 24px 0 8px; }
.tc-prose p { margin: 12px 0; }
.tc-prose ul, .tc-prose ol { margin: 12px 0; padding-left: 26px; }
.tc-prose li { margin: 6px 0; }
.tc-prose code {
    background: #eef3f7;
    color: #c0392b;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: "Cascadia Code", Consolas, monospace;
    font-size: .88em;
}
.tc-prose pre {
    background: var(--tc-dark-2);
    color: #e6edf3;
    padding: 16px 18px;
    border-radius: var(--tc-radius);
    overflow-x: auto;
    border-left: 4px solid var(--tc-blue);
}
.tc-prose pre code { background: none; color: inherit; padding: 0; }
.tc-prose a { font-weight: 500; }

.tc-hero {
    background: linear-gradient(120deg, var(--tc-blue) 0%, var(--tc-blue-light) 100%);
    color: #fff;
    padding: 26px 28px;
    border-radius: var(--tc-radius);
    margin-bottom: 8px;
}
.tc-hero h2 { color: #fff; margin: 0 0 8px; }
.tc-hero p { margin: 0; color: rgba(255,255,255,.92); }

.tc-callout {
    background: var(--tc-blue-pale);
    border-left: 4px solid var(--tc-blue);
    padding: 14px 18px;
    border-radius: 0 var(--tc-radius) var(--tc-radius) 0;
    margin: 18px 0;
}
.tc-callout-error { background: #fdecea; border-left-color: #c0392b; }

.tc-table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: .95rem; }
.tc-table th, .tc-table td { border: 1px solid var(--tc-border); padding: 9px 12px; text-align: left; vertical-align: top; }
.tc-table th { background: var(--tc-blue); color: #fff; font-weight: 600; }
.tc-table tr:nth-child(even) td { background: #f7fafc; }

.tc-tags { margin-top: 26px; display: flex; flex-wrap: wrap; gap: 8px; }
.tc-tag {
    background: #eef3f7; color: var(--tc-muted);
    padding: 3px 10px; border-radius: 12px; font-size: .8rem;
}
.tc-tag:hover { background: var(--tc-blue); color: #fff; text-decoration: none; }
.tc-article-meta { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--tc-border); color: var(--tc-muted); font-size: .82rem; }

/* ---------- Search page ---------- */
.tc-search-page { display: flex; gap: 10px; margin: 16px 0 22px; }
.tc-search-page input { flex: 1; height: 42px; padding: 0 14px; border: 1px solid var(--tc-border); border-radius: 6px; font-size: 1rem; }
.tc-results { list-style: none; padding: 0; margin: 0; }
.tc-results li { padding: 16px 0; border-bottom: 1px solid var(--tc-border); }
.tc-result-title { font-size: 1.15rem; font-weight: 600; }
.tc-result-cat { margin-left: 10px; font-size: .78rem; color: var(--tc-muted); text-transform: uppercase; }
.tc-result-snippet { margin: 6px 0 0; color: var(--tc-muted); }

/* ---------- Footer ---------- */
.tc-footer {
    margin: 40px auto 0;
    max-width: 900px; width: 100%;
    padding-top: 18px;
    display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px;
    color: var(--tc-muted); font-size: .82rem;
}

/* ---------- Login ---------- */
.tc-login-page {
    display: grid; place-items: center; min-height: 100vh;
    background: linear-gradient(135deg, var(--tc-dark) 0%, var(--tc-blue) 100%);
}
.tc-login-card {
    background: #fff; border-radius: 12px; padding: 36px 34px; width: 360px; max-width: 92vw;
    box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.tc-login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; font-size: 1.1rem; }
.tc-login-card h1 { margin: 0 0 4px; font-size: 1.5rem; color: var(--tc-dark); }
.tc-login-back { display: inline-block; margin-top: 16px; font-size: .9rem; }

/* ---------- Fields ---------- */
.tc-field { display: block; margin: 0 0 16px; }
.tc-field > span { display: block; font-size: .85rem; font-weight: 600; color: var(--tc-text); margin-bottom: 5px; }
.tc-field input, .tc-field textarea {
    width: 100%; padding: 9px 12px; border: 1px solid var(--tc-border); border-radius: 6px; font-size: .95rem; font-family: inherit;
}
.tc-field input:focus, .tc-field textarea:focus { outline: none; border-color: var(--tc-blue); box-shadow: 0 0 0 3px rgba(36,127,181,.15); }
.tc-field-grid { display: flex; gap: 16px; flex-wrap: wrap; }
.tc-field-grid .tc-field { flex: 1; min-width: 180px; }
.tc-field-narrow { flex: 0 0 120px !important; min-width: 0 !important; }

/* ---------- Editor ---------- */
.tc-editor { max-width: 1000px; }
.tc-tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--tc-border); margin: 8px 0 0; }
.tc-tab {
    padding: 10px 18px; border: 0; background: none; cursor: pointer;
    font-size: .92rem; font-weight: 600; color: var(--tc-muted);
    border-bottom: 3px solid transparent; margin-bottom: -2px;
}
.tc-tab:hover { color: var(--tc-blue); }
.tc-tab.active { color: var(--tc-blue); border-bottom-color: var(--tc-blue); }
.tc-tabpanel { display: none; padding: 18px 0; }
.tc-tabpanel.active { display: block; }

.tc-wysiwyg-toolbar { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; background: #f4f7fa; border: 1px solid var(--tc-border); border-bottom: 0; border-radius: 6px 6px 0 0; }
.tc-wysiwyg-toolbar button {
    min-width: 34px; height: 32px; padding: 0 8px; border: 1px solid var(--tc-border);
    background: #fff; border-radius: 5px; cursor: pointer; font-size: .85rem; color: var(--tc-text);
}
.tc-wysiwyg-toolbar button:hover { background: var(--tc-blue-pale); border-color: var(--tc-blue-light); }
.tc-sep { width: 1px; background: var(--tc-border); margin: 2px 4px; }
.tc-wysiwyg {
    min-height: 340px; padding: 18px 20px; border: 1px solid var(--tc-border); border-radius: 0 0 6px 6px;
    background: #fff; overflow-y: auto;
}
.tc-wysiwyg:focus { outline: none; border-color: var(--tc-blue); }

.tc-code {
    width: 100%; min-height: 380px; padding: 14px 16px;
    font-family: "Cascadia Code", Consolas, monospace; font-size: .9rem; line-height: 1.5;
    background: var(--tc-dark-2); color: #e6edf3; border: 1px solid var(--tc-dark); border-radius: 6px;
    resize: vertical; tab-size: 2;
}
.tc-code:focus { outline: none; box-shadow: 0 0 0 3px rgba(36,127,181,.3); }
.tc-hint { color: var(--tc-muted); font-size: .82rem; margin: 8px 0 0; }
.tc-hint.tc-warn { color: var(--tc-orange); }
.tc-editor-actions { display: flex; gap: 10px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--tc-border); }
.tc-editor-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tc-hint kbd { background: #eef3f7; border: 1px solid var(--tc-border); border-radius: 4px; padding: 1px 5px; font-size: .78rem; }

.tc-admin-link { color: var(--tc-blue-light) !important; font-size: .9rem; font-weight: 600; }
.tc-content .tc-admin-link { color: var(--tc-blue) !important; }

/* ---------- Image modal ---------- */
body.tc-modal-open { overflow: hidden; }
.tc-modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px; }
.tc-modal[hidden] { display: none !important; }
.tc-modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.55); }
.tc-modal-dialog { position: relative; background: #fff; border-radius: 12px; box-shadow: 0 24px 80px rgba(0,0,0,.35); max-width: 960px; width: 100%; max-height: 92vh; overflow: auto; }
.tc-img-modal-dialog { max-width: 1100px; }
.tc-modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 22px; border-bottom: 1px solid var(--tc-border); }
.tc-modal-header h2 { margin: 0; font-size: 1.2rem; color: var(--tc-dark); }
.tc-modal-close { background: none; border: 0; font-size: 1.6rem; cursor: pointer; color: var(--tc-muted); line-height: 1; }
.tc-modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--tc-border); }

.tc-img-editor-body { display: grid; grid-template-columns: 1fr 280px; gap: 20px; padding: 18px 22px; }
.tc-img-canvas-wrap { background: #eef3f7; border: 1px solid var(--tc-border); border-radius: 8px; overflow: auto; max-height: 420px; display: flex; justify-content: center; padding: 8px; }
#tc-img-canvas { cursor: crosshair; max-width: 100%; }
.tc-img-controls { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.tc-img-controls label { font-size: .85rem; font-weight: 600; display: flex; flex-direction: column; gap: 4px; }
.tc-img-controls input[type=range] { width: 100%; }
.tc-img-control-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.tc-img-preview-col h3 { margin: 0 0 10px; font-size: .95rem; color: var(--tc-blue); }
.tc-img-preview-box { background: #f4f7fa; border: 1px solid var(--tc-border); border-radius: 8px; padding: 8px; min-height: 120px; }
#tc-img-preview { max-width: 100%; height: auto; display: block; margin: 0 auto; }

/* ---------- Admin image library ---------- */
.tc-admin-images { max-width: 1100px; }
.tc-stats-row { display: flex; gap: 16px; margin: 16px 0 22px; flex-wrap: wrap; }
.tc-stat { background: #f4f7fa; padding: 8px 14px; border-radius: 6px; font-size: .9rem; }
.tc-stat-ok { background: #e8f5e9; color: #2e7d32; }
.tc-stat-warn { background: #fff8e1; color: #e65100; }
.tc-image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.tc-image-card { border: 1px solid var(--tc-border); border-radius: 8px; overflow: hidden; background: #fff; }
.tc-image-card.unused { border-color: #ffe0b2; }
.tc-image-thumb { display: block; background: #eef3f7; height: 140px; overflow: hidden; }
.tc-image-thumb img { width: 100%; height: 100%; object-fit: contain; }
.tc-image-meta { padding: 10px 12px; }
.tc-image-name { font-size: .78rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tc-image-size { font-size: .75rem; color: var(--tc-muted); margin: 4px 0 8px; }
.tc-badge { display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 10px; text-transform: uppercase; letter-spacing: .04em; }
.tc-badge-ok { background: #e8f5e9; color: #2e7d32; }
.tc-badge-warn { background: #fff3e0; color: #e65100; }
.tc-image-usage { list-style: none; margin: 8px 0 0; padding: 0; font-size: .82rem; }
.tc-image-usage li { margin: 3px 0; }
.tc-btn-danger { background: #c0392b; color: #fff; border-color: #c0392b; }
.tc-btn-danger:hover { background: #e74c3c; color: #fff; }
.tc-btn-sm { padding: 4px 10px; font-size: .78rem; }
.tc-image-delete { margin-top: 8px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .tc-menu-toggle { display: block; }
    .tc-header-actions > a:first-child { display: none; }
    .tc-sidebar {
        position: fixed; left: 0; top: var(--tc-header-h); bottom: 0; z-index: 40;
        transform: translateX(-100%); transition: transform .2s ease; box-shadow: 4px 0 20px rgba(0,0,0,.2);
    }
    .tc-sidebar.open { transform: translateX(0); }
    .tc-content { padding: 20px 16px; }
    .tc-article { padding: 22px 20px; }
    .tc-search { max-width: none; }
    .tc-img-editor-body { grid-template-columns: 1fr; }
}
