* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.panel {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* === СЕКЦИЯ ПОДКЛЮЧЕНИЯ === */
.connection-section {
    display: grid;
    grid-template-columns: 1fr 1fr auto auto;
    gap: 15px;
    align-items: end;
    margin-bottom: 30px;
    padding: 25px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 15px;
}

.input-group {
    display: flex;
    flex-direction: column;
}

.input-group label {
    font-weight: 600;
    margin-bottom: 5px;
    color: #333;
}

.url-input, .token-input {
    padding: 12px 15px;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
    font-family: 'Courier New', monospace;
}

.url-input:focus, .token-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* === КНОПКИ === */
.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
}

.btn-connect {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
}

.btn-connect:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(76, 175, 80, 0.4);
}

.btn-disconnect {
    background: linear-gradient(135deg, #f44336, #da190b);
    color: white;
}

.btn-disconnect:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(244, 67, 54, 0.4);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-secondary {
    background: linear-gradient(135deg, #6c757d, #5a6268);
    color: white;
    font-size: 12px;
    padding: 8px 16px;
}

.btn-secondary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(108, 117, 125, 0.4);
}

/* === СТАТУС СОЕДИНЕНИЯ === */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 16px;
}

.status-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.status-connected { color: #4CAF50; }
.status-connected .status-dot { background: #4CAF50; }

.status-disconnected { color: #f44336; }
.status-disconnected .status-dot { background: #f44336; }

.status-connecting { color: #ff9800; }
.status-connecting .status-dot { background: #ff9800; }

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* === КАНАЛЫ === */
.channels-section {
    margin-bottom: 30px;
    padding: 25px;
    background: #f8f9fa;
    border-radius: 15px;
}

.channels-section h3 {
    margin-bottom: 20px;
    color: #333;
    font-size: 18px;
}

.channels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.channel-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    border: 2px solid #e1e8ed;
    transition: all 0.3s ease;
}

.channel-card:hover {
    border-color: #667eea;
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.1);
}

.channel-card.subscribed {
    border-color: #4CAF50;
    background: linear-gradient(135deg, #f1f8e9 0%, #e8f5e8 100%);
}

.channel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.channel-name {
    font-weight: 600;
    font-size: 16px;
}

.channel-status {
    font-size: 18px;
}

.channel-description {
    color: #666;
    font-size: 13px;
    margin-bottom: 15px;
    line-height: 1.4;
}

.btn-channel-toggle {
    width: 100%;
    padding: 10px;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-channel-toggle:hover {
    background: #667eea;
    color: white;
}

.btn-channel-toggle.subscribed {
    background: #4CAF50;
    border-color: #4CAF50;
    color: white;
}

.btn-channel-toggle.subscribed:hover {
    background: #f44336;
    border-color: #f44336;
}

.channels-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* === ОСНОВНОЙ КОНТЕНТ === */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

.send-panel, .preset-panel {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 15px;
}

.send-panel h3, .preset-panel h3 {
    margin-bottom: 15px;
    color: #333;
    font-size: 18px;
}

.send-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.send-controls label {
    font-weight: 600;
    color: #333;
}

.channel-select {
    padding: 8px 12px;
    border: 2px solid #e1e8ed;
    border-radius: 6px;
    font-size: 13px;
    background: white;
}

.channel-select:focus {
    outline: none;
    border-color: #667eea;
}

.message-input {
    width: 100%;
    min-height: 150px;
    padding: 15px;
    border: 2px solid #e1e8ed;
    border-radius: 10px;
    font-size: 13px;
    font-family: 'Courier New', monospace;
    resize: vertical;
    margin-bottom: 15px;
}

.message-input:focus {
    outline: none;
    border-color: #667eea;
}

.btn-send {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    width: 100%;
    justify-content: center;
    padding: 15px;
}

.btn-send:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

/* === ШАБЛОНЫ === */
.preset-category {
    margin-bottom: 20px;
}

.preset-category h4 {
    margin-bottom: 10px;
    color: #555;
    font-size: 14px;
    border-bottom: 1px solid #ddd;
    padding-bottom: 5px;
}

.preset-btn {
    display: block;
    width: 100%;
    margin-bottom: 8px;
    padding: 10px 12px;
    background: white;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    font-size: 12px;
    line-height: 1.3;
}

.preset-btn:hover {
    border-color: #667eea;
    background: #f0f4ff;
}

/* === ЖУРНАЛ СООБЩЕНИЙ === */
.messages-log {
    background: #1a1a1a;
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 30px;
}

.messages-log h3 {
    color: #fff;
    margin-bottom: 15px;
    font-size: 18px;
}

.log-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.btn-clear {
    background: linear-gradient(135deg, #6c757d, #5a6268);
    color: white;
    font-size: 12px;
    padding: 8px 16px;
}

.btn-toggle-autoreconnect {
    background: linear-gradient(135deg, #17a2b8, #138496);
    color: white;
    font-size: 12px;
    padding: 8px 16px;
}

.btn-toggle-autoreconnect.disabled {
    background: linear-gradient(135deg, #6c757d, #5a6268);
}

.filter-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-controls label {
    color: #ccc;
    font-size: 12px;
}

.channel-filter {
    padding: 6px 10px;
    border: 1px solid #444;
    border-radius: 4px;
    background: #333;
    color: #fff;
    font-size: 12px;
}

.messages-container {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 15px;
}

.message-item {
    margin-bottom: 12px;
    padding: 12px;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
}

.message-sent {
    background: rgba(76, 175, 80, 0.2);
    border-left: 4px solid #4CAF50;
}

.message-received {
    background: rgba(33, 150, 243, 0.2);
    border-left: 4px solid #2196F3;
}

.message-system {
    background: rgba(255, 152, 0, 0.2);
    border-left: 4px solid #ff9800;
}

.message-error {
    background: rgba(244, 67, 54, 0.2);
    border-left: 4px solid #f44336;
}

.message-channel {
    background: rgba(156, 39, 176, 0.2);
    border-left: 4px solid #9c27b0;
}

.message-timestamp {
    color: #888;
    font-size: 10px;
    margin-bottom: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.message-channel-tag {
    background: #667eea;
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 9px;
    font-weight: 600;
}

.message-content {
    color: #fff;
    word-wrap: break-word;
    white-space: pre-wrap;
}

/* === СТАТИСТИКА === */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 20px;
    border-radius: 15px;
    text-align: center;
}

.stat-number {
    font-size: 1.8rem;
    font-weight: bold;
    margin-bottom: 5px;
}

.stat-label {
    opacity: 0.9;
    font-size: 13px;
}

/* === ДИАГНОСТИКА === */
.diagnostics {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 20px;
}

.diagnostics h3 {
    margin-bottom: 15px;
    color: #333;
}

.diagnostics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.diagnostic-item {
    background: white;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #e1e8ed;
}

.diagnostic-label {
    font-weight: 600;
    color: #666;
    font-size: 12px;
    margin-bottom: 5px;
}

.diagnostic-value {
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: #333;
    word-break: break-all;
}

/* === АДАПТИВНОСТЬ === */
@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .connection-section {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .channels-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .panel {
        padding: 20px;
    }

    .connection-section {
        grid-template-columns: 1fr;
    }

    .log-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .stats {
        grid-template-columns: repeat(2, 1fr);
    }
}