/* ==================== TEMPLATE COMPONENTS ==================== */

/* --- Button Template --- */
.template-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.template-btn {
    width: 100%;
    padding: 10px 16px;
    border: 1px solid var(--primary-color);
    border-radius: 12px;
    background: white;
    color: var(--primary-color);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-align: center;
    line-height: 1.4;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.template-btn:hover {
    background: var(--primary-gradient);
    color: white;
    border-color: transparent;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.template-btn:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

/* --- List Template --- */
.template-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
}

.list-item {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    background: white;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.list-item[style*="cursor: pointer"]:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.list-item-image {
    width: 100%;
    height: 130px;
    object-fit: cover;
    display: block;
    background: var(--secondary-color);
}

.list-item-body {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.list-item-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-color);
    line-height: 1.4;
}

.list-item-subtitle {
    font-size: 12px;
    color: var(--text-light);
    line-height: 1.5;
    margin-bottom: 4px;
}

/* Buttons inside list items get a slightly tighter look */
.list-item-body .template-btn {
    margin-top: 6px;
    padding: 8px 14px;
    font-size: 12px;
}

/* --- Quick Replies --- */
.quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-self: flex-start;
    max-width: 85%;
    margin-top: 4px;
    animation: slideIn 0.3s ease-out;
}

.quick-replies .template-btn {
    width: auto;
    border-radius: 20px;
    padding: 8px 16px;
    background: white;
    box-shadow: var(--shadow-sm);
}

/* --- Carousel (if you add it later) --- */
.template-carousel {
    display: flex;
    gap: 10px;
    margin-top: 8px;
    overflow-x: auto;
    padding-bottom: 6px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}

.template-carousel .list-item {
    flex: 0 0 220px;
    scroll-snap-align: start;
}

.template-carousel::-webkit-scrollbar {
    height: 4px;
}

.template-carousel::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}

.bot-message:has(.template-buttons),
.bot-message:has(.template-list),
.bot-message:has(.template-carousel) {
    max-width: 95%;
}

.template-btn.selected {
    background: var(--primary-gradient);
    color: white;
    border-color: transparent;
    font-weight: 700;
    cursor: default;
    box-shadow: var(--shadow-sm);
}

.template-btn.selected::after {
    content: "✓";
    margin-left: 8px;
    font-weight: 700;
}

.template-btn.locked {
    opacity: 0.45;
    cursor: default;
    pointer-events: none;
}

.template-btn.locked:hover {
    background: white;
    color: var(--primary-color);
    transform: none;
    box-shadow: none;
}

.template-btn.selected.locked {
    opacity: 1;
    pointer-events: none;
}

/* --- Error Message --- */
.bot-message .message-content.error-content {
    --error-accent: var(--primary-color);
    background: #FEF2F2;
    border: 1px solid #FCA5A5;
    border-left: 4px solid var(--error-accent, #DC2626);
    border-radius: 16px 16px 16px 4px;
}

.error-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.error-icon {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--error-accent, #DC2626);
    margin-top: 1px;
}

.error-content p {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    color: #7F1D1D;
}

.error-content .message-time {
    color: #B91C1C;
    opacity: 0.7;
}