/* ============================================================
 * AHB CRM — Sprint 6-11 Feature Styles
 * Teams, Broadcasts, Analytics, Notes, Custom Fields,
 * Agent Status, Assign/Close, Webhooks, AI Personas
 * ============================================================ */

/* ─── Agent Status Indicator ─────────────────── */
.agent-status-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.agent-status-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: var(--bg-glass);
    color: var(--text-primary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.agent-status-btn:hover {
    background: var(--bg-hover);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.status-dot.online {
    background: #22c55e;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
}

.status-dot.away {
    background: #f59e0b;
    box-shadow: 0 0 6px rgba(245, 158, 11, 0.4);
}

.status-dot.offline {
    background: #6b7280;
}

.agent-status-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-heavy);
    z-index: 200;
    min-width: 140px;
    display: none;
    overflow: hidden;
}

.agent-status-menu.active {
    display: block;
}

.agent-status-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    width: 100%;
    border: none;
    background: none;
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.agent-status-option:hover {
    background: var(--bg-hover);
}

/* ─── Conversation Actions Bar ───────────────── */
.conv-actions-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 8px;
}

.conv-action-btn {
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-glass);
    color: var(--text-primary);
    font-size: 0.78rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.conv-action-btn:hover {
    background: var(--bg-hover);
    transform: translateY(-1px);
}

.conv-action-btn.assign {
    border-color: rgba(99, 102, 241, 0.3);
}

.conv-action-btn.close-conv {
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--danger);
}

.conv-action-btn.reopen {
    border-color: rgba(16, 185, 129, 0.3);
    color: var(--secondary);
}

.assign-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-heavy);
    z-index: 200;
    min-width: 200px;
    max-height: 250px;
    overflow-y: auto;
    display: none;
}

.assign-dropdown.active {
    display: block;
}

.assign-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    color: var(--text-primary);
    font-size: 0.85rem;
    transition: background var(--transition-fast);
}

.assign-item:hover {
    background: var(--bg-hover);
}

/* ─── Notes Panel ────────────────────────────── */
.notes-panel {
    width: 280px;
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    border-left: 1px solid var(--border-color);
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    z-index: 15;
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.1);
    transition: transform 0.25s ease, opacity 0.25s ease;
}

.notes-panel.collapsed {
    transform: translateX(100%);
    opacity: 0;
    pointer-events: none;
}

.notes-header {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
}

.notes-header h4 {
    font-size: 0.9rem;
    font-weight: 600;
}

.notes-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.note-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px;
    margin-bottom: 8px;
    font-size: 0.85rem;
    line-height: 1.4;
    position: relative;
    transition: box-shadow var(--transition-fast);
}

.note-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.note-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.note-actions {
    display: flex;
    gap: 4px;
}

.note-actions button {
    padding: 2px 6px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.75rem;
    color: var(--text-muted);
    border-radius: 4px;
    transition: all var(--transition-fast);
}

.note-actions button:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.notes-compose {
    padding: 8px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-card);
}

.notes-compose textarea {
    width: 100%;
    resize: none;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 8px;
    font-size: 0.85rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: inherit;
}

.notes-compose textarea:focus {
    outline: none;
    border-color: var(--primary);
}

/* ─── Teams Page ─────────────────────────────── */
.teams-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.team-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    transition: all var(--transition-normal);
    position: relative;
}

.team-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.15);
    transform: translateY(-2px);
}

.team-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.team-name {
    font-size: 1rem;
    font-weight: 600;
}

.team-desc {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.4;
}

.team-members {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.member-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    font-size: 0.78rem;
}

.member-chip .remove-member {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.7rem;
    margin-left: 2px;
    transition: color var(--transition-fast);
}

.member-chip .remove-member:hover {
    color: var(--danger);
}

/* ─── Broadcasts Page ────────────────────────── */
.broadcast-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}

.broadcast-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    transition: all var(--transition-normal);
}

.broadcast-card:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 16px rgba(245, 158, 11, 0.12);
}

.broadcast-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.broadcast-name {
    font-size: 0.95rem;
    font-weight: 600;
}

.broadcast-stats {
    display: flex;
    gap: 16px;
    margin: 10px 0;
    font-size: 0.82rem;
}

.broadcast-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.broadcast-stat-value {
    font-weight: 700;
    font-size: 1.1rem;
}

.broadcast-stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.bc-status {
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.bc-status.draft {
    background: rgba(107, 114, 128, 0.15);
    color: #9ca3af;
}

.bc-status.scheduled {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary);
}

.bc-status.sending {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent);
}

.bc-status.paused {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.bc-status.completed {
    background: rgba(16, 185, 129, 0.15);
    color: var(--secondary);
}

/* ─── Analytics Page ─────────────────────────── */
.analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.analytics-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    text-align: center;
}

.analytics-value {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.analytics-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 4px;
}

.perf-bar-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 4px 0;
}

.perf-bar {
    flex: 1;
    height: 8px;
    background: var(--bg-glass);
    border-radius: 4px;
    overflow: hidden;
}

.perf-bar-fill {
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    transition: width 0.8s ease;
}

.perf-label {
    font-size: 0.8rem;
    min-width: 80px;
}

.perf-value {
    font-size: 0.8rem;
    min-width: 40px;
    text-align: right;
    color: var(--text-muted);
}

/* Date range filter */
.date-range-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.date-range-bar input[type="date"] {
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: inherit;
}

/* ─── Settings Add-on Sections ───────────────── */
.settings-section {
    margin-bottom: 1.5rem;
}

.persona-row,
.webhook-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

.persona-row:last-child,
.webhook-row:last-child {
    border-bottom: none;
}

.persona-info,
.webhook-info {
    flex: 1;
    min-width: 0;
}

.persona-name,
.webhook-url-text {
    font-size: 0.9rem;
    font-weight: 500;
}

.persona-model,
.webhook-events {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.default-badge {
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary);
}

/* ─── Custom Fields ──────────────────────────── */
.field-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
}

.field-row label {
    min-width: 100px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.field-row input,
.field-row select {
    flex: 1;
    padding: 5px 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: inherit;
}

/* ─── Merge Modal ────────────────────────────── */
.merge-preview {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 12px;
    align-items: start;
    margin: 12px 0;
}

.merge-contact {
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    text-align: center;
}

.merge-contact.primary {
    border-color: var(--primary);
}

.merge-contact .avatar {
    margin: 0 auto 8px;
}

.merge-arrow {
    display: flex;
    align-items: center;
    font-size: 1.5rem;
    color: var(--text-muted);
    padding-top: 24px;
}

/* ─── Responsive ─────────────────────────────── */
@media (max-width: 768px) {
    .teams-grid {
        grid-template-columns: 1fr;
    }

    .broadcast-grid {
        grid-template-columns: 1fr;
    }

    .analytics-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .notes-panel {
        width: 100%;
        position: absolute;
        right: 0;
        top: 0;
        z-index: 10;
    }

    .merge-preview {
        grid-template-columns: 1fr;
    }

    .merge-arrow {
        transform: rotate(90deg);
        justify-content: center;
    }

    .date-range-bar {
        flex-direction: column;
        align-items: stretch;
    }
}