/* ========================================
   WebToAgencia - App CSS v3.1
   ======================================== */

/* --- Variáveis --------------------------------- */
:root {
    --cc-accent:    #6c63ff;
    --cc-accent-2:  #00d4aa;
    --cc-bg:        #f4f5f7;
    --cc-surface:   #ffffff;
    --cc-border:    rgba(0,0,0,0.07);
    --cc-col-bg:    #f8f9fb;
    --cc-shadow-sm: 0 1px 4px rgba(0,0,0,0.06);
    --cc-shadow:    0 2px 12px rgba(0,0,0,0.09);
    --cc-radius:    12px;
    --cc-radius-sm: 8px;
    --sidebar-w:    250px;
}

/* --- Base -------------------------------------- */
body { background: var(--cc-bg); }

/* --- Sidebar ----------------------------------- */
#sidebar-wrapper {
    transition: margin-left 0.25s ease;
    z-index: 100;
    min-width: var(--sidebar-w);
    max-width: var(--sidebar-w);
}
#sidebar-wrapper .list-group-item:hover  { background-color: #2d2d44 !important; }
#sidebar-wrapper .list-group-item.active { background-color: var(--cc-accent) !important; border-color: var(--cc-accent) !important; }
body.sidebar-collapsed #sidebar-wrapper  { margin-left: calc(-1 * var(--sidebar-w)); }

/* --- Cards globais ----------------------------- */
.card {
    border: none;
    border-radius: var(--cc-radius);
    box-shadow: var(--cc-shadow-sm);
    transition: box-shadow 0.2s ease;
}
.card:hover { box-shadow: var(--cc-shadow); }

/* ════════════════════════════════════════════════
   COMMAND CENTER LAYOUT
   ════════════════════════════════════════════════ */

