/* =====================================================
   sysadmin-scripts — main.css
   ===================================================== */

/* ── Variables ─────────────────────────────────────── */
:root {
    --bg:          #0d1117;
    --surface:     #161b22;
    --surface-2:   #21262d;
    --border:      #30363d;
    --text:        #e6edf3;
    --text-muted:  #8b949e;
    --text-faint:  #6e7681;
    --accent:      #3fb950;
    --accent-dim:  #1a7f37;
    --blue:        #58a6ff;
    --warn:        #e3b341;
    --danger:      #f85149;
    --sidebar-w:   280px;
    --header-h:    60px;
    --r:           6px;
    --r-lg:        10px;
    --mono:        'Courier New', Consolas, monospace;
    --ease:        150ms ease;
}

/* ── Reset ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: .9375rem;
    line-height: 1.65;
    min-height: 100vh;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }

/* ── Layout ────────────────────────────────────────── */
.layout {
    display: flex;
    min-height: 100vh;
    padding-top: var(--header-h);
}

/* ── Header ────────────────────────────────────────── */
.site-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--header-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    z-index: 200;
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
}
/* Obsah headeru kopíruje šířku contentu — zarovnání s hlavní oblastí */
.header-inner {
    display: flex;
    align-items: center;
    gap: .875rem;
    width: 100%;
    max-width: calc(var(--sidebar-w) + 1120px + 2.5rem);
    margin: 0 auto;
    padding-left: var(--sidebar-w);
}

.logo {
    display: flex;
    align-items: center;
    gap: .625rem;
    text-decoration: none;
    flex-shrink: 0;
}
.logo:hover { text-decoration: none; }
.logo img { height: 36px; width: auto; }

.header-search {
    flex: 1;
    max-width: 420px;
    position: relative;
}
.header-search input {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: .375rem 1rem .375rem 2.25rem;
    color: var(--text);
    font-size: .875rem;
    outline: none;
    transition: border-color var(--ease);
}
.header-search input::placeholder { color: var(--text-faint); }
.header-search input:focus { border-color: var(--accent); }
.header-search .si {
    position: absolute;
    left: .75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-faint);
    font-size: .8rem;
    pointer-events: none;
}

/* Live search dropdown */
.search-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    box-shadow: 0 8px 24px rgba(0,0,0,.5);
    z-index: 300;
    max-height: 380px;
    overflow-y: auto;
}
.search-dropdown.open { display: block; }
.sd-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .625rem 1rem;
    text-decoration: none;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    transition: background var(--ease);
    font-size: .875rem;
}
.sd-item:last-child { border-bottom: none; }
.sd-item:hover { background: var(--surface-2); text-decoration: none; }
.sd-item-title { font-weight: 500; flex: 1; }
.sd-item-cat { font-size: .7rem; color: var(--text-muted); white-space: nowrap; }
.sd-empty { padding: 1rem; text-align: center; color: var(--text-muted); font-size: .875rem; }

.header-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: .625rem;
}

/* Language switcher */
.lang-switcher { display: flex; gap: .25rem; }
.lang-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-muted);
    padding: .2rem .45rem;
    font-size: .7rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    letter-spacing: .5px;
    transition: all var(--ease);
}
.lang-btn:hover, .lang-btn.active {
    border-color: var(--accent);
    color: var(--accent);
    text-decoration: none;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--r);
    width: 34px; height: 34px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: .9rem;
}

