/* ─────────────────────────────────────────────────────────────
   Agency Mode — CSS
   Social Authority Design System
   ───────────────────────────────────────────────────────────── */

/* ── CSS Variable for dynamic branding ── */
:root {
    --agency-primary: #8b5cf6;
}

/* ──────────────────────────────────────────────────────────────
   ROLE-BASED GATING — Client Portal
   Applied via body.sa-role--client (set by auth.js applyRoleGating)
   Hides internal tools; shows only BI/reporting sections.
   ────────────────────────────────────────────────────────────── */

/* Hide the right-side upload + AI chat panels in Engagement & Audit */
body.sa-role--client .sa-right-panel,
body.sa-role--client #sa-engagement-side,
body.sa-role--client #sa-audit-side {
    display: none !important;
}

/* Make the BI area full-width when right panel is hidden */
body.sa-role--client .sa-engagement-layout {
    grid-template-columns: 1fr !important;
}

/* Hide upload / data management elements */
body.sa-role--client .sa-upload,
body.sa-role--client .sa-dropzone,
body.sa-role--client .sa-upload-actions,
body.sa-role--client .sa-sync-btn,
body.sa-role--client #btn-reset-data,
body.sa-role--client #btn-reset-data-audit {
    display: none !important;
}

/* Hide Calendar "Start Sync AI" button for clients */
body.sa-role--client .sa-calendar-sync-btn,
body.sa-role--client [id*="sync-ai"],
body.sa-role--client [class*="sync-ai"] {
    display: none !important;
}

/* Campaign Builder: hide creation sidebar + canvas, show only Saved Campaigns */
body.sa-role--client .sa-campaign-sidebar,
body.sa-role--client .sa-campaign-canvas,
body.sa-role--client #sa-campaign-actions {
    display: none !important;
}

body.sa-role--client .sa-campaign-container {
    display: block !important;
}

/* Rename "Saved Campaigns" section label for clients */
body.sa-role--client .sa-saved-campaigns-header h3::before {
    content: "Active ";
}

/* Engagement Analytics: make layout single-column */
body.sa-role--client #sa-engagement-main {
    width: 100% !important;
    max-width: 100% !important;
}


/* ── View Shell ── */
.sa-agency-view {
    padding: 0;
    min-height: 100%;
}

.sa-agency-loading-state {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}

.sa-agency-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #1f2235;
    border-top-color: var(--agency-primary);
    border-radius: 50%;
    animation: sa-spin 0.8s linear infinite;
}

@keyframes sa-spin { to { transform: rotate(360deg); } }

/* ── Empty / Upgrade State ── */
.sa-agency-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 60px 24px;
    max-width: 480px;
    margin: 0 auto;
}

.sa-agency-icon {
    font-size: 56px;
    margin-bottom: 20px;
    filter: drop-shadow(0 0 20px rgba(139, 92, 246, 0.4));
}

.sa-agency-empty-state h2 {
    font-size: 1.8rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 12px;
}

.sa-agency-empty-state p {
    color: #94a3b8;
    line-height: 1.6;
    margin-bottom: 12px;
}

.sa-agency-plan-note {
    font-size: 0.85rem;
    color: #64748b;
    margin-bottom: 24px !important;
}

.sa-agency-plan-note strong {
    color: var(--agency-primary);
}

/* ── Activation Screen ── */
.sa-agency-activation {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 32px 16px;
    min-height: 100%;
}

.sa-agency-activation-card {
    background: #121421;
    border: 1px solid #1f2235;
    border-radius: 16px;
    padding: 40px;
    max-width: 560px;
    width: 100%;
    box-shadow: 0 0 60px rgba(139, 92, 246, 0.08);
}

.sa-agency-glow-icon {
    font-size: 48px;
    text-align: center;
    margin-bottom: 16px;
    filter: drop-shadow(0 0 16px rgba(139, 92, 246, 0.5));
}