.cc-topbar {
    background: var(--cc-surface);
    border-radius: var(--cc-radius);
    padding: 12px 16px;
    box-shadow: var(--cc-shadow-sm);
}
.cc-title { color: #1a1a2e; letter-spacing: -0.3px; }
.cc-project-select { border-color: var(--cc-border); border-radius: var(--cc-radius-sm); background: #f8f9fb; font-size: 0.85rem; }

/* Stats compactos */
.cc-stat-card {
    display: flex; flex-direction: column; align-items: center;
    background: var(--cc-col-bg); border: 1px solid var(--cc-border);
    border-radius: var(--cc-radius-sm); padding: 6px 14px; min-width: 72px;
    transition: box-shadow 0.15s; cursor: default;
}
.cc-stat-card:hover { box-shadow: var(--cc-shadow-sm); }
.cc-stat-card .bi  { font-size: 1rem; }
.cc-stat-val { font-size: 1.1rem; font-weight: 700; color: #1a1a2e; line-height: 1.1; }
.cc-stat-lbl { font-size: 0.65rem; color: #888; text-transform: uppercase; letter-spacing: 0.4px; }

/* Grid 3 colunas */
.cc-grid {
    display: grid;
    grid-template-columns: 230px 1fr 260px;
    gap: 14px;
    align-items: start;
}

/* Colunas base */
.cc-col-agents, .cc-col-kanban, .cc-col-side {
    background: var(--cc-surface);
    border-radius: var(--cc-radius);
    box-shadow: var(--cc-shadow-sm);
    overflow: hidden;
    display: flex; flex-direction: column;
}
.cc-col-header {
    display: flex; align-items: center; gap: 4px;
    padding: 10px 14px;
    font-size: 0.82rem; font-weight: 600; color: #444;
    border-bottom: 1px solid var(--cc-border);
    background: #fbfcfd; letter-spacing: 0.2px;
}
.cc-col-body {
    padding: 10px; overflow-y: auto; flex: 1;
    max-height: calc(100vh - 230px);
}

/* ── Agentes ──────────────────────────────────── */
.cc-agent-card {
    background: var(--cc-col-bg); border: 1px solid var(--cc-border);
    border-radius: var(--cc-radius-sm); padding: 10px 12px; margin-bottom: 8px;
    transition: box-shadow 0.15s, transform 0.1s;
}
.cc-agent-card:hover { box-shadow: var(--cc-shadow); transform: translateY(-1px); }
.cc-agent-avatar {
    width: 40px; height: 40px;
    background: linear-gradient(135deg, #6c63ff22, #00d4aa22);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem; flex-shrink: 0;
}
.cc-agent-name  { font-size: 0.83rem; font-weight: 600; color: #1a1a2e; }
.cc-status-dot  { font-size: 0.55rem; }
.cc-agent-doing { font-size: 0.7rem; color: #666; background: #fff8e1; border-radius: 4px; padding: 2px 6px; }
.cc-badge-mini  { font-size: 0.65rem; padding: 1px 6px; border-radius: 20px; font-weight: 500; }
.cc-agent-actions { display: flex; gap: 4px; }
.cc-action-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px;
    background: #fff; border: 1px solid var(--cc-border); border-radius: 6px;
    color: #555; font-size: 0.8rem; text-decoration: none;
    transition: background 0.15s, color 0.15s;
}
.cc-action-btn:hover { background: var(--cc-accent); color: #fff; border-color: var(--cc-accent); }

/* ── Kanban ────────────────────────────────────── */
.cc-col-kanban .cc-col-body { padding: 0; }
.cc-kanban-scroll { overflow-x: auto; height: calc(100vh - 230px); }
.cc-kanban-board  { display: flex; gap: 10px; padding: 12px; min-width: max-content; height: 100%; align-items: flex-start; }
.cc-kanban-col    { width: 210px; flex-shrink: 0; display: flex; flex-direction: column; max-height: calc(100vh - 260px); }
.cc-kanban-col-header {
    display: flex; align-items: center; gap: 4px;
    padding: 6px 8px;
    border-radius: var(--cc-radius-sm) var(--cc-radius-sm) 0 0;
    background: var(--cc-col-bg); border: 1px solid var(--cc-border); border-bottom: none;
    font-size: 0.75rem; font-weight: 600; color: #444;
}
.cc-kanban-cards {
    background: var(--cc-col-bg); border: 1px solid var(--cc-border);
    border-radius: 0 0 var(--cc-radius-sm) var(--cc-radius-sm);
    padding: 8px; overflow-y: auto; flex: 1; min-height: 80px;
}
.cc-kanban-empty { text-align: center; color: #bbb; font-size: 0.72rem; padding: 16px 0; }
.cc-kanban-card {
    background: #fff; border-radius: var(--cc-radius-sm); padding: 10px; margin-bottom: 7px;
    border-left: 3px solid var(--cc-accent); cursor: pointer;
    box-shadow: var(--cc-shadow-sm); transition: transform 0.12s, box-shadow 0.12s;
}
.cc-kanban-card:hover { transform: translateY(-2px); box-shadow: var(--cc-shadow); }
.cc-kanban-card.priority-urgent { border-left-color: #dc3545; }
.cc-kanban-card.priority-high   { border-left-color: #fd7e14; }
.cc-kanban-card.priority-medium { border-left-color: var(--cc-accent); }
.cc-kanban-card.priority-low    { border-left-color: #adb5bd; }
.cc-task-type    { font-size: 0.65rem; font-weight: 600; color: var(--cc-accent); background: #6c63ff12; padding: 1px 6px; border-radius: 20px; text-transform: uppercase; letter-spacing: 0.3px; }
.cc-task-ref     { font-size: 0.65rem; color: #aaa; }
.cc-task-title   { font-size: 0.8rem; font-weight: 600; color: #1a1a2e; line-height: 1.3; margin: 2px 0; }
.cc-task-preview { font-size: 0.7rem; color: #777; line-height: 1.4; margin-top: 3px; }
.cc-agent-chip   { font-size: 0.65rem; color: #555; background: #eee; padding: 1px 7px; border-radius: 20px; }
.cc-due          { font-size: 0.65rem; color: #888; }

/* ── Coluna Direita ────────────────────────────── */
.cc-tabs     { border-bottom: 1px solid var(--cc-border); }
.cc-tab-btn  {
    font-size: 0.75rem; padding: 7px 4px; border: none;
    border-bottom: 2px solid transparent; background: none; color: #666;
    cursor: pointer; transition: color 0.15s, border-color 0.15s;
}
.cc-tab-btn.active { color: var(--cc-accent); border-bottom-color: var(--cc-accent); font-weight: 600; }
.cc-tab-btn:hover  { color: var(--cc-accent); }

/* Timeline */
.cc-timeline { display: flex; flex-direction: column; }
.cc-timeline-item { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--cc-border); }
.cc-timeline-item:last-child { border-bottom: none; }
.cc-tl-icon  { width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 0.85rem; margin-top: 1px; }
.cc-tl-body  { flex: 1; min-width: 0; }
.cc-tl-title { font-size: 0.78rem; font-weight: 500; color: #1a1a2e; line-height: 1.3; }
.cc-tl-meta  { display: flex; align-items: center; gap: 5px; margin-top: 2px; font-size: 0.68rem; }
.cc-tl-time  { font-size: 0.65rem; color: #aaa; margin-top: 2px; }

/* Crons */
.cc-cron-card { background: var(--cc-col-bg); border: 1px solid var(--cc-border); border-radius: var(--cc-radius-sm); padding: 10px 12px; }

/* Empty state */
.cc-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 32px 16px; color: #bbb; font-size: 0.8rem; }
.cc-empty .bi { font-size: 2rem; }

/* Animations */
@keyframes cc-spin { to { transform: rotate(360deg); } }
.cc-spin { animation: cc-spin 1.5s linear infinite; display: inline-block; }

/* ── Agent status badges ──────────────────────── */
.agent-status-online  { color: #28a745; }
.agent-status-working { color: #ffc107; }
.agent-status-error   { color: #dc3545; }
.agent-status-offline { color: #6c757d; }

/* ── Agent avatar pixel art ───────────────────── */
.agent-avatar { width: 48px; height: 48px; border-radius: 12px; image-rendering: pixelated; }

/* ── Kanban standalone (views/tasks) ──────────── */
.kanban-column { min-height: 400px; background: #f8f9fa; border-radius: 10px; padding: 12px; }
.kanban-card   { background: white; border-radius: 8px; padding: 12px; margin-bottom: 8px; border-left: 4px solid var(--cc-accent); cursor: pointer; transition: transform 0.1s ease; }
.kanban-card:hover { transform: translateY(-2px); }
.kanban-card.priority-urgent { border-left-color: #dc3545; }
.kanban-card.priority-high   { border-left-color: #fd7e14; }
.kanban-card.priority-medium { border-left-color: var(--cc-accent); }
.kanban-card.priority-low    { border-left-color: #6c757d; }

/* ── Timeline standalone ──────────────────────── */
.timeline-item { position: relative; padding-left: 24px; padding-bottom: 16px; border-left: 2px solid #dee2e6; }
.timeline-item::before { content: ''; position: absolute; left: -5px; top: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--cc-accent); }

/* ════════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════════ */

@media (max-width: 1400px) {
    .cc-grid { grid-template-columns: 210px 1fr 240px; }
}

@media (max-width: 1200px) {
    .cc-grid { grid-template-columns: 200px 1fr; }
    .cc-col-side { display: none; }
}

@media (max-width: 992px) {
    .cc-grid { grid-template-columns: 1fr; }
    .cc-col-agents { display: none; }
    .cc-kanban-scroll { height: auto; }
    .cc-kanban-board { min-width: unset; flex-wrap: wrap; }
    .cc-kanban-col { width: 100%; }
    .cc-col-body { max-height: none; }
}

@media (max-width: 768px) {
    /* Sidebar: colapsa por padrão no mobile */
    body:not(.sidebar-open) #sidebar-wrapper { margin-left: calc(-1 * var(--sidebar-w)); }
    #page-content-wrapper { min-width: 0; }

    /* Topbar stats: 2 por linha */
    .cc-stat-card { min-width: 60px; padding: 5px 10px; }
    .cc-stat-val  { font-size: 0.95rem; }

    /* Cards compactos */
    .card { border-radius: 8px; }
    .container-fluid { padding: 0 12px; }
}

@media (max-width: 576px) {
    .cc-topbar { flex-direction: column; gap: 10px; }
    .cc-topbar > div:last-child { width: 100%; justify-content: space-between; }
}


/* ── Pipeline Timeline (Fase 18) ─────────────── */
.ring-pulse {
    animation: pulse-ring 1.5s ease-in-out infinite;
}
@keyframes pulse-ring {
    0%   { box-shadow: 0 0 0 0 rgba(13, 110, 253, 0.4); }
    70%  { box-shadow: 0 0 0 8px rgba(13, 110, 253, 0); }
    100% { box-shadow: 0 0 0 0 rgba(13, 110, 253, 0); }
}


/* ── Calendário Editorial (Fase 19) ──────────── */
.cal-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}
.cal-header-cell {
    text-align: center;
    padding: 8px 4px;
    font-weight: 600;
    font-size: 0.8rem;
    color: #6c757d;
}
.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}
.cal-cell {
    min-height: 110px;
    border-right: 1px solid #eee;
    border-bottom: 1px solid #eee;
    padding: 4px;
    position: relative;
    transition: background 0.15s;
}
.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell-empty {
    background: #fafafa;
    min-height: 110px;
}
.cal-cell-valid:hover {
    background: #f0f4ff;
}
.cal-cell-valid.cal-drag-over {
    background: #e0e7ff;
}
.cal-cell-today {
    background: #fffde7;
}
.cal-day-num {
    font-size: 0.8rem;
    font-weight: 500;
    color: #999;
    padding: 2px 4px;
}
.cal-today-num {
    color: #fff;
    background: #0d6efd;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}
.cal-tasks {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-top: 2px;
}
.cal-task-item {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 2px 5px;
    border-radius: 4px;
    background: #fff;
    font-size: 0.72rem;
    text-decoration: none;
    color: #333;
    cursor: grab;
    transition: box-shadow 0.15s, transform 0.1s;
    white-space: nowrap;
    overflow: hidden;
}
.cal-task-item:hover {
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
    transform: translateY(-1px);
    color: #333;
}
.cal-task-item:active { cursor: grabbing; }
.cal-task-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}
.cal-task-title {
    overflow: hidden;
    text-overflow: ellipsis;
}
.cal-dragging {
    opacity: 0.4;
}

/* Responsivo */
@media (max-width: 768px) {
    .cal-cell { min-height: 70px; }
    .cal-task-item { font-size: 0.65rem; padding: 1px 3px; }
    .cal-header-cell { font-size: 0.7rem; padding: 5px 2px; }
}

/* ════════════════════════════════════════════════
   METRICS DASHBOARD (Fase 20)
   ════════════════════════════════════════════════ */

.metrics-topbar {
    background: var(--cc-surface);
    border-radius: var(--cc-radius);
    padding: 12px 16px;
    box-shadow: var(--cc-shadow-sm);
}

.metrics-card {
    border: none;
    transition: transform 0.15s, box-shadow 0.15s;
}
.metrics-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--cc-shadow);
}
.metrics-card-icon {
    width: 40px; height: 40px;
    border-radius: 10px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
    margin: 0 auto 8px auto;
}
.metrics-card-val {
    font-size: 1.3rem;
    font-weight: 700;
    color: #1a1a2e;
    line-height: 1.2;
}
.metrics-card-lbl {
    font-size: 0.72rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

/* Spin animation para botão sincronizar */
@keyframes spin { 100% { transform: rotate(360deg); } }
.spin-animation { animation: spin 1s linear infinite; }

/* Métricas: Flash animation para valores atualizados via AJAX */
@keyframes metricsFlash {
    0%   { color: var(--cc-accent); transform: scale(1.1); }
    100% { color: #1a1a2e; transform: scale(1); }
}
.metrics-flash { animation: metricsFlash 0.6s ease-out; }

/* Responsividade mobile para métricas */
@media (max-width: 767px) {
    .metrics-topbar .d-flex {
        flex-direction: column;
        align-items: stretch !important;
    }
    .metrics-topbar .input-group { width: 100% !important; }
    .metrics-topbar select { width: 100% !important; }
    .metrics-card-val { font-size: 1.1rem; }
    .metrics-card-icon { width: 32px; height: 32px; font-size: 1rem; }

    #engagement-subcards .col-4 { flex: 0 0 33.33%; }

    .table-responsive { font-size: 0.8rem; }
    .table-responsive th,
    .table-responsive td { padding: 4px 6px; white-space: nowrap; }
}

@media (max-width: 575px) {
    .metrics-card-val { font-size: 0.95rem; }
    .metrics-card-lbl { font-size: 0.6rem; }
    .btn-group-sm .btn { font-size: 0.7rem; padding: 2px 8px; }
}

/* ════════════════════════════════════════════════
   USERS — Gerenciamento de equipe (Fase 21)
   ════════════════════════════════════════════════ */

.user-avatar {
    width: 36px; height: 36px;
    border-radius: 10px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1rem; flex-shrink: 0;
}

.role-option {
    transition: border-color 0.15s, box-shadow 0.15s;
    border: 1px solid var(--cc-border);
}
.role-option:hover { border-color: var(--cc-accent); }
.role-option:has(input:checked) {
    border-color: var(--cc-accent);
    box-shadow: 0 0 0 2px rgba(108,99,255,0.15);
}