/* ── Sidebar ───────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: 0;
    overflow-y: auto;
    background: var(--surface);
    border-right: 1px solid var(--border);
    z-index: 100;
    transition: transform var(--ease);
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.sidebar-label {
    padding: 1.25rem 1rem .375rem;
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-faint);
    font-weight: 700;
}

.cat-list, .subcat-list { list-style: none; }

.cat-link, .subcat-link {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .45rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: .8375rem;
    border-left: 3px solid transparent;
    transition: all var(--ease);
    cursor: pointer;
    background: none;
    border-top: none;
    border-right: none;
    border-bottom: none;
    width: 100%;
    text-align: left;
}
.cat-link:hover, .subcat-link:hover {
    background: var(--surface-2);
    color: var(--text);
    text-decoration: none;
}
.cat-link.active { color: var(--accent); border-left-color: var(--accent); background: rgba(63,185,80,.08); }
.subcat-link.active { color: var(--accent); border-left-color: var(--accent); }

.cat-link .ci { width: 16px; text-align: center; font-size: .8125rem; flex-shrink: 0; }
.cat-link .cn { flex: 1; }
.cat-link .cc {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0 5px;
    font-size: .65rem;
    color: var(--text-faint);
    font-weight: 700;
    min-width: 20px;
    text-align: center;
}
.cat-link .ct {
    font-size: .65rem;
    color: var(--text-faint);
    transition: transform var(--ease);
    flex-shrink: 0;
}
.cat-item.open > .cat-link .ct { transform: rotate(90deg); }

.subcat-list {
    display: none;
    border-left: 1px solid var(--border);
    margin-left: 1.25rem;
}
.cat-item.open > .subcat-list { display: block; }

.subcat-link {
    padding: .35rem 1rem .35rem 1.5rem;
    font-size: .8125rem;
    border-left: none;
    border-left: 2px solid transparent;
}
.subcat-link .cc {
    margin-left: auto;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0 5px;
    font-size: .65rem;
    color: var(--text-faint);
    font-weight: 700;
}

/* Sidebar overlay (mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    z-index: 99;
}
.sidebar-overlay.show { display: block; }

/* ── Main Content ──────────────────────────────────── */
.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    padding: 2rem 2.5rem;
    min-width: 0;
}
.container {
    max-width: 1120px;
    margin: 0 auto;
}

/* ── Hero ──────────────────────────────────────────── */
.hero {
    background: linear-gradient(135deg, var(--surface) 0%, #0a0e14 100%);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 2.25rem 2.5rem;
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
}
.hero::after {
    content: '';
    position: absolute;
    top: -40%;
    right: -5%;
    width: 280px;
    height: 280px;
    background: radial-gradient(circle, rgba(63,185,80,.07) 0%, transparent 70%);
    pointer-events: none;
}
.hero h1 {
    font-family: var(--mono);
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: .4rem;
}
.hero h1 em { color: var(--accent); font-style: normal; }
.hero p { color: var(--text-muted); font-size: .9rem; margin-bottom: 1.5rem; }
.hero-stats { display: flex; gap: 2rem; flex-wrap: wrap; }
.hs-num {
    font-family: var(--mono);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--accent);
    line-height: 1;
}
.hs-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); }