.sa-agency-activation-card h2 {
    font-size: 1.6rem;
    font-weight: 700;
    color: #fff;
    text-align: center;
    margin-bottom: 8px;
}

.sa-agency-activation-card > p {
    color: #94a3b8;
    text-align: center;
    line-height: 1.6;
    margin-bottom: 24px;
}

.sa-agency-features {
    background: rgba(255,255,255,0.03);
    border: 1px solid #1f2235;
    border-radius: 10px;
    padding: 16px 20px;
    margin-bottom: 28px;
}

.sa-agency-feature {
    display: flex;
    gap: 10px;
    color: #94a3b8;
    font-size: 0.88rem;
    padding: 5px 0;
}

.sa-agency-feature span {
    color: #10b981;
    font-weight: 700;
    flex-shrink: 0;
}

/* ── Form Elements ── */
.sa-agency-setup-form .sa-input-group {
    margin-bottom: 18px;
}

.sa-agency-setup-form .sa-input-group label,
#sa-add-client-modal .sa-input-group label,
#sa-settings-modal .sa-input-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: #e2e8f0;
}

.sa-label-hint {
    color: #64748b;
    font-size: 0.8rem;
    font-weight: 400;
}

.sa-slug-wrapper {
    display: flex;
    align-items: center;
    gap: 0;
}

.sa-slug-wrapper input {
    border-radius: 8px 0 0 8px !important;
    flex: 1;
}

.sa-slug-suffix {
    background: #1f2235;
    border: 1px solid #2a2d45;
    border-left: none;
    border-radius: 0 8px 8px 0;
    padding: 10px 12px;
    color: #64748b;
    font-size: 0.88rem;
    white-space: nowrap;
    line-height: 1.5;
}

.sa-input-hint {
    font-size: 0.78rem;
    color: #64748b;
    margin-top: 5px;
}

/* ── Color Picker ── */
.sa-color-picker-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sa-color-input {
    width: 44px;
    height: 38px;
    border: 1px solid #2a2d45;
    border-radius: 8px;
    background: #0a0b14;
    cursor: pointer;
    padding: 2px;
}

.sa-color-hex {
    font-family: monospace;
    color: #94a3b8;
    font-size: 0.9rem;
    min-width: 72px;
}

.sa-color-presets {
    display: flex;
    gap: 6px;
}

.sa-color-preset {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s;
}

.sa-color-preset:hover {
    transform: scale(1.2);
    border-color: rgba(255,255,255,0.3);
}

/* ── Activate Button ── */
.sa-agency-activate-btn {
    width: 100%;
    margin-top: 28px;
    padding: 14px;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: 10px;
    color: #fff;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.15s;
}

.sa-agency-activate-btn:hover { opacity: 0.9; transform: translateY(-1px); }
.sa-agency-activate-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.sa-agency-legal-note {
    font-size: 0.78rem;
    color: #64748b;
    text-align: center;
    margin-top: 12px;
}

/* ── Agency Dashboard ── */
.sa-agency-dashboard {
    padding: 24px;
    max-width: 1000px;
}

.sa-agency-portal-url {
    margin-top: 8px;
    font-size: 0.85rem;
    color: #94a3b8;
}

.sa-agency-dash-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 28px;
    gap: 16px;
    flex-wrap: wrap;
}

.sa-agency-dash-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 4px;
}

.sa-agency-link {
    color: var(--agency-primary);
    text-decoration: none;
    font-size: 0.9rem;
}

.sa-agency-link:hover { text-decoration: underline; }

.sa-agency-link-text {
    color: var(--agency-primary);
    font-size: 0.9rem;
    user-select: all;
}

.sa-copy-link-btn {
    margin-left: 8px;
    padding: 2px 10px;
    font-size: 0.78rem;
    background: transparent;
    border: 1px solid var(--agency-primary);
    color: var(--agency-primary);
    border-radius: 6px;
    cursor: pointer;
    vertical-align: middle;
    transition: background 0.15s, color 0.15s;
}
.sa-copy-link-btn:hover {
    background: var(--agency-primary);
    color: #fff;
}

