/* ===== Post Scheduler & Best Time Analysis Styles ===== */

/* Layout: 2 columns */
.scheduler-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}

@media (max-width: 1100px) {
    .scheduler-layout {
        grid-template-columns: 1fr;
    }
}

.scheduler-section {
    margin-bottom: 0 !important;
}

/* Form */
.scheduler-form {
    padding: 0;
}

.scheduler-form .form-group {
    margin-bottom: 16px;
}

.scheduler-form .form-group label {
    font-weight: 600;
    font-size: 0.88rem;
    margin-bottom: 6px;
    display: block;
    color: var(--text-primary);
}

.scheduler-form .form-group label i {
    color: var(--primary);
    margin-right: 4px;
}

.char-count {
    text-align: right;
    font-size: 0.73rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* AI Button */
.btn-ai {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 10px 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
}

.btn-ai:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-ai:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-full {
    width: 100%;
    padding: 12px;
    font-size: 0.95rem;
}

/* AI Suggestions */
.ai-suggestions {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.08), rgba(118, 75, 162, 0.08));
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 16px;
}

.ai-suggestions-header {
    font-weight: 700;
    font-size: 0.85rem;
    color: #667eea;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-suggestion-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--bg-card);
    border-radius: 10px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.ai-suggestion-item:last-child {
    margin-bottom: 0;
}

.ai-suggestion-item:hover {
    border-color: var(--primary);
    background: rgba(108, 92, 231, 0.04);
}

.ai-suggestion-item .sug-time {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.ai-suggestion-item .sug-reason {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.ai-suggestion-item .sug-icon {
    font-size: 1.2rem;
    color: var(--primary);
}

/* Scheduled Posts List */
.scheduled-list-section {
    border-top: 1px solid var(--border);
    margin-top: 16px;
    padding-top: 16px;
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.section-title h3 {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.section-title h3 i {
    color: var(--primary);
}

.sched-post-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    border-radius: 10px;
    background: var(--bg-input);
    margin-bottom: 10px;
    transition: all 0.2s;
}

.sched-post-item:hover {
    background: rgba(108, 92, 231, 0.05);
}

.sched-post-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    color: #fff;
    flex-shrink: 0;
}

.sched-post-icon.pending { background: #F9A825; }
.sched-post-icon.published { background: #00B894; }
.sched-post-icon.failed { background: #E17055; }
.sched-post-icon.cancelled { background: #B2BEC3; }

.sched-post-content {
    flex: 1;
    min-width: 0;
}

.sched-post-content .post-msg {
    font-size: 0.82rem;
    color: var(--text-primary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.sched-post-content .post-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.sched-post-content .post-meta .badge-ai {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
}

.sched-post-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.sched-post-actions button {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    opacity: 0.5;
}

.sched-post-item:hover .sched-post-actions button {
    opacity: 1;
}

/* ===== Heatmap ===== */
.heatmap-section {
    margin-top: 8px;
}

.heatmap-container {
    overflow-x: auto;
    padding: 4px 0;
}

.heatmap-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 3px;
    font-size: 0.7rem;
}

.heatmap-table th {
    padding: 4px 2px;
    font-weight: 600;
    font-size: 0.65rem;
    color: var(--text-muted);
    text-align: center;
    white-space: nowrap;
}

.heatmap-table th.day-label {
    text-align: right;
    padding-right: 8px;
    min-width: 50px;
}

.heatmap-cell {
    width: 28px;
    height: 28px;
    border-radius: 5px;
    text-align: center;
    vertical-align: middle;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    font-size: 0.6rem;
    font-weight: 600;
    color: rgba(0,0,0,0.4);
}

.heatmap-cell:hover {
    transform: scale(1.3);
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* Heatmap intensity levels */
.heatmap-lv0 { background: rgba(0,0,0,0.04); color: rgba(0,0,0,0.15); }
.heatmap-lv1 { background: rgba(108, 92, 231, 0.15); color: rgba(108,92,231,0.6); }
.heatmap-lv2 { background: rgba(108, 92, 231, 0.3); color: rgba(108,92,231,0.8); }
.heatmap-lv3 { background: rgba(108, 92, 231, 0.5); color: #fff; }
.heatmap-lv4 { background: rgba(108, 92, 231, 0.7); color: #fff; }
.heatmap-lv5 { background: rgba(108, 92, 231, 0.9); color: #fff; }
.heatmap-best { background: #6C5CE7; color: #fff; box-shadow: 0 0 0 2px #F9A825, 0 0 8px rgba(249,168,37,0.5); }

/* Heatmap Legend */
.heatmap-legend {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 10px;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.heatmap-legend .legend-box {
    width: 14px;
    height: 14px;
    border-radius: 3px;
}

/* ===== Top Slots ===== */
.top-slot-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--bg-input);
    margin-bottom: 8px;
    gap: 12px;
}

.top-slot-rank {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.8rem;
    color: #fff;
    flex-shrink: 0;
}

.top-slot-rank.rank-1 { background: #F9A825; }
.top-slot-rank.rank-2 { background: #B2BEC3; }
.top-slot-rank.rank-3 { background: #E17055; }
.top-slot-rank.rank-4,
.top-slot-rank.rank-5 { background: var(--primary); opacity: 0.6; }

.top-slot-info {
    flex: 1;
}

.top-slot-info .slot-day-time {
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--text-primary);
}

.top-slot-info .slot-detail {
    font-size: 0.73rem;
    color: var(--text-muted);
}

.top-slot-eng {
    font-weight: 800;
    font-size: 1rem;
    color: var(--primary);
}

/* ===== Top Posts ===== */
.top-post-item {
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--bg-input);
    margin-bottom: 8px;
}

.top-post-item .tp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.top-post-item .tp-rank {
    font-weight: 800;
    font-size: 0.75rem;
    color: var(--primary);
}

.top-post-item .tp-date {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.top-post-item .tp-message {
    font-size: 0.8rem;
    color: var(--text-primary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 6px;
}

.top-post-item .tp-stats {
    display: flex;
    gap: 12px;
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.top-post-item .tp-stats span {
    display: flex;
    align-items: center;
    gap: 3px;
}

.top-post-item .tp-stats i {
    font-size: 0.68rem;
}

/* ===== AI Analysis Result ===== */
.ai-analysis-section {
    margin-top: 16px;
    border-top: 1px solid var(--border);
    padding-top: 16px;
}

.ai-analysis-result {
    margin-top: 14px;
    padding: 16px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.06), rgba(118, 75, 162, 0.06));
    border: 1px solid rgba(102, 126, 234, 0.15);
    border-radius: 12px;
    font-size: 0.85rem;
    line-height: 1.7;
    color: var(--text-primary);
    white-space: pre-wrap;
}

.ai-analysis-result h3,
.ai-analysis-result h4 {
    color: #667eea;
    margin-top: 12px;
    margin-bottom: 4px;
}

/* ===== Stats Summary ===== */
.stats-summary {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.stat-mini {
    flex: 1;
    min-width: 120px;
    padding: 12px;
    border-radius: 12px;
    background: var(--bg-input);
    text-align: center;
}

.stat-mini .stat-val {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--primary);
}

.stat-mini .stat-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Heatmap tooltip */
.heatmap-cell[title] {
    cursor: help;
}

/* Responsive */
@media (max-width: 768px) {
    .heatmap-cell {
        width: 22px;
        height: 22px;
        font-size: 0.5rem;
    }
    .stats-summary {
        gap: 8px;
    }
    .stat-mini {
        min-width: 80px;
        padding: 8px;
    }
    .stat-mini .stat-val {
        font-size: 1rem;
    }
}

/* ===== Multi-page Selector Grid ===== */
.scheduler-pages-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 16px;
}

.scheduler-page-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border: 2px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    background: var(--bg-input);
    user-select: none;
}

.scheduler-page-card:hover {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.05);
}

.scheduler-page-card.selected {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
    box-shadow: 0 0 0 1px var(--primary);
}

.scheduler-page-card input[type="checkbox"] {
    display: none;
}

.page-card-check {
    display: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 10px;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.scheduler-page-card.selected .page-card-check {
    display: flex;
}

.page-card-pic {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.page-card-pic-placeholder {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 14px;
    flex-shrink: 0;
}

.page-card-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}

.sched-page-count {
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
    margin-left: auto;
}

/* ===== Per-page Messages ===== */
.sched-page-messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sched-page-msg-block {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    background: var(--bg-input);
}

.sched-page-msg-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 13px;
    color: var(--text);
}

.page-card-pic-sm {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
}

.page-card-pic-sm-placeholder {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 11px;
}

.sched-page-msg-empty {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

.sched-page-msg-empty i {
    margin-right: 6px;
}

/* ===== Scheduled Post Page Name ===== */
.sched-post-page-name {
    font-size: 11px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 2px;
}

.sched-post-page-name i {
    margin-right: 4px;
    font-size: 10px;
}

/* ===== Post Status Badge ===== */
.sched-status-badge.status-published {
    color: #00B894;
    font-weight: 600;
}

.sched-status-badge.status-failed {
    color: #E17055;
    font-weight: 600;
}

.sched-status-badge.status-cancelled {
    color: #B2BEC3;
}

/* ===== Post Link Button ===== */
.sched-post-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    margin-left: 4px;
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary);
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
}

.sched-post-link:hover {
    background: var(--primary);
    color: #fff;
}

/* ===== Responsive: Page Cards ===== */
@media (max-width: 768px) {
    .scheduler-pages-grid {
        gap: 8px;
    }
    .scheduler-page-card {
        padding: 6px 10px;
    }
    .page-card-pic {
        width: 24px;
        height: 24px;
    }
    .page-card-name {
        max-width: 100px;
        font-size: 12px;
    }
}

/* ===== AI Caption Button & Modal ===== */
.btn-ai-caption {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all .2s;
    white-space: nowrap;
}
.btn-ai-caption:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102,126,234,.4);
}
.btn-ai-caption i { font-size: 11px; }

/* Modal Overlay */
.sched-ai-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.sched-ai-modal {
    background: var(--bg-card, #1e1e2e);
    border-radius: 16px;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,.5);
    border: 1px solid var(--border, #333);
}
.sched-ai-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border, #333);
}
.sched-ai-modal-header h3 {
    margin: 0;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.sched-ai-modal-header h3 i {
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.sched-ai-modal-close {
    background: none;
    border: none;
    color: var(--text-secondary, #888);
    font-size: 22px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.sched-ai-modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.sched-ai-modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 14px 20px;
    border-top: 1px solid var(--border, #333);
}

/* Auto Toggle */
.sched-ai-auto-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-input, #2a2a3a);
    border-radius: 10px;
    font-size: 13px;
}
.sched-ai-auto-toggle .switch {
    position: relative;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
}
.sched-ai-auto-toggle .switch input { display: none; }
.sched-ai-auto-toggle .slider {
    position: absolute;
    inset: 0;
    background: #444;
    border-radius: 22px;
    cursor: pointer;
    transition: .3s;
}
.sched-ai-auto-toggle .slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: .3s;
}
.sched-ai-auto-toggle .switch input:checked + .slider {
    background: linear-gradient(135deg, #667eea, #764ba2);
}
.sched-ai-auto-toggle .switch input:checked + .slider::before {
    transform: translateX(18px);
}

/* AI Result */
.sched-ai-result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--primary, #667eea);
    font-weight: 600;
}
.sched-ai-caption-text {
    background: var(--bg-input, #2a2a3a);
    border-radius: 10px;
    padding: 14px;
    white-space: pre-wrap;
    font-size: 13px;
    line-height: 1.6;
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid var(--border, #333);
}

/* Full-width button */
.btn-full { width: 100%; justify-content: center; }

/* Message label row */
.sched-msg-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.btn-ai-all {
    font-size: 12px;
    padding: 5px 12px;
}

/* Photo Upload */
.sched-photo-dropzone {
    border: 2px dashed var(--border, #444);
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all .2s;
    color: var(--text-muted, #888);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
.sched-photo-dropzone:hover,
.sched-photo-dropzone.dragover {
    border-color: var(--primary, #667eea);
    background: rgba(102,126,234,.08);
    color: var(--primary, #667eea);
}
.sched-photo-dropzone i {
    font-size: 24px;
}
.sched-photo-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-input, #2a2a3a);
    border-radius: 12px;
    padding: 10px;
    position: relative;
    border: 1px solid var(--border, #333);
}
.sched-photo-preview img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
}
.sched-photo-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}
.sched-photo-info span:first-child {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sched-photo-info span:last-child {
    font-size: 12px;
    color: var(--text-muted, #888);
}
.sched-photo-remove {
    position: absolute;
    top: 6px;
    right: 8px;
    background: rgba(244,67,54,.2);
    color: #f44336;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: all .2s;
}
.sched-photo-remove:hover {
    background: #f44336;
    color: #fff;
}

/* Batch result items */
.sched-ai-batch-item {
    background: var(--bg-input, #2a2a3a);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 10px;
    border: 1px solid var(--border, #333);
}
.sched-ai-batch-page {
    font-size: 13px;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.sched-ai-batch-item .batch-caption {
    margin-top: 6px;
    max-height: 150px;
}