/* ── Section title ─────────────────────────────────── */
.section-title {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-faint);
    font-weight: 700;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: .75rem;
}
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ── Category grid (homepage) ──────────────────────── */
.cat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: .875rem;
    margin-bottom: 2.5rem;
}
.cat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 1.125rem;
    text-decoration: none;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: .875rem;
    transition: all var(--ease);
    position: relative;
    overflow: hidden;
}
.cat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--cc, var(--accent));
    transform: scaleX(0);
    transform-origin: left;
    transition: transform var(--ease);
}
.cat-card:hover { border-color: var(--cc, var(--accent)); background: var(--surface-2); text-decoration: none; transform: translateY(-2px); }
.cat-card:hover::before { transform: scaleX(1); }
.cat-card-icon {
    width: 42px; height: 42px;
    border-radius: var(--r);
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}
.cat-card-body { flex: 1; min-width: 0; }
.cat-card-name { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-card-meta { font-size: .75rem; color: var(--text-muted); margin-top: .125rem; }
.cat-card-arrow { color: var(--text-faint); font-size: .8rem; }

/* ── Script list ───────────────────────────────────── */
.script-list { list-style: none; }
.script-row {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    margin-bottom: .5rem;
    transition: border-color var(--ease);
}
.script-row:hover { border-color: var(--blue); }
.script-row-link {
    display: flex;
    align-items: center;
    gap: .875rem;
    padding: .875rem 1.125rem;
    text-decoration: none;
    color: var(--text);
}
.script-row-link:hover { text-decoration: none; }

.type-badge {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .175rem .5rem;
    border-radius: 4px;
    font-size: .65rem;
    font-weight: 700;
    text-transform: uppercase;
    flex-shrink: 0;
    letter-spacing: .3px;
}
.type-script { background: rgba(88,166,255,.12); color: var(--blue); border: 1px solid rgba(88,166,255,.25); }
.type-guide  { background: rgba(227,179,65,.12);  color: var(--warn); border: 1px solid rgba(227,179,65,.25); }

.script-row-title { flex: 1; font-weight: 500; font-size: .9rem; }

.tag-list { display: flex; gap: .3rem; flex-wrap: wrap; }
.tag {
    display: inline-block;
    padding: .125rem .45rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: .675rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: all var(--ease);
}
.tag:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

.script-row-date { font-size: .725rem; color: var(--text-faint); flex-shrink: 0; }

/* ── Page header ───────────────────────────────────── */
.page-hdr {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.75rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}
.page-hdr-icon {
    width: 52px; height: 52px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}
.page-hdr-info h1 { font-size: 1.4rem; font-weight: 700; margin-bottom: .2rem; }
.page-hdr-info p  { color: var(--text-muted); font-size: .875rem; }

/* Subcategory cards */
.subcat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: .75rem;
    margin-bottom: 2rem;
}
.subcat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: .875rem 1rem;
    text-decoration: none;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: .75rem;
    transition: all var(--ease);
    font-size: .875rem;
}
.subcat-card:hover { border-color: var(--blue); background: var(--surface-2); text-decoration: none; }
.subcat-card-icon { font-size: 1.1rem; flex-shrink: 0; }
.subcat-card-name { font-weight: 500; }
.subcat-card-count { font-size: .75rem; color: var(--text-muted); }
.subcat-card-arrow { margin-left: auto; color: var(--text-faint); font-size: .75rem; }

/* ── Breadcrumb ────────────────────────────────────── */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .8rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb .sep { color: var(--text-faint); }

/* ── Script detail ─────────────────────────────────── */
.script-hdr { margin-bottom: 1.75rem; }
.script-title { font-size: 1.6rem; font-weight: 700; margin-bottom: .625rem; line-height: 1.3; }
.script-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    color: var(--text-muted);
    font-size: .8rem;
}
.script-meta i { margin-right: .25rem; }

.script-body {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 2rem 2.25rem;
    line-height: 1.75;
}

/* Rich text */
.script-body h1, .script-body h2, .script-body h3, .script-body h4 {
    color: var(--text);
    margin: 1.75rem 0 .75rem;
    line-height: 1.3;
}
.script-body h1 { font-size: 1.5rem; }
.script-body h2 { font-size: 1.2rem; border-bottom: 1px solid var(--border); padding-bottom: .5rem; }
.script-body h3 { font-size: 1.05rem; }
.script-body h4 { font-size: .95rem; }
.script-body p  { margin-bottom: 1rem; color: var(--text-muted); }
.script-body ul, .script-body ol { margin: .5rem 0 1rem 1.5rem; color: var(--text-muted); }
.script-body li { margin-bottom: .25rem; }
.script-body strong, .script-body b { color: var(--text); font-weight: 600; }
.script-body em, .script-body i { font-style: italic; }
.script-body u  { text-decoration: underline; }
.script-body s  { text-decoration: line-through; color: var(--text-muted); }
.script-body a  { color: var(--blue); }
.script-body hr { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

/* Inline code */
.script-body :not(pre) > code {
    font-family: var(--mono);
    font-size: .85em;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: .1em .35em;
    color: var(--accent);
}

/* Code blocks */
.code-wrap { margin: 1.25rem 0; border-radius: var(--r); overflow: hidden; border: 1px solid var(--border); }
.code-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface-2);
    padding: .35rem .875rem;
    border-bottom: 1px solid var(--border);
}
.code-lang {
    font-family: var(--mono);
    font-size: .65rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-faint);
    font-weight: 700;
}
.copy-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-muted);
    font-size: .7rem;
    padding: .2rem .5rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    transition: all var(--ease);
}
.copy-btn:hover { border-color: var(--accent); color: var(--accent); }
.copy-btn.ok  { border-color: var(--accent); color: var(--accent); }

