/* Call Template Selection Modal Styles */

.call-template-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    animation: modalOverlayFadeIn 0.3s ease-out;
}

@keyframes modalOverlayFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.call-template-modal {
    background: white;
    border-radius: 16px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    max-width: 900px;
    width: 95%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.4s ease-out;
    border: 1px solid rgba(255, 255, 255, 0.18);
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.call-template-modal .modal-header {
    background: linear-gradient(135deg, #2c3e50 0%, #9fbfde 100%);
    color: white;
    padding: 20px 24px 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px solid #2f6690;
}

.call-template-modal .modal-header-content {
    flex: 1;
}

.call-template-modal .modal-title {
    margin: 0 0 8px 0;
    font-size: 1.4em;
    color: white;
    font-weight: 600;
}

.call-template-modal .modal-description {
    margin: 0;
    color: #f8f9fa;
    font-size: 14px;
    line-height: 1.4;
}

.call-template-modal .modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: white;
    padding: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.call-template-modal .modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.call-templates-container {
    padding: 10px 24px;
    max-height: 600px;
    overflow-y: auto;
    flex: 1;
}

.call-templates-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.call-template-card {
    display: flex;
    align-items: center;
    padding: 20px;
    border: 2px solid #e1e8ed;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #fff;
    min-height: 100px;
    position: relative; /* For template-status positioning */
}

.call-template-card:hover {
    border-color: #4a90b8;
    background-color: #fbfcfd;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 144, 184, 0.15);
}

.call-template-card.selected {
    border-color: #77a0c6;
    background-color: #ebf2f9;
    box-shadow: 0 4px 12px rgb(144 174 203 / 70%);
}

.call-template-card.selected:hover {
    border-color: #b0c9e0;
    background-color: #ebf2f9;
}

.template-icon {
    margin-right: 16px;
    flex-shrink: 0;
}

.template-icon i {
    font-size: 28px;
    color: #4a90b8;
    width: 32px;
    text-align: center;
}

.call-template-card.selected .template-icon i {
    color: #385a7a;
}

.template-info {
    flex: 1;
}

.template-info h4 {
    margin: 0 0 8px 0;
    font-size: 16px;
    color: #2c3e50;
    font-weight: 600;
}

.template-info p {
    margin: 0;
    font-size: 0.8rem;
    color: #5a6c7d;
    line-height: 1.2;
}

.call-template-modal .action-buttons {
    display: flex;
    gap: 12px;
    padding: 20px 24px;
    border-top: 1px solid #e9ecef;
    background: #f8f9fa;
}

.call-template-modal-button {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    flex: 1;
}

.call-template-modal-button.cancel {
    background: #6c757d;
    color: white;
}

.call-template-modal-button.cancel:hover {
    background: #5a6268;
}

.call-template-modal-button.confirm {
    background: #5b738a;
    color: white;
    flex: 2;
}

.call-template-modal-button.confirm:hover {
    background: #3d7a9e;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74, 144, 184, 0.3);
}

.call-template-modal-button.confirm:disabled {
    background: #d1dae0;
    color: #6c7a86;
    cursor: not-allowed;
    opacity: 0.7;
    transform: none !important;
    box-shadow: none;
}

.call-template-modal-button.confirm:disabled:hover {
    background: #d1dae0;
    transform: none !important;
    box-shadow: none;
}

/* Template status indicator */
.template-status {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #28a745;
    background: rgba(40, 167, 69, 0.1);
    padding: 2px 6px;
    border-radius: 12px;
    border: 1px solid rgba(40, 167, 69, 0.2);
}

.template-status i {
    font-size: 0.8rem;
}

/* Readonly template cards */
.call-template-card.readonly {
    opacity: 0.7;
    cursor: not-allowed;
    position: relative;
}

.call-template-card.readonly::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    pointer-events: none;
}

.call-template-card.readonly:hover {
    transform: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Templates indicator styles for Call Analysis header */
.templates-indicator {
    display: flex;
    align-items: center;
    margin-left: 12px;
}

.templates-icon-badge {
    position: relative;
    background: transparent;
    border: none;
    color: #4a90b8;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.templates-icon-badge i {
    font-size: 20px;
    transition: all 0.2s ease;
}

.templates-icon-badge:hover {
    background: rgba(74, 144, 184, 0.1);
    color: #3d7a9e;
    transform: translateY(-1px);
}

.templates-icon-badge:hover i {
    transform: scale(1.1);
}

/* Count badge positioned over the icon */
.template-count-badge {
    position: absolute;
    top: -8px;
    right: -10px;
    background: #4a90b8;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    min-width: 18px;
    line-height: 1;
}

/* No templates state - gray colors */
.templates-icon-badge.no-templates {
    color: #6c757d;
}

.templates-icon-badge.no-templates:hover {
    background: rgba(108, 117, 125, 0.1);
    color: #495057;
}

.templates-icon-badge.no-templates .template-count-badge {
    color: white;
}

.templates-icon-badge.no-templates:hover .template-count-badge {
    background: #495057;
}

/* Adjust Call Analysis header layout */
.call-details-header .block-title {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.call-details-header .block-title h3 {
    margin: 0;
}

/* Responsive design */
@media (max-width: 768px) {
    .call-template-modal {
        width: 95%;
        max-width: none;
        margin: 20px;
    }
    
    .call-templates-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .call-template-card {
        min-height: auto;
        padding: 16px;
    }
    
    .template-icon i {
        font-size: 24px;
    }
    
    .call-template-modal .modal-header {
        padding: 20px;
    }
    
    .call-templates-container {
        padding: 20px;
    }
    
    .call-template-modal .action-buttons {
        padding: 16px 20px;
        flex-direction: column;
    }
    
    .call-template-modal-button.confirm {
        flex: 1;
    }
}

/* Custom Instructions Modal Styles */
.custom-instructions-modal-content {
    max-width: 600px;
    width: 90%;
}

.custom-instructions-container {
    padding: 20px 24px;
    flex: 1;
}

.custom-instructions-textarea {
    width: 100%;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    padding: 16px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    resize: vertical;
    min-height: 200px;
    background: #fff;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
}

.custom-instructions-textarea:focus {
    outline: none;
    border-color: #4a90b8;
    box-shadow: 0 0 0 3px rgba(74, 144, 184, 0.1);
}

.custom-instructions-textarea::placeholder {
    color: #6c757d;
    font-style: italic;
    line-height: 1.4;
}

/* Special styling for custom analysis template card */
/* Support both "custom_analysis" (local) and "call_analysis_custom_analysis" (production) */
.call-template-card[data-template-id="custom_analysis"] .template-icon i,
.call-template-card[data-template-id="call_analysis_custom_analysis"] .template-icon i {
    color: #e67e22;
}

.call-template-card[data-template-id="custom_analysis"].selected .template-icon i,
.call-template-card[data-template-id="call_analysis_custom_analysis"].selected .template-icon i {
    color: #d35400;
}

.call-template-card[data-template-id="custom_analysis"],
.call-template-card[data-template-id="call_analysis_custom_analysis"] {
    border-color: #f39c12;
}

.call-template-card[data-template-id="custom_analysis"]:hover,
.call-template-card[data-template-id="call_analysis_custom_analysis"]:hover {
    border-color: #e67e22;
    background-color: #fef9e7;
}

.call-template-card[data-template-id="custom_analysis"].selected,
.call-template-card[data-template-id="call_analysis_custom_analysis"].selected {
    border-color: #e67e22;
    background-color: #fdf2e9;
    box-shadow: 0 4px 12px rgba(230, 126, 34, 0.3);
}

.call-template-card[data-template-id="custom_analysis"].selected:hover,
.call-template-card[data-template-id="call_analysis_custom_analysis"].selected:hover {
    border-color: #d35400;
    background-color: #fdf2e9;
}