/* ============================================================
   Боты — дополнение к основной тёмной теме админки
============================================================ */

.bots-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.bot-card {
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 10px;
    padding: 16px 18px;
    transition: border-color .15s, transform .15s;
    position: relative;
}
.bot-card:hover { border-color: #3a3a3a; transform: translateY(-1px); }
.bot-card.inactive { opacity: .65; }
.bot-card.never-start { border-color: #7a5a00; background: #1f1a10; }

.bot-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
    gap: 10px;
}

.bot-name {
    font-size: 16px;
    font-weight: 600;
    color: #eaeaea;
    margin: 0;
    word-break: break-word;
}
.bot-name small {
    display: block;
    font-size: 11px;
    font-weight: normal;
    color: #777;
    margin-top: 3px;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

.bot-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    padding: 4px 9px;
    border-radius: 20px;
    white-space: nowrap;
    font-weight: 500;
}
.bot-status.active   { background: #143d1f; color: #4ade80; border: 1px solid #1e5a2c; }
.bot-status.inactive { background: #3a1a1a; color: #f87171; border: 1px solid #5a2020; }
.bot-status.warn     { background: #3a3010; color: #fbbf24; border: 1px solid #5a4a10; }

.bot-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    font-size: 12px;
    color: #999;
    margin-bottom: 14px;
}
.bot-meta span b { color: #ccc; font-weight: 500; }

.bot-warning {
    background: #3a2010;
    color: #fbbf24;
    font-size: 11px;
    padding: 6px 10px;
    border-radius: 6px;
    margin-bottom: 12px;
    border: 1px solid #5a3a10;
}

.bot-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.btn-sm { padding: 6px 10px; font-size: 12px; line-height: 1; }
.btn-icon { min-width: 34px; text-align: center; }
.btn-danger { background: #7f1d1d; color: #fff; border: 1px solid #991b1b; }
.btn-danger:hover { background: #991b1b; }

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .72);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: modal-fade .12s ease-out;
}
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }

.modal {
    background: #141414;
    border: 1px solid #2a2a2a;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .6);
}
.modal-sm { max-width: 420px; }
.modal-lg { max-width: 900px; }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid #2a2a2a;
    gap: 12px;
}
.modal-header h2 { margin: 0; font-size: 15px; color: #eaeaea; font-weight: 600; }
.modal-actions { display: flex; gap: 8px; align-items: center; }

.modal-body {
    padding: 14px 18px;
    overflow: auto;
    flex: 1;
    min-height: 0;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 18px;
    border-top: 1px solid #2a2a2a;
}

.logs-pre {
    background: #0a0a0a;
    color: #c8c8c8;
    padding: 12px;
    border-radius: 6px;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 12px;
    line-height: 1.45;
    overflow: auto;
    max-height: 65vh;
    white-space: pre-wrap;
    word-break: break-all;
    margin: 0;
}

.env-textarea {
    width: 100%;
    min-height: 400px;
    background: #0a0a0a;
    color: #c8c8c8;
    border: 1px solid #2a2a2a;
    border-radius: 6px;
    padding: 12px;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 12px;
    line-height: 1.5;
    resize: vertical;
    outline: none;
}
.env-textarea:focus { border-color: #444; }

.env-hint { margin-top: 8px; font-size: 11px; color: #666; }

.ws-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #999;
    cursor: pointer;
    user-select: none;
}
.ws-toggle input { accent-color: #f5c518; }

.auto-refresh { font-size: 12px; color: #666; margin-left: auto; }
.auto-refresh b { color: #999; }

.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    color: #eaeaea;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    min-width: 240px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .5);
    animation: toast-in .18s ease-out;
    pointer-events: auto;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

.toast.ok   { border-color: #1e5a2c; background: #143d1f; }
.toast.err  { border-color: #5a2020; background: #3a1a1a; }
.toast.info { border-color: #2a4a7a; background: #14243d; }

/* ============================================================
   Цветовая индикация загрузки RAM у ботов
   Пороги: <100 / 100-200 / 200-400 / >=400 MB
============================================================ */

.bot-meta .ram-ok   { color: #4ade80; }
.bot-meta .ram-mid  { color: #fbbf24; }
.bot-meta .ram-warn { color: #fb923c; }
.bot-meta .ram-crit { color: #f87171; }

/* Для ram-crit — мягкая пульсация, чтобы глаз цеплялся */
.bot-meta .ram-crit b { animation: ram-pulse 1.6s ease-in-out infinite; }
@keyframes ram-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: .55; }
}

/* Цветной кружок-индикатор перед числом (опционально) */
.bot-meta .ram-ok::before   { content: '🟢'; margin-right: 2px; }
.bot-meta .ram-mid::before  { content: '🟡'; margin-right: 2px; }
.bot-meta .ram-warn::before { content: '🟠'; margin-right: 2px; }
.bot-meta .ram-crit::before { content: '🔴'; margin-right: 2px; }

/* ============================================================
   Форма «Добавить бота»
============================================================ */

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.form-field > label {
    font-size: 12px;
    color: #aaa;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.form-field > small {
    font-size: 11px;
    color: #666;
    margin-top: -2px;
}

.form-field input[type="text"],
.form-field select,
.form-field textarea {
    background: #0a0a0a;
    color: #eaeaea;
    border: 1px solid #2a2a2a;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
    width: 100%;
    box-sizing: border-box;
}

.form-field input[type="text"]:focus,
.form-field select:focus,
.form-field textarea:focus {
    border-color: #f5c518;
}

.form-field textarea {
    resize: vertical;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 12px;
    line-height: 1.5;
}

.form-field input[type="checkbox"] {
    accent-color: #f5c518;
    width: 16px;
    height: 16px;
    cursor: pointer;
    margin: 0;
}

.form-field > label:has(input[type="checkbox"]) {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #ccc;
    text-transform: none;
    letter-spacing: 0;
    font-weight: normal;
    cursor: pointer;
    padding: 4px 0;
}

/* Pub-key блок — подсветим */
#add-pubkey-block {
    background: #14243d;
    border: 1px solid #2a4a7a;
    border-radius: 8px;
    padding: 12px;
}

#add-pubkey-block > label {
    color: #93c5fd;
    text-transform: none;
    letter-spacing: 0;
    font-weight: 500;
    font-size: 13px;
}

/* Лог создания — чуть выше, чтобы видеть больше */
#add-bot-log {
    min-height: 120px;
    background: #0a0a0a;
}

/* Модалка добавления — не на всю ширину */
#modal-add-bot .modal {
    max-width: 900px;
    width: 95vw;
}

/* Кнопка "Создать" в шапке формы */
#add-bot-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

@media (max-width: 640px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}
