/* ========================================
   CRM SETTINGS - Admin Configuration
   ======================================== */

/* Override section padding for CRM settings — tight layout */
#section-crm-settings {
    padding: 8px 0 12px 0;
    max-width: none;
}

/* Two-column layout */
.crm-settings-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    align-items: start;
}

.crm-settings-col-left,
.crm-settings-col-right {
    display: grid;
    gap: 12px;
}

.crm-settings-grid {
    display: grid;
    gap: 12px;
}

/* Card */
.crm-settings-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
}

.crm-settings-card.disabled {
    opacity: 0.6;
    pointer-events: none;
}

.crm-settings-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    background: #fafbfc;
}

.crm-settings-card-header .card-icon {
    font-size: 18px;
    line-height: 1;
}

.crm-settings-card-header .card-title {
    font-size: 15px;
    font-weight: 600;
    color: #1e293b;
    flex: 1;
}

.crm-settings-badge-soon {
    background: #f1f5f9;
    color: #94a3b8;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.crm-settings-card-body {
    padding: 14px;
    display: grid;
    gap: 14px;
}

/* Field */
.crm-settings-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.crm-settings-field .field-label {
    font-size: 13px;
    font-weight: 600;
    color: #475569;
}

.crm-settings-field .field-hint {
    font-size: 12px;
    color: #94a3b8;
    margin-top: -4px;
}

/* Range field (2 selects with dash) */
.crm-settings-range {
    display: flex;
    align-items: center;
    gap: 12px;
}

.crm-settings-range select {
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    color: #1e293b;
    background: #fff;
    cursor: pointer;
    min-width: 90px;
}

.crm-settings-range select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.crm-settings-range .range-dash {
    color: #94a3b8;
    font-weight: 500;
}

/* Radio group (pill style) */
.crm-settings-radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.crm-settings-radio {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    color: #475569;
    background: #fff;
    transition: all 0.15s ease;
    user-select: none;
}

.crm-settings-radio:hover {
    border-color: #cbd5e1;
    background: #f8fafc;
}

.crm-settings-radio.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border-color: transparent;
    font-weight: 500;
}

.crm-settings-radio input[type='radio'] {
    display: none;
}

/* Preview */
.crm-settings-preview {
    border: 1px dashed #e2e8f0;
    border-radius: 8px;
    padding: 12px;
    background: #fafbfc;
    overflow: hidden;
}

.crm-settings-preview .preview-label {
    font-size: 11px;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    font-weight: 600;
}

.preview-timeline {
    position: relative;
    overflow: hidden;
    border-radius: 4px;
}

.preview-hour-row {
    display: flex;
    align-items: flex-start;
    border-bottom: 1px solid #f1f5f9;
}

.preview-hour-label {
    width: 32px;
    font-size: 10px;
    color: #94a3b8;
    text-align: right;
    padding-right: 6px;
    flex-shrink: 0;
    line-height: 1;
    transform: translateY(-5px);
}

.preview-hour-cell {
    flex: 1;
    border-left: 1px solid #e2e8f0;
}

.preview-meeting {
    position: absolute;
    left: 38px;
    right: 4px;
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 10px;
    overflow: hidden;
    white-space: nowrap;
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    color: #b45309;
    border-left: 2px solid #f59e0b;
}

/* Placeholder content */
.crm-settings-placeholder {
    padding: 8px 0;
    font-size: 13px;
    color: #94a3b8;
    line-height: 1.6;
}

/* Actions bar */
.crm-settings-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 10px;
    border-top: 1px solid #f1f5f9;
}

.crm-settings-actions .btn-reset {
    padding: 10px 20px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
    color: #64748b;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.crm-settings-actions .btn-reset:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.crm-settings-actions .btn-save {
    padding: 10px 24px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.crm-settings-actions .btn-save:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.crm-settings-actions .btn-save:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Loading */
.crm-settings-loading {
    text-align: center;
    padding: 60px 20px;
    color: #94a3b8;
    font-size: 14px;
}

/* Radio group wrap (for many options) */
.crm-settings-radio-group--wrap {
    flex-wrap: wrap;
}

/* ============ SCORING ============ */
.scoring-section {
    padding: 12px 0;
    border-bottom: 1px solid #f1f5f9;
}

.scoring-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.scoring-section:first-child {
    padding-top: 0;
}

.scoring-section-title {
    font-size: 11px;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.scoring-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
}

.scoring-icon {
    font-size: 14px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.scoring-label {
    flex: 1;
    font-size: 13px;
    color: #475569;
}

.scoring-input-wrap {
    display: flex;
    align-items: center;
    gap: 4px;
}

.scoring-input {
    width: 56px;
    padding: 4px 6px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 13px;
    text-align: center;
    color: #1e293b;
    background: #fff;
    font-family: inherit;
}

.scoring-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.15);
}

.scoring-input.positive {
    color: #16a34a;
}

.scoring-input.negative {
    color: #dc2626;
}

.scoring-unit {
    font-size: 11px;
    color: #94a3b8;
    width: 20px;
}

/* Thresholds */
.scoring-thresholds {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.threshold-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
}

.threshold-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.threshold-item.hot .threshold-dot {
    background: #ef4444;
}
.threshold-item.warm .threshold-dot {
    background: #f59e0b;
}
.threshold-item.cold .threshold-dot {
    background: #94a3b8;
}

.threshold-label {
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    width: 48px;
}

.threshold-op {
    font-size: 12px;
    color: #94a3b8;
    width: 16px;
    text-align: center;
}

.threshold-auto {
    font-size: 13px;
    color: #94a3b8;
    font-style: italic;
}