/* ── Client Cards Grid ── */
.sa-agency-clients-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 340px));
    gap: 20px;
    margin-top: 24px;
    justify-content: start;
}

.sa-client-card {
    background: #121421;
    border: 1px solid #1f2235;
    border-radius: 12px;
    padding: 20px;
    transition: border-color 0.2s, transform 0.15s;
}

.sa-client-card:hover {
    border-color: var(--agency-primary);
    transform: translateY(-2px);
}

.sa-client-card-top {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.sa-client-avatar {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--agency-primary), #06b6d4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.sa-client-info {
    flex: 1;
    min-width: 0;
}

.sa-client-info h4 {
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff;
    margin: 0 0 4px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sa-client-tone-badge {
    font-size: 0.75rem;
    color: #64748b;
}

.sa-client-status {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 20px;
    flex-shrink: 0;
}

.sa-status-active {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.sa-status-inactive {
    background: rgba(100, 116, 139, 0.15);
    color: #64748b;
}

.sa-client-card-actions {
    display: flex;
    gap: 8px;
    justify-content: space-between;
}

/* ── Button System ── */
.sa-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    text-decoration: none;
    line-height: 1;
}

.sa-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}


.sa-btn-outline {
    background: transparent;
    color: #94a3b8;
    border: 1px solid #2a2d45;
}

.sa-btn-outline:hover:not(:disabled) {
    border-color: var(--agency-primary, #8b5cf6);
    color: var(--agency-primary, #8b5cf6);
    background: rgba(139,92,246,0.06);
}

.sa-btn-sm {
    padding: 6px 12px;
    font-size: 0.82rem;
}


/* ── Empty / Error states ── */
.sa-agency-empty-clients {
    grid-column: 1 / -1;
    text-align: center;
    padding: 48px;
    color: #64748b;
}

/* ── Logo Upload Area ── */
.sa-logo-upload-area {
    display: flex;
    align-items: center;
    gap: 16px;
    background: rgba(255,255,255,0.02);
    border: 1.5px dashed #2a2d45;
    border-radius: 10px;
    padding: 14px 16px;
    transition: border-color 0.2s;
}

.sa-logo-upload-area:hover {
    border-color: var(--agency-primary);
}

.sa-logo-preview {
    width: 56px;
    height: 56px;
    border-radius: 10px;
    background: #1f2235;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    flex-shrink: 0;
    overflow: hidden;
}

.sa-logo-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.sa-logo-upload-text {
    flex: 1;
    min-width: 0;
}

.sa-logo-upload-text .sa-btn {
    margin-bottom: 6px;
}

/* ── Tone Select — Custom Styled ── */
#sa-client-tone,
.sa-agency-select {
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    background: #0f172a;
    border: 1px solid #2a2d45;
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 0.88rem;
    padding: 10px 36px 10px 12px;
    cursor: pointer;
    transition: border-color 0.2s;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

#sa-client-tone:hover,
.sa-agency-select:hover {
    border-color: var(--agency-primary);
}

#sa-client-tone:focus,
.sa-agency-select:focus {
    outline: none;
    border-color: var(--agency-primary);
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.15);
}

#sa-client-tone option {
    background: #0f172a;
    color: #e2e8f0;
    padding: 8px;
}

/* ──────────────────────────────────────────────────────────────
   CLIENT CONTEXT BANNER (Impersonation Mode)
   ────────────────────────────────────────────────────────────── */
.sa-client-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    z-index: 1000;
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: 12px;
    padding: 12px 20px;
    margin: 16px 24px;
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.05);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sa-client-banner-left {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #e2e8f0;
    font-size: 0.95rem;
}

.sa-client-banner-dot {
    width: 8px;
    height: 8px;
    background-color: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 10px #10b981;
    animation: sa-dot-pulse 2s infinite ease-in-out;
}

@keyframes sa-dot-pulse {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.3); opacity: 1; box-shadow: 0 0 16px #10b981; }
}

