/* Telegram Mailer Bot v2 — Styles */
/* Тёмная тема в стиле Telegram, двухзонный layout */

:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-card: #1e2a4a;
    --bg-input: #0f1a30;
    --text-primary: #e8e8e8;
    --text-secondary: #8892b0;
    --text-muted: #5a6482;
    --accent-blue: #5b8def;
    --accent-green: #4ade80;
    --accent-yellow: #fbbf24;
    --accent-red: #f87171;
    --accent-orange: #fb923c;
    --accent-fast: #4ade80;
    --accent-slow: #60a5fa;
    --border-color: #2a3a5c;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.2s ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
        Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

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

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 24px;
}

.header-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.header-badge {
    display: flex;
    align-items: center;
    gap: 12px;
}

.version {
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg-card);
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-badge.idle {
    background: rgba(90, 100, 130, 0.3);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.status-badge.running {
    background: rgba(74, 222, 128, 0.15);
    color: var(--accent-green);
    border: 1px solid rgba(74, 222, 128, 0.3);
}

.status-badge.paused {
    background: rgba(251, 191, 36, 0.15);
    color: var(--accent-yellow);
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.status-badge.error {
    background: rgba(248, 113, 113, 0.15);
    color: var(--accent-red);
    border: 1px solid rgba(248, 113, 113, 0.3);
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

/* Status Card */
.status-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.status-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.status-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
}

.status-value {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

/* ======================== ZONES ======================== */
.zone {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.zone-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.zone-fast-header {
    background: rgba(74, 222, 128, 0.05);
    border-bottom-color: rgba(74, 222, 128, 0.2);
}

.zone-slow-header {
    background: rgba(96, 165, 250, 0.05);
    border-bottom-color: rgba(96, 165, 250, 0.2);
}

.zone-title {
    font-size: 16px;
    font-weight: 600;
}

.zone-fast .zone-title {
    color: var(--accent-fast);
}

.zone-slow .zone-title {
    color: var(--accent-slow);
}

.zone-body {
    padding: 20px;
}

.zone-status-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}

.zone-progress {
    margin-bottom: 16px;
}

.zone-channels {
    margin-bottom: 16px;
}

.zone-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.zone-log {
    margin-top: 8px;
}

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

.log-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Progress Bar */
.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.progress-title {
    font-size: 13px;
    color: var(--text-secondary);
}

.progress-percent {
    font-size: 14px;
    font-weight: 700;
    color: var(--accent-blue);
    font-variant-numeric: tabular-nums;
}

.progress-bar-container {
    width: 100%;
    height: 12px;
    background: var(--bg-input);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-bar {
    height: 100%;
    border-radius: 6px;
    transition: width var(--transition);
    width: 0%;
}

.progress-bar-fast {
    background: linear-gradient(90deg, #22c55e, #4ade80);
}

.progress-bar-slow {
    background: linear-gradient(90deg, #3b82f6, #60a5fa);
}

.progress-details {
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
}

/* Controls */
.controls {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}

.btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none !important;
}

.btn:not(:disabled):hover {
    transform: translateY(-1px);
}

.btn:not(:disabled):active {
    transform: translateY(0);
}

.btn-start {
    background: var(--accent-green);
    color: #000;
}

.btn-start:not(:disabled):hover {
    box-shadow: 0 0 20px rgba(74, 222, 128, 0.3);
}

.btn-pause {
    background: var(--accent-yellow);
    color: #000;
}

.btn-resume {
    background: var(--accent-blue);
    color: #fff;
}

.btn-stop {
    background: var(--accent-red);
    color: #fff;
}

.btn-stop:not(:disabled):hover {
    box-shadow: 0 0 20px rgba(248, 113, 113, 0.3);
}

.btn-save {
    background: var(--accent-blue);
    color: #fff;
}

.btn-refresh {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

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

.btn-add {
    background: var(--accent-green);
    color: #000;
    white-space: nowrap;
}

/* Configuration */
.config-subtitle {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 10px;
    margin-top: 12px;
}

.config-subtitle:first-child {
    margin-top: 0;
}

.config-section {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.config-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

/* Chats */
.chats-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
    min-height: 32px;
}

.chat-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 13px;
    color: var(--text-primary);
    transition: all var(--transition);
}

.zone-fast .chat-tag {
    border-color: rgba(74, 222, 128, 0.3);
}

.zone-slow .chat-tag {
    border-color: rgba(96, 165, 250, 0.3);
}

.chat-tag:hover {
    border-color: var(--accent-red);
}

.chat-tag-remove {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 16px;
    line-height: 1;
    transition: color var(--transition);
}

.chat-tag-remove:hover {
    color: var(--accent-red);
}

.chats-add {
    display: flex;
    gap: 8px;
}

.input {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: border-color var(--transition);
}

.input:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    min-height: 60px;
    transition: border-color var(--transition);
}

.textarea:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.messages-editor {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message-label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
    font-weight: 600;
}

.config-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.config-status {
    margin-top: 8px;
    font-size: 13px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    display: none;
}

.config-status.success {
    display: block;
    background: rgba(74, 222, 128, 0.1);
    color: var(--accent-green);
    border: 1px solid rgba(74, 222, 128, 0.2);
}

.config-status.error {
    display: block;
    background: rgba(248, 113, 113, 0.1);
    color: var(--accent-red);
    border: 1px solid rgba(248, 113, 113, 0.2);
}

/* Dialogs */
.dialogs-list {
    max-height: 300px;
    overflow-y: auto;
    margin-top: 12px;
}

.dialog-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
    cursor: pointer;
}

.dialog-item:hover {
    background: var(--bg-input);
}

.dialog-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.dialog-type {
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-input);
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: capitalize;
}

.dialog-add-btn {
    font-size: 11px;
    color: var(--accent-blue);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background var(--transition);
}

.dialog-add-btn:hover {
    background: rgba(91, 141, 239, 0.15);
}

.hint {
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    padding: 20px;
}

/* Logs */
.log-stats {
    font-size: 12px;
    color: var(--text-muted);
}

.log-container {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    font-family: "SF Mono", "Fira Code", "Fira Mono", monospace;
    font-size: 12px;
    line-height: 1.5;
}

.log-empty {
    color: var(--text-muted);
    text-align: center;
    padding: 24px;
    font-family: inherit;
}

.log-entry {
    display: flex;
    gap: 8px;
    padding: 6px 12px;
    border-bottom: 1px solid rgba(42, 58, 92, 0.5);
    align-items: flex-start;
}

.log-entry:last-child {
    border-bottom: none;
}

.log-time {
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
    font-size: 11px;
    padding-top: 1px;
}

.log-chat {
    color: var(--accent-blue);
    font-weight: 600;
    flex-shrink: 0;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.log-preview {
    color: var(--text-secondary);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.log-status {
    flex-shrink: 0;
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
}

.log-status.ok {
    color: var(--accent-green);
}

.log-status.error {
    color: var(--accent-red);
}

.log-error-msg {
    color: var(--accent-red);
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 12px;
    }

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

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

    .controls {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    .header {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }

    .config-actions {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .status-grid {
        grid-template-columns: 1fr;
    }

    .zone-status-grid {
        grid-template-columns: 1fr 1fr;
    }

    .log-entry {
        flex-wrap: wrap;
    }
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-input);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}
