/* ===== Auto Reply & AI Comment Styles ===== */

.autoreply-container {
    max-width: 1400px;
    margin: 0 auto;
}

.page-selector-section {
    margin-bottom: 20px;
}

.page-selector-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

.page-selector-wrap select {
    flex: 1;
    max-width: 400px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text);
    font-size: 14px;
}

.ar-page-status {
    font-size: 13px;
    font-weight: 500;
}

.ar-page-status.on  { color: #22c55e; }
.ar-page-status.off { color: #ef4444; }

/* Grid Layout */
.autoreply-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 1024px) {
    .autoreply-grid {
        grid-template-columns: 1fr;
    }
}

/* Section Cards */
.autoreply-section {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
}

.autoreply-section h3 {
    margin: 0 0 14px 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.autoreply-section h3 i {
    color: var(--primary);
    font-size: 14px;
}

.ar-desc {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 0 0 10px 0;
}

/* Toggle */
.ar-toggle-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ar-toggle-label {
    font-size: 14px;
    color: var(--text);
}

.ar-delay-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
}

.ar-delay-row label {
    font-size: 13px;
    color: var(--text-secondary);
}

.ar-delay-input {
    width: 70px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    text-align: center;
}

/* Textarea */
.autoreply-section textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
    min-height: 60px;
}

.autoreply-section textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb, 59,130,246), 0.15);
}

/* Buttons */
.ar-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.ar-btn:hover { opacity: 0.85; transform: translateY(-1px); }

.ar-btn-save {
    background: var(--primary);
    color: #fff;
    width: 100%;
    justify-content: center;
}

.ar-btn-test {
    background: #8b5cf6;
    color: #fff;
    white-space: nowrap;
}

.ar-btn-sm {
    padding: 5px 10px;
    font-size: 12px;
    border-radius: 6px;
    background: var(--bg);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.ar-btn-refresh:hover { color: var(--primary); }
.ar-btn-danger:hover { color: #ef4444; border-color: #ef4444; }

/* Test AI */
.ar-test-row {
    display: flex;
    gap: 10px;
}

.ar-test-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-size: 13px;
}

.ar-test-input:focus {
    outline: none;
    border-color: var(--primary);
}

.ar-test-result {
    margin-top: 12px;
    padding: 12px 14px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.5;
}

.ar-test-result.success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: #16a34a;
}

.ar-test-result.fallback {
    background: rgba(251, 146, 60, 0.1);
    border: 1px solid rgba(251, 146, 60, 0.3);
    color: #ea580c;
}

.ar-test-result.error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #dc2626;
}

.ar-test-result .ar-test-label {
    font-weight: 600;
    margin-bottom: 4px;
}

/* Flow Diagram */
.ar-flow {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px 0;
}

.ar-flow-step {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    width: 100%;
    max-width: 320px;
}

.ar-flow-step.small {
    max-width: 260px;
    padding: 8px 12px;
}

.ar-flow-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: #fff;
    font-size: 14px;
    flex-shrink: 0;
}

.ar-flow-icon.ai      { background: #8b5cf6; }
.ar-flow-icon.success  { background: #22c55e; }
.ar-flow-icon.warning  { background: #f59e0b; }
.ar-flow-icon.inbox    { background: #3b82f6; }

.ar-flow-text {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
}

.ar-flow-arrow {
    color: var(--text-secondary);
    font-size: 14px;
}

.ar-flow-branch {
    display: flex;
    gap: 16px;
    width: 100%;
    max-width: 560px;
}

.ar-flow-yes, .ar-flow-no {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.ar-flow-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
}

.ar-flow-badge.yes { background: rgba(34,197,94,0.15); color: #16a34a; }
.ar-flow-badge.no  { background: rgba(251,146,60,0.15); color: #ea580c; }

/* Stats Grid */
.ar-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.ar-stat-card {
    text-align: center;
    padding: 12px 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.ar-stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
}

.ar-stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.ar-stat-card.ai       .ar-stat-value { color: #8b5cf6; }
.ar-stat-card.fallback  .ar-stat-value { color: #f59e0b; }
.ar-stat-card.inbox     .ar-stat-value { color: #3b82f6; }
.ar-stat-card.success   .ar-stat-value { color: #22c55e; }
.ar-stat-card.failed    .ar-stat-value { color: #ef4444; }

/* Logs */
.ar-logs-container {
    max-height: 500px;
    overflow-y: auto;
}

.ar-empty {
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
    padding: 30px 0;
}

.ar-log-item {
    display: flex;
    gap: 10px;
    padding: 12px;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}

.ar-log-item:hover {
    background: var(--bg);
}

.ar-log-item:last-child {
    border-bottom: none;
}

.ar-log-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    color: #fff;
}

.ar-log-avatar.ai       { background: #8b5cf6; }
.ar-log-avatar.fallback  { background: #f59e0b; }
.ar-log-avatar.failed    { background: #ef4444; }

.ar-log-body {
    flex: 1;
    min-width: 0;
}

.ar-log-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.ar-log-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.ar-log-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 10px;
}

.ar-log-badge.ai       { background: rgba(139,92,246,0.15); color: #8b5cf6; }
.ar-log-badge.fallback  { background: rgba(245,158,11,0.15); color: #f59e0b; }
.ar-log-badge.failed    { background: rgba(239,68,68,0.15); color: #ef4444; }
.ar-log-badge.inbox     { background: rgba(59,130,246,0.15); color: #3b82f6; }

.ar-log-comment {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 3px;
    word-break: break-word;
}

.ar-log-comment .label { font-weight: 600; color: var(--text); }

.ar-log-reply {
    font-size: 12px;
    color: var(--text);
    padding: 6px 10px;
    background: var(--bg);
    border-radius: 6px;
    margin-top: 4px;
    word-break: break-word;
}

.ar-log-time {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.ar-logs-more {
    text-align: center;
    padding: 10px;
}

/* Loading Spinner */
.ar-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: arSpin 0.6s linear infinite;
}

@keyframes arSpin {
    to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 768px) {
    .ar-flow-branch {
        flex-direction: column;
        align-items: center;
    }
    .ar-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .ar-test-row {
        flex-direction: column;
    }
}