.sa-tone-dropdown-wrap {
    position: relative;
    margin-left: 6px;
}

.sa-client-banner-tone {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    font-size: 0.78rem;
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: background 0.15s, border-color 0.15s;
}
.sa-client-banner-tone:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: #e2e8f0;
}
.sa-tone-chevron {
    opacity: 0.6;
    flex-shrink: 0;
}

.sa-tone-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    background: #1a1d2e;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 6px;
    min-width: 210px;
    z-index: 999;
    box-shadow: 0 8px 30px rgba(0,0,0,0.4);
}

.sa-tone-option {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    border-radius: 7px;
    border: none;
    background: transparent;
    color: #94a3b8;
    font-size: 0.82rem;
    cursor: pointer;
    text-align: left;
    transition: background 0.12s, color 0.12s;
}
.sa-tone-option:hover {
    background: rgba(255, 255, 255, 0.07);
    color: #e2e8f0;
}
.sa-tone-option.is-active {
    background: rgba(var(--agency-primary-rgb, 139, 92, 246), 0.15);
    color: var(--agency-primary);
    font-weight: 600;
}
.sa-tone-option-icon {
    font-size: 1rem;
    flex-shrink: 0;
}

.sa-client-banner-btn {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #ef4444;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.sa-client-banner-btn:hover {
    background: #ef4444;
    color: #fff;
    border-color: #ef4444;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.3);
}


/* ──────────────────────────────────────────────────────────────
   CLIENT CARD — CHANGE REQUEST ALERTS
   ────────────────────────────────────────────────────────────── */

/* Card state when client has pending change requests */
.sa-client-card.has-alerts {
    border-color: rgba(245, 158, 11, 0.35);
    box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.12), 0 4px 20px rgba(245, 158, 11, 0.06);
}

.sa-client-card.has-alerts:hover {
    border-color: rgba(245, 158, 11, 0.6);
}

/* Amber chip replacing the "Active" status pill */
.sa-client-alert-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: #f59e0b;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s, border-color 0.2s;
    line-height: 1.3;
}

.sa-client-alert-chip:hover,
.sa-client-alert-chip.is-active {
    background: rgba(245, 158, 11, 0.18);
    border-color: rgba(245, 158, 11, 0.5);
}

/* Pulsing amber dot */
.sa-alert-pulse-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #f59e0b;
    box-shadow: 0 0 6px rgba(245, 158, 11, 0.7);
    flex-shrink: 0;
    animation: sa-amber-pulse 2s ease-in-out infinite;
}

@keyframes sa-amber-pulse {
    0%, 100% { transform: scale(1);   opacity: 0.85; box-shadow: 0 0 6px  rgba(245,158,11,0.6); }
    50%       { transform: scale(1.4); opacity: 1;    box-shadow: 0 0 12px rgba(245,158,11,0.9); }
}

/* Slide-down notification panel */
.sa-client-alerts-panel {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.sa-client-alerts-panel.is-open {
    grid-template-rows: 1fr;
    margin-bottom: 12px;
}

/* Inner wrapper required for grid-row animation */
.sa-alerts-panel-inner {
    overflow: hidden;
    padding-top: 12px;
}

/* Alert item row */
.sa-alert-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: rgba(245, 158, 11, 0.05);
    border: 1px solid rgba(245, 158, 11, 0.12);
    border-radius: 8px;
    padding: 10px 12px;
    margin: 0 4px 6px 4px;
}

.sa-alert-icon {
    font-size: 1rem;
    flex-shrink: 0;
    line-height: 1.4;
}

.sa-alert-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sa-alert-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sa-alert-comment {
    font-size: 0.73rem;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sa-alert-go-btn {
    flex-shrink: 0;
    background: transparent;
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: #f59e0b;
    font-size: 0.73rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s;
    align-self: center;
}

.sa-alert-go-btn:hover {
    background: rgba(245, 158, 11, 0.12);
    border-color: rgba(245, 158, 11, 0.5);
}


