/*******************************
    ГЛОБАЛЬНЫЕ ПЕРЕМЕННЫЕ
*******************************/
:root {
    --bg: #f6f6f6;
    --text: #222;

    --panel: #ffffff;
    --panel-border: #ddd;

    --code-bg: #f0f0f0;

    --accent: #333;
    --hover: rgba(0,0,0,0.05);

    --radius: 8px;
}

/* ====== DARK THEME ====== */
:root.dark {
    --bg: #121212;
    --text: #e6e6e6;

    --panel: #1d1d1d;
    --panel-border: #333;

    --code-bg: #161616;

    --accent: #ddd;
    --hover: rgba(255,255,255,0.07);
}

/* Плавные переходы */
body, .panel, .settings-card, .file-tree, header, .metric-card {
    transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}


/*******************************
             БАЗА
*******************************/
body {
    background: var(--bg);
    color: var(--text);
    margin: 0;
    font-family: system-ui, sans-serif;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--panel);
    padding: 15px 20px;
    border-bottom: 1px solid var(--panel-border);
}


/*******************************
            TOOLBAR
*******************************/
.toolbar {
    display: flex;
    gap: 10px;
    padding: 15px 20px;
    align-items: center;
    flex-wrap: wrap;
}

button, .button {
    background: var(--accent);
    color: var(--bg);
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
}

button:hover, .button:hover {
    opacity: 0.8;
}

input[type="text"] {
    padding: 6px 10px;
    border-radius: var(--radius);
    border: 1px solid var(--panel-border);
    background: var(--panel);
    color: var(--text);
}


/*******************************
           PANELS
*******************************/
.panel {
    margin: 20px;
    background: var(--panel);
    padding: 15px 20px;
    border-radius: var(--radius);
    border: 1px solid var(--panel-border);
}

pre {
    background: var(--code-bg);
    padding: 15px;
    border-radius: var(--radius);
    max-height: 65vh;
    overflow: auto;
}


/*******************************
        COLLAPSIBLE BLOCKS
*******************************/
.collapsible {
    cursor: pointer;
    position: relative;
    padding-right: 20px;
}

.collapsible::after {
    content: "▼";
    position: absolute;
    right: 0;
    transition: transform 0.25s;
}

.collapsible.active::after {
    transform: rotate(-180deg);
}

.content {
    display: none;
    padding-top: 10px;
}

.content.open {
    display: block;
}

.highlight {
    background: #ffe08a;
    padding: 2px 4px;
    border-radius: 4px;
}

body.dark .highlight {
    background: #6b5200;
}


/*******************************
           METRICS
*******************************/
.metrics-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.metric-card {
    flex: 1 1 150px;
    min-width: 150px;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    padding: 10px 12px;
}

.metric-label {
    font-size: 12px;
    opacity: 0.8;
}

.metric-value {
    font-size: 20px;
    font-weight: 600;
    margin-top: 4px;
}

.chart-wrapper {
    max-width: 600px;
}


/*******************************
         SETTINGS PAGE
*******************************/
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.settings-card {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    padding: 12px;
}

.settings-card h3 {
    margin: 0 0 6px;
    font-size: 15px;
}

.item-row {
    display: flex;
    gap: 6px;
    margin-bottom: 4px;
}

.item-row input {
    flex: 1;
}

.small-btn {
    padding: 4px 8px;
    font-size: 12px;
}

#statusBlock {
    margin-top: 10px;
    white-space: pre-wrap;
}


/*******************************
            FILE TREE
*******************************/
.file-tree {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    padding: 10px;
    max-height: 45vh;
    overflow-y: auto;
    font-family: monospace;
    font-size: 14px;
}

.folder {
    cursor: pointer;
    font-weight: bold;
}

.file-item {
    cursor: pointer;
    padding: 2px 0;
    user-select: none;
}

.file-item:hover {
    background: var(--hover);
}

.indent-file {
    padding-left: 20px;
}

.folder-children {
    padding-left: 16px;
}


/*******************************
          THEME BUTTON
*******************************/
#themeToggle {
    padding: 6px 10px;
    border-radius: var(--radius);
    background: var(--panel);
    border: 1px solid var(--panel-border);
    cursor: pointer;
}

#themeToggle:hover {
    background: var(--hover);
}

/*******************************
          THEME SWITCH
*******************************/
.theme-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
}

.theme-switch input {
    display: none;
}

.switch-track {
    position: absolute;
    inset: 0;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.3s, border-color 0.3s;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px;
    font-size: 14px;
    color: var(--text);
}

.icon {
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.25s, transform 0.3s;
}

.sun {
    color: #ffcc00;
}

.moon {
    color: #c7d7ff;
}

/* положение переключателя */
.theme-switch input + .switch-track::before {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    background: var(--accent);
    border-radius: 50%;
    top: 1.5px;
    left: 2px;
    transition: transform 0.25s;
}

/* включена тёмная тема */
.theme-switch input:checked + .switch-track::before {
    transform: translateX(24px);
}

/* иконки */
.theme-switch input + .switch-track .sun {
    opacity: 1;
    transform: translateY(0);
}

.theme-switch input:checked + .switch-track .sun {
    opacity: 0;
    transform: translateY(4px);
}

.theme-switch input + .switch-track .moon {
    opacity: 0;
    transform: translateY(4px);
}

.theme-switch input:checked + .switch-track .moon {
    opacity: 1;
    transform: translateY(0);
}

.back-btn {
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--panel-border);
}
.back-btn:hover {
    background: var(--hover);
}