.scoring-input.threshold {
    width: 52px;
}

/* Decay */
.scoring-decay {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.decay-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
}

.decay-row .scoring-label {
    flex: 1;
}

.decay-row .scoring-input {
    width: 52px;
}

/* ======== ACTIVE CONFIG BANNER ======== */
.scoring-active-banner {
    padding: 10px 14px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);
    border-bottom: 1px solid rgba(102, 126, 234, 0.15);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.scoring-active-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
}

.scoring-active-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
    animation: scoring-pulse 2s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes scoring-pulse {
    0%,
    100% {
        box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.1);
    }
}

.scoring-active-label {
    font-size: 10px;
    font-weight: 700;
    color: #667eea;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.scoring-active-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-left: 16px;
}

.scoring-active-name {
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
}

.scoring-active-meta {
    font-size: 11px;
    color: #94a3b8;
}

/* ======== TEMPLATE CARDS ======== */
.scoring-templates-section {
    padding: 8px 0;
    border-bottom: 1px solid #f1f5f9;
    margin-bottom: 8px;
}

.scoring-templates-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.scoring-templates-title {
    font-size: 11px;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-template-new {
    padding: 4px 12px;
    border: 1px dashed #cbd5e1;
    border-radius: 6px;
    background: transparent;
    color: #667eea;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
}

.btn-template-new:hover {
    background: rgba(102, 126, 234, 0.06);
    border-color: #667eea;
}

.scoring-templates-grid {
    display: grid;
    gap: 8px;
    max-height: 260px;
    overflow-y: auto;
}

.scoring-template-card {
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
    transition: all 0.15s ease;
}

.scoring-template-card:hover {
    border-color: #cbd5e1;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.scoring-template-card.active {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.03);
    box-shadow: 0 0 0 1px rgba(102, 126, 234, 0.2);
}

.scoring-template-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
}

.scoring-template-name {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.scoring-template-active-badge {
    font-size: 9px;
    font-weight: 700;
    color: #667eea;
    background: rgba(102, 126, 234, 0.1);
    padding: 2px 8px;
    border-radius: 10px;
    letter-spacing: 0.5px;
    flex-shrink: 0;
    text-transform: uppercase;
}

.scoring-template-card-meta {
    display: flex;
    gap: 12px;
    font-size: 11px;
    color: #94a3b8;
    margin-bottom: 4px;
}

.scoring-template-card-desc {
    font-size: 12px;
    color: #64748b;
    line-height: 1.4;
    margin-bottom: 6px;
}

.scoring-template-card-actions {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}

.scoring-template-card-actions button {
    padding: 3px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    background: #fff;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.12s ease;
    color: #475569;
    font-family: inherit;
}

.btn-tpl-preview:hover {
    background: #f0f4ff;
    border-color: #93a3f5;
    color: #667eea;
}

.btn-tpl-apply:hover {
    background: #f0fdf4;
    border-color: #86efac;
    color: #16a34a;
}

.btn-tpl-delete:hover {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #dc2626;
}

.scoring-templates-empty {
    font-size: 12px;
    color: #94a3b8;
    text-align: center;
    padding: 12px;
    background: #fafbfc;
    border-radius: 6px;
    border: 1px dashed #e2e8f0;
}

/* ======== NEW TEMPLATE FORM ======== */
.scoring-template-form {
    padding: 10px 12px;
    background: #fafbfc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.scoring-template-input {
    padding: 8px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 13px;
    color: #1e293b;
    background: #fff;
    font-family: inherit;
    width: 100%;
    box-sizing: border-box;
}

.scoring-template-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.15);
}

.scoring-template-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.btn-template-cancel {
    padding: 6px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #fff;
    color: #64748b;
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
}

.btn-template-cancel:hover {
    background: #f8fafc;
}

.btn-template-confirm {
    padding: 6px 14px;
    border: none;
    border-radius: 6px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

.btn-template-confirm:hover {
    opacity: 0.9;
}

/* ======== PREVIEW MODE ======== */
.scoring-preview-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 8px;
    margin-bottom: 12px;
}

.scoring-preview-icon {
    font-size: 16px;
}

.scoring-preview-text {
    flex: 1;
    font-size: 12px;
    color: #92400e;
}

.btn-preview-cancel {
    padding: 4px 10px;
    border: 1px solid #fbbf24;
    border-radius: 4px;
    background: #fff;
    color: #b45309;
    font-size: 11px;
    cursor: pointer;
    font-family: inherit;
}

.btn-preview-cancel:hover {
    background: #fef3c7;
}

.scoring-input.preview-mode {
    border-color: #fbbf24;
    background: #fffef5;
}

/* ======== SELF-CONTAINED ACTIONS ======== */
.scoring-card-actions {
    padding-top: 10px;
    margin-top: 10px;
    border-top: 1px solid #f1f5f9;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn-scoring-apply {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    width: 100%;
    text-align: center;
    font-family: inherit;
}

.btn-scoring-apply:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-scoring-apply:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-recalc {
    padding: 8px 20px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
    color: #475569;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    width: 100%;
    text-align: center;
    font-family: inherit;
}

.btn-recalc:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.btn-recalc:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f1f5f9;
    color: #94a3b8;
}

/* Responsive */
@media (max-width: 960px) {
    .crm-settings-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .crm-settings-radio-group {
        flex-direction: column;
    }

    .crm-settings-radio {
        justify-content: center;
    }

    .crm-settings-actions {
        flex-direction: column;
        gap: 12px;
    }

    .crm-settings-actions .btn-reset,
    .crm-settings-actions .btn-save {
        width: 100%;
        text-align: center;
    }
}