.script-body pre {
    margin: 0;
    background: var(--bg);
    padding: 1rem 1.25rem;
    overflow-x: auto;
    font-size: .875rem;
    line-height: 1.55;
}
.script-body pre code { background: none; border: none; padding: 0; color: var(--text); font-size: 1em; }
.script-body pre:first-child { border-radius: var(--r) var(--r) 0 0; }

/* ── Recent scripts (homepage) ─────────────────────── */
.recent-list { list-style: none; }
.recent-item {
    display: flex;
    align-items: center;
    gap: .875rem;
    padding: .625rem 0;
    border-bottom: 1px solid var(--border);
}
.recent-item:last-child { border-bottom: none; }
.recent-link { flex: 1; color: var(--text); font-size: .875rem; font-weight: 500; }
.recent-link:hover { color: var(--blue); text-decoration: none; }
.recent-cat {
    font-size: .7rem;
    color: var(--text-muted);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: .125rem .45rem;
    white-space: nowrap;
}

/* ── Search page ───────────────────────────────────── */
.search-hdr { margin-bottom: 1.5rem; }
.search-q { font-size: 1.2rem; font-weight: 600; margin-bottom: .25rem; }
.search-q span { color: var(--accent); }
.search-count { color: var(--text-muted); font-size: .875rem; }

/* ── Empty state ───────────────────────────────────── */
.empty {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}
.empty i { font-size: 2.5rem; color: var(--text-faint); display: block; margin-bottom: .875rem; }
.empty h3 { font-size: 1.1rem; color: var(--text); margin-bottom: .5rem; }

/* ── Footer ────────────────────────────────────────── */
.site-footer {
    margin-left: var(--sidebar-w);
    text-align: center;
    padding: 1.5rem 2.5rem;
    color: var(--text-faint);
    font-size: .775rem;
    border-top: 1px solid var(--border);
    margin-top: 3rem;
}
.site-footer .container {
    max-width: 1120px;
    margin: 0 auto;
}

/* ── Prism.js overrides ────────────────────────────── */
code[class*="language-"], pre[class*="language-"] {
    background: transparent !important;
    text-shadow: none !important;
    font-family: var(--mono) !important;
}
.token.comment   { color: #6e7681; }
.token.string    { color: #a5d6ff; }
.token.keyword   { color: #ff7b72; }
.token.function  { color: #d2a8ff; }
.token.number    { color: #79c0ff; }
.token.operator  { color: #e6edf3; }
.token.class-name{ color: #ffa657; }
.token.punctuation { color: #8b949e; }

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; padding: 1.5rem; }
    .site-footer { margin-left: 0; padding: 1.5rem; }
    .sidebar-toggle { display: flex; }
    .header-inner { padding-left: 0; }
}

@media (max-width: 640px) {
    .main { padding: 1rem; }
    .hero { padding: 1.25rem; }
    .hero h1 { font-size: 1.25rem; }
    .hero-stats { gap: 1.25rem; }
    .cat-grid { grid-template-columns: 1fr 1fr; }
    .script-row-date, .tag-list { display: none; }
    .script-body { padding: 1.25rem; }
    .header-search { max-width: 180px; }
}

@media (max-width: 420px) {
    .header-search { display: none; }
    .lang-switcher { display: none; }
    .cat-grid { grid-template-columns: 1fr; }
}
