/**
 * Country Program Search CSS
 * Enhanced design for clickable country selector
 */

.sams-country-selector-container {
    padding: 20px;
    margin: 20px 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.country-selector-header {
    text-align: center;
    margin-bottom: 30px;
}

.country-selector-header h2 {
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 2.2em;
    font-weight: 600;
}

.country-selector-header .subtitle {
    color: #7f8c8d;
    font-size: 1.1em;
    margin: 0;
}

.country-search-bar {
    max-width: 500px;
    margin: 0 auto 30px;
    position: relative;
}

.country-search-bar input {
    width: 100%;
    padding: 15px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 50px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.3s, box-shadow 0.3s;
    box-sizing: border-box;
}

.country-search-bar input:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.countries-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.country-card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    border: 1px solid #f0f0f0;
    position: relative;
    overflow: hidden;
}

.country-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #3498db, #2980b9);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.country-card.clickable {
    cursor: pointer;
}

.country-card.clickable:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.country-card.clickable:hover::before {
    transform: scaleX(1);
}

.country-card.clicked {
    transform: scale(0.98);
}

.country-name {
    font-size: 1.4em;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 8px;
}

.country-stats {
    margin-bottom: 15px;
}

.country-institutes,
.country-programs {
    color: #7f8c8d;
    font-size: 0.9em;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
}

.country-institutes::before {
    content: "🏛️";
    margin-right: 6px;
}

.country-programs::before {
    content: "📚";
    margin-right: 6px;
}

.country-action {
    color: #3498db;
    font-size: 0.9em;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.country-card.clickable:hover .country-action {
    opacity: 1;
}

.loading-indicator {
    text-align: center;
    padding: 40px;
    color: #7f8c8d;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.error-message {
    text-align: center;
    color: #e74c3c;
    padding: 20px;
    background: #fdf2f2;
    border: 1px solid #f5b5b5;
    border-radius: 8px;
    margin: 20px 0;
}

/* Inline Programs Section */
.country-programs-section {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 2px solid #e8ecef;
}

.programs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.selected-country-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.btn-back {
    background: #6c757d;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 5px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.btn-back:hover {
    background: #5a6268;
}

#selected-country-title {
    color: #2c3e50;
    margin: 0;
    font-size: 1.8em;
    font-weight: 600;
}

.programs-filters-compact {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 20px;
}

.programs-filters-compact input,
.programs-filters-compact select {
    padding: 8px 12px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 14px;
    min-width: 120px;
}

.programs-filters-compact input[type="number"] {
    min-width: 100px;
    max-width: 120px;
}

.programs-filters-compact input:focus,
.programs-filters-compact select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.1);
}

.btn-primary-small {
    background: #3498db;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.btn-primary-small:hover {
    background: #2980b9;
}

.results-info {
    margin: 15px 0;
    color: #666;
    font-size: 14px;
}

/* Programs Grid */
.programs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.program-card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    padding: 20px;
    transition: transform 0.3s, box-shadow 0.3s;
    border: 1px solid #e8ecef;
}

.program-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
}

.program-header {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.program-name {
    color: #2c3e50;
    margin: 0 0 5px 0;
    font-size: 1.2em;
    font-weight: 600;
    line-height: 1.3;
}

.program-institute {
    color: #7f8c8d;
    font-size: 0.95em;
    font-weight: 500;
}

.program-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 15px;
    font-size: 0.9em;
}

.program-details > div {
    display: flex;
    align-items: center;
    color: #555;
}

.program-description {
    color: #666;
    font-size: 0.9em;
    line-height: 1.4;
    margin-bottom: 15px;
    max-height: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.program-actions {
    display: flex;
    gap: 10px;
    justify-content: space-between;
}

.btn-apply,
.btn-details {
    flex: 1;
    padding: 10px 15px;
    border: none;
    border-radius: 5px;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.btn-apply {
    background: #27ae60;
    color: white;
}

.btn-apply:hover {
    background: #219a52;
    transform: translateY(-1px);
}

.btn-details {
    background: #ecf0f1;
    color: #34495e;
    border: 1px solid #bdc3c7;
}

.btn-details:hover {
    background: #d5dbdb;
    border-color: #95a5a6;
}

/* Pagination */
.pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin: 30px 0;
    flex-wrap: wrap;
}

.pagination-btn {
    padding: 8px 12px;
    border: 1px solid #ddd;
    background: white;
    color: #333;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
}

.pagination-btn:hover {
    background: #3498db;
    color: white;
    border-color: #3498db;
}

.pagination-current {
    padding: 8px 12px;
    background: #3498db;
    color: white;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
}

/* No results message */
.no-results {
    text-align: center;
    color: #666;
    font-size: 1.1em;
    padding: 40px 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e8ecef;
}

/* Country filter notification (if used on programs page) */
.country-filter-notification {
    background: #e3f2fd;
    border: 1px solid #2196f3;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.notification-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.clear-filter-btn {
    background: #2196f3;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.clear-filter-btn:hover {
    background: #1976d2;
}

/* Enhanced form styling for the improved filter layout */
.country-program-search-form .search-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.country-program-search-form .search-field {
    display: flex;
    flex-direction: column;
}

.country-program-search-form .search-field label {
    margin-bottom: 8px;
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
}

.country-program-search-form .search-field input,
.country-program-search-form .search-field select {
    padding: 12px 16px;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
    background: white;
}

.country-program-search-form .search-field input:focus,
.country-program-search-form .search-field select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* Searchable select styling */
.searchable-select {
    position: relative;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 8px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 40px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

.search-field.search-actions {
    flex-direction: row;
    align-items: end;
    gap: 12px;
}

.search-field.search-actions button {
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    min-width: 120px;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.btn-outline {
    background: white;
    color: #3498db;
    border: 2px solid #3498db !important;
}

.btn-outline:hover {
    background: #3498db;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

/* Fee input styling */
input[type="number"] {
    appearance: textfield;
    -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .country-program-search-form .search-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .search-field.search-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-field.search-actions button {
        min-width: unset;
        width: 100%;
    }
}

@media (max-width: 768px) {
    .programs-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .selected-country-info {
        justify-content: center;
    }
    
    .programs-filters-compact {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .programs-filters-compact input,
    .programs-filters-compact select {
        min-width: 150px;
        flex: 1;
    }
    
    .programs-grid {
        grid-template-columns: 1fr;
    }
    
    .program-details {
        grid-template-columns: 1fr;
    }
    
    .program-actions {
        flex-direction: column;
    }
    
    .pagination-container {
        gap: 5px;
    }
    
    .pagination-btn,
    .pagination-current {
        padding: 6px 10px;
        font-size: 12px;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .countries-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 15px;
    }
    
    .country-card {
        padding: 20px;
    }
    
    .country-selector-header h2 {
        font-size: 1.8em;
    }
    
    .country-search-bar input {
        padding: 12px 16px;
        font-size: 15px;
    }
}

@media (max-width: 480px) {
    .countries-grid {
        grid-template-columns: 1fr;
    }
    
    .sams-country-selector-container {
        padding: 15px;
    }
    
    .country-selector-header h2 {
        font-size: 1.6em;
    }
}

/* Integration with existing WordPress themes */
.sams-country-selector-container * {
    box-sizing: border-box;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .country-card {
        border: 2px solid #333;
    }
    
    .country-card:hover {
        border-color: #0066cc;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .country-card,
    .country-card::before,
    .country-action,
    .loading-spinner {
        transition: none;
        animation: none;
    }
    
    .country-card:hover {
        transform: none;
    }
}