/* =============================================
   ===== CHUDOPOSTER FRONTEND STYLES =====
   ============================================= */

/* ===== СПИСОК СВЯЗОК В САЙДБАРЕ ===== */
.chp-link-item {
    padding: 10px 12px;
    background: #1c1c24;
    border: 1px solid #2a2a32;
    border-radius: 8px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.chp-link-item:hover {
    border-color: #5a7bff;
    background: #24242e;
}
.chp-link-title {
    font-size: 13px;
    font-weight: 600;
    color: #e0e0e0;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chp-link-meta {
    font-size: 11px;
    color: #6a6a7a;
    margin-top: 3px;
}

body.light .chp-link-item {
    background: #ffffff;
    border-color: #e2e8f0;
}
body.light .chp-link-item:hover {
    background: #f8fafc;
    border-color: #046bd2;
}
body.light .chp-link-title { color: #0f172a; }
body.light .chp-link-meta  { color: #64748b; }

/* ===== БЛОК ТАРИФА В САЙДБАРЕ ===== */
.chp-tariff-block {
    margin-top: 16px;
    padding: 12px 14px;
    background: #1c1c24;
    border: 1px solid #2a2a32;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.6;
}
.chp-tariff-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}
.chp-tariff-row:last-child { margin-bottom: 0; }
.chp-tariff-icon { flex-shrink: 0; }
.chp-tariff-label { color: #a0a0a0; }
.chp-tariff-value { color: #f5c842; font-weight: 700; margin-left: auto; }
body.light .chp-tariff-block {
    background: #ffffff;
    border-color: #e2e8f0;
}
body.light .chp-tariff-label { color: #64748b; }
body.light .chp-tariff-value { color: #d4a800; }

/* ===== МОДАЛКА ===== */
#chp-modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.75);
    z-index: 100000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 20px;
    padding-top: 30px;
    box-sizing: border-box;
}

#chp-modal {
    background: #1c1c24;
    border: 1px solid #2a2a32;
    border-radius: 16px;
    width: 100%;
    max-width: 560px;
    max-height: calc(100vh - 60px);
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.chp-modal-header {
    padding: 20px 24px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #2a2a32;
    flex-shrink: 0;
}
.chp-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #e0e0e0;
}
#chp-modal-close {
    background: transparent;
    border: none;
    color: #6a6a7a;
    font-size: 26px;
    cursor: pointer;
    line-height: 1;
    padding: 0 6px;
}
#chp-modal-close:hover { color: #e0e0e0; }

.chp-modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.chp-modal-footer {
    padding: 16px 24px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
    background: #1c1c24;
    border-top: 1px solid #2a2a32;
    z-index: 10;
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
}
body.light .chp-modal-footer {
    background: #ffffff;
    border-top-color: #e2e8f0;
}

/* ===== ПОЛЯ ===== */
.chp-field {
    margin-bottom: 20px;
}
.chp-field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #a0a0a0;
    margin-bottom: 8px;
}
.chp-hint {
    font-size: 11px;
    color: #6a6a7a;
    line-height: 1.4;
    margin-bottom: 8px;
}

.chp-field textarea,
.chp-field input[type="text"],
.chp-field input[type="time"] {
    width: 100%;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid #2a2a32;
    background: #0f0f12;
    color: #e0e0e0;
    font-size: 14px;
    font-family: inherit;
    box-sizing: border-box;
    resize: vertical;
}
.chp-field textarea:focus,
.chp-field input:focus {
    outline: none;
    border-color: #5a7bff;
}

/* ===== КНОПКИ ===== */
.chp-btn {
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
    font-family: inherit;
}
.chp-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.chp-btn-primary { background: #5a7bff; color: #fff; }
.chp-btn-primary:hover:not(:disabled) { background: #4a6adf; }
.chp-btn-secondary {
    background: transparent;
    color: #5a7bff;
    border: 1px dashed #5a7bff;
}
.chp-btn-secondary:hover:not(:disabled) { background: rgba(90, 123, 255, 0.1); }
.chp-btn-danger { background: #dc2626; color: #fff; }
.chp-btn-danger:hover:not(:disabled) { background: #b91c1c; }
.chp-btn-ghost { background: transparent; color: #6a6a7a; }
.chp-btn-ghost:hover:not(:disabled) { color: #e0e0e0; }

/* ===== БОТЫ ===== */
.chp-bot-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
}
.chp-bot-item {
    padding: 10px 14px;
    background: #0f0f12;
    border: 1px solid #2a2a32;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.15s;
    font-size: 13px;
    color: #e0e0e0;
}
.chp-bot-item:hover { border-color: #5a7bff; }
.chp-bot-item.active {
    border-color: #4ade80 !important;
    background: rgba(74, 222, 128, 0.08) !important;
}

/* ===== КАНАЛЫ ===== */
.chp-channel-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
}
.chp-channel-item {
    padding: 10px 14px;
    background: #0f0f12;
    border: 1px solid #2a2a32;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.15s;
    font-size: 13px;
    color: #e0e0e0;
}
.chp-channel-item:hover { border-color: #5a7bff; }
.chp-channel-item.active {
    border-color: #4ade80 !important;
    background: rgba(74, 222, 128, 0.08) !important;
}

/* ===== ЧИПСЫ ===== */
.chp-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.chp-chip {
    display: inline-block;
    padding: 6px 14px;
    background: #0f0f12;
    border: 1px solid #2a2a32;
    border-radius: 16px;
    cursor: pointer;
    font-size: 13px;
    color: #a0a0a0;
    transition: all 0.15s;
    user-select: none;
}
.chp-chip:hover {
    border-color: #5a7bff;
    color: #e0e0e0;
}
.chp-chip.active {
    background: rgba(90, 123, 255, 0.2);
    border-color: #5a7bff;
    color: #5a7bff;
    font-weight: 600;
}

/* ===== ВРЕМЯ ===== */
.chp-time-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 6px;
}
.chp-time-row input { flex: 1; }
.chp-time-remove {
    background: transparent;
    border: 1px solid #3a3a4a;
    color: #a0a0a0;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    flex-shrink: 0;
    transition: all 0.15s;
}
.chp-time-remove:hover {
    background: #3a1f1f;
    border-color: #ff4444;
    color: #ff4444;
}

/* ===== СТАТУС ===== */
.chp-status {
    display: none;
    padding: 10px 24px 16px;
    font-size: 13px;
    text-align: center;
}

.chp-limit-info {
    padding: 10px 14px;
    background: rgba(90, 123, 255, 0.06);
    border: 1px solid rgba(90, 123, 255, 0.2);
    border-radius: 8px;
    font-size: 12px;
    color: #a0a0a0;
    margin-bottom: 16px;
}

/* ===== ИСТОРИЯ ===== */
#chp-history-block {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #2a2a32;
    position: static;
    display: block;
}
#chp-history-block label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #a0a0a0;
    margin-bottom: 8px;
}
.chp-history {
    max-height: 300px;
    overflow-y: auto;
    padding: 8px;
    background: #0f0f12;
    border: 1px solid #2a2a32;
    border-radius: 8px;
}
.chp-history-item {
    padding: 8px;
    border-bottom: 1px solid #2a2a32;
    font-size: 12px;
    color: #d0d0d8;
}
.chp-history-item:last-child { border-bottom: none; }

body.light #chp-history-block {
    border-top-color: #e2e8f0;
}
body.light .chp-history {
    background: #f8fafc;
    border-color: #e2e8f0;
}
body.light .chp-history-item {
    border-color: #e2e8f0;
    color: #475569;
}

/* ===== МОДАЛКА БОТА ===== */
#chp-bot-modal {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 100001;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}
.chp-bot-inner {
    background: #1c1c24;
    border: 1px solid #2a2a32;
    border-radius: 16px;
    padding: 24px;
    max-width: 460px;
    width: 100%;
}
.chp-bot-inner h3 {
    margin: 0 0 8px 0;
    color: #e0e0e0;
    font-size: 18px;
}
.chp-bot-inner p {
    margin: 0 0 16px 0;
    color: #a0a0a0;
    font-size: 13px;
    line-height: 1.5;
}
.chp-bot-inner a { color: #5a7bff; }
#chp-bot-token {
    width: 100%;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid #2a2a32;
    background: #0f0f12;
    color: #e0e0e0;
    font-size: 14px;
    font-family: monospace;
    box-sizing: border-box;
    margin-bottom: 14px;
}
.chp-bot-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* ===== СВЕТЛАЯ ТЕМА ===== */
body.light #chp-modal,
body.light .chp-bot-inner {
    background: #ffffff;
    border-color: #e2e8f0;
}
body.light .chp-modal-header {
    border-color: #e2e8f0;
}
body.light .chp-modal-header h3,
body.light .chp-bot-inner h3 { color: #0f172a; }
body.light .chp-bot-inner p { color: #475569; }
body.light .chp-field label { color: #475569; }
body.light .chp-hint { color: #94a3b8; }

body.light .chp-field textarea,
body.light .chp-field input,
body.light #chp-bot-token {
    background: #f8fafc;
    border-color: #e2e8f0;
    color: #1e293b;
}
body.light .chp-bot-item,
body.light .chp-channel-item,
body.light .chp-chip {
    background: #f8fafc;
    border-color: #e2e8f0;
    color: #1e293b;
}
body.light .chp-bot-item:hover,
body.light .chp-channel-item:hover,
body.light .chp-chip:hover { border-color: #046bd2; }
body.light .chp-chip.active {
    background: rgba(4, 107, 210, 0.1);
    border-color: #046bd2;
    color: #046bd2;
}

body.light .chp-btn-primary { background: #046bd2; }
body.light .chp-btn-primary:hover:not(:disabled) { background: #035aa8; }
body.light .chp-btn-secondary { color: #046bd2; border-color: #046bd2; }
body.light .chp-btn-secondary:hover:not(:disabled) { background: rgba(4, 107, 210, 0.08); }
body.light .chp-btn-ghost { color: #64748b; }
body.light .chp-btn-ghost:hover { color: #0f172a; }

body.light .chp-limit-info {
    background: rgba(4, 107, 210, 0.05);
    border-color: rgba(4, 107, 210, 0.2);
    color: #475569;
}

body.light #chp-modal-close { color: #64748b; }
body.light #chp-modal-close:hover { color: #0f172a; }

/* ===== АДАПТАЦИЯ ===== */
@media (max-width: 600px) {
    #chp-modal {
        max-height: 95vh;
        border-radius: 12px;
    }
    .chp-modal-header { padding: 16px 16px 10px; }
    .chp-modal-body   { padding: 14px 16px; }
    .chp-modal-footer { padding: 12px 16px; }
    .chp-modal-footer .chp-btn { flex: 1; min-width: 0; padding: 10px 12px; font-size: 13px; }
    .chp-modal-header h3 { font-size: 16px; }
    .chp-field { margin-bottom: 16px; }
}