.search-container {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    align-items: flex-start;
}

.template-selector {
    min-width: 100px;
}

.btn-template {
    background: linear-gradient(135deg, #e9f1ff 0%, #ffffff 100%);
    border: 1px solid #cfd9f5;
    color: #2f3f5c;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 1px;
    white-space: nowrap;
    box-shadow: 0 8px 18px rgba(44, 84, 179, 0.12);
}

.btn-template:hover {
    background: linear-gradient(135deg, #dce8ff 0%, #ffffff 100%);
    border-color: #a9b9ee;
    transform: translateY(-1px);
}

.btn-template.selected {
    background: linear-gradient(135deg, #1f79ff 0%, #5c66ff 100%);
    color: white;
    border-color: #4d6bff;
}

.dropdown-arrow {
    margin-left: 8px;
    font-size: 10px;
    opacity: 0.7;
}

.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: white;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
}

.modal-header h3 {
    margin: 0;
    font-size: 16px;
}

.close {
    font-size: 24px;
    font-weight: bold;
    color: #999;
    cursor: pointer;
    line-height: 1;
}

.close:hover {
    color: #333;
}

.modal-body {
    padding: 20px;
    max-height: calc(80vh - 80px);
    overflow-y: auto;
}

.template-modal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.template-modal-card {
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: white;
}

.template-modal-card:hover {
    border-color: #007aff;
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.2);
}

.template-modal-card.selected {
    border-color: #007aff;
    background: #f0f8ff;
}

.template-modal-preview {
    width: 100%;
    height: 100px;
    object-fit: cover;
    border-radius: 4px;
    margin-bottom: 8px;
}

.template-modal-name {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 4px;
}

.template-modal-description {
    font-size: 11px;
    color: #666;
    line-height: 1.3;
}

.api-status {
    padding: 10px;
    border-radius: 10px;
    margin-bottom: 12px;
    font-weight: 500;
    border: 1px solid;
    font-size: 12px;
}

.api-status.success {
    background: rgba(52, 199, 89, 0.1);
    border-color: rgba(52, 199, 89, 0.3);
    color: #34c759;
}

.api-status.error {
    background: rgba(255, 59, 48, 0.1);
    border-color: rgba(255, 59, 48, 0.3);
    color: #ff3b30;
}

.loading {
    color: #007aff;
    font-weight: 500;
    font-size: 12px;
    padding: 10px;
}

.loading-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(0, 122, 255, 0.2);
    border-top: 2px solid #007aff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

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

@keyframes slideInUp {
    from {
        transform: translateY(30px) scale(0.9);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

@media (max-width: 480px) {
    .search-container {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
        text-align: left;
    }

    .template-selector {
        min-width: auto;
        width: 100%;
        display: flex;
        justify-content: stretch;
    }

    .btn-template {
        width: 100%;
        font-size: 13px;
        padding: 10px 12px;
        margin: 0 auto;
        border-radius: 12px;
        justify-content: space-between;
    }

    .modal-content {
        width: 95%;
        max-height: 90vh;
    }

    .template-modal-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 8px;
    }

    .template-modal-card {
        padding: 8px;
    }

    .template-modal-preview {
        height: 80px;
    }

    .template-modal-name {
        font-size: 12px;
    }

    .template-modal-description {
        font-size: 10px;
    }

    .api-status {
        padding: 8px;
        margin-bottom: 8px;
        font-size: 11px;
        border-radius: 8px;
    }

    .loading {
        font-size: 11px;
        padding: 8px;
    }
}

@media (max-width: 400px) {
    .search-container {
        align-items: center;
        text-align: center;
    }

    .template-selector {
        display: flex;
        justify-content: center;
    }
}

@media (max-width: 360px) {
    .search-container {
        align-items: center;
        text-align: center;
        justify-content: center;
    }

    .template-selector {
        display: flex;
        justify-content: center;
        width: 100%;
    }
}
