/**
 * iCarol Resources Frontend Styles
 */

/* Reset and base styles */
.icarol-container * {
    box-sizing: border-box;
}

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

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes shimmer {
    0% { background-position: -200px 0; }
    100% { background-position: calc(200px + 100%) 0; }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { transform: translateX(-100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Main Loading Overlay */
.loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(2px);
}

.loader.inline {
    position: relative;
    height: 200px;
    background: rgba(248, 249, 250, 0.9);
    border-radius: 8px;
    margin: 20px;
}

/* Spinner Animation */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e9ecef;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

.spinner.small {
    width: 20px;
    height: 20px;
    border-width: 2px;
    margin-bottom: 8px;
}

/* Loading Text */
.loading-text {
    font-size: 16px;
    color: #495057;
    font-weight: 500;
    text-align: center;
}

.loading-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Skeleton Loading for Results */
.skeleton-loading {
    padding: 20px;
}

.skeleton-item {
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 16px;
    overflow: hidden;
    position: relative;
}

.skeleton-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.6),
        transparent
    );
    animation: shimmer 2s infinite;
}

.skeleton-header {
    height: 24px;
    background: #e9ecef;
    border-radius: 4px;
    margin-bottom: 12px;
    width: 70%;
}

.skeleton-line {
    height: 16px;
    background: #e9ecef;
    border-radius: 4px;
    margin-bottom: 8px;
}

.skeleton-line.short {
    width: 60%;
}

.skeleton-line.medium {
    width: 80%;
}

.skeleton-line.long {
    width: 90%;
}

/* Button Loading States */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.btn-loading::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.btn-loading .btn-text {
    opacity: 0;
}

/* Map Loading */
.map-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(248, 249, 250, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 4px;
    background: #e9ecef;
    border-radius: 2px;
    overflow: hidden;
    margin-top: 8px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #007bff, #0056b3);
    border-radius: 2px;
    transition: width 0.3s ease;
    animation: pulse 1.5s infinite;
}

/* Result Item Styling - Match Screenshot Layout */
.result-item {
    background: #ffffff;
    border: none;
    border-bottom: 1px solid #e0e0e0;
    padding: 16px 0;
    margin: 0;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    animation: fadeIn 0.5s ease-out;
}

.result-item:last-child {
    border-bottom: none;
}

.result-marker-icon {
    flex-shrink: 0;
    margin-top: 2px;
}

.result-marker-icon svg {
    width: 24px !important;
    height: 24px !important;
}

.result-content {
    flex: 1;
    display: flex;
    gap: 20px;
}

.result-main {
    flex: 1;
}

.result-title {
    font-size: 19px;
    font-weight: bold;
    color: #2563eb;
    margin: 0 0 4px 0;
    line-height: 1.3;
}

.result-title a {
    color: #2563eb;
    text-decoration: none;
}

.result-title a:hover {
    text-decoration: underline;
}

.result-agency {
    font-size: 14px;
    color: #666666;
    margin-bottom: 8px;
}

.result-agency a {
    color: #666666;
    text-decoration: none;
}

.result-agency a:hover {
    text-decoration: underline;
}

.result-description {
    font-size: 16px !important;
    color: #000000 !important;
    line-height: 1.3 !important;
    margin-bottom: 0;
}

.result-sidebar {
    flex-shrink: 0;
    width: 140px;
    text-align: right;
}

.result-location {
    font-size: 15px !important;
    color: #666666;
    line-height: 1.3;
    margin-bottom: 8px;
}

.result-location strong {
    color: #333333;
    font-weight: bold;
    display: block;
    margin-bottom: 2px;
}

.result-url {
    font-size: 15px !important;
}

.result-url a {
    color: #2563eb;
    text-decoration: none;
}

.result-url a:hover {
    text-decoration: underline;
}

/* Fade In Animation for Results */
.result-item {
    animation: fadeIn 0.5s ease-out;
}

.result-item:nth-child(1) { animation-delay: 0.1s; }
.result-item:nth-child(2) { animation-delay: 0.2s; }
.result-item:nth-child(3) { animation-delay: 0.3s; }
.result-item:nth-child(4) { animation-delay: 0.4s; }
.result-item:nth-child(5) { animation-delay: 0.5s; }

/* Loading States for Different Components */
.search-loading {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
}

.map-marker-loading {
    position: relative;
}

.map-marker-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid #e9ecef;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Main container */
.icarol-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: #333;
}

/* Layout containers */
.split-container {
    display: flex;
    gap: 20px;
    min-height: 500px;
}

.split-30 {
    flex: 0 0 30%;
    background-color: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.split-70 {
    flex: 1;
    background-color: #fff;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    overflow: hidden;
}

/* Search sections */
.search-section {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e9ecef;
}

.search-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.search-section h4 {
    margin: 0 0 8px 0;
    font-size: 19px;
    font-weight: 700;
    color: #000000;
}

.search-section .description {
    margin: 0 0 16px 0;
    font-size: 17px !important;
    color: #495057 !important;
    line-height: 1.3;
}

/* Form elements */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 15px;
    color: #495057;
}

.form-control,
.form-select {
    display: block;
    width: 100%;
    padding: 8px 12px;
    font-size: 15px;
    line-height: 1.5;
    color: #495057;
    background-color: #fff;
    border: 1px solid #ced4da;
    border-radius: 4px;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus,
.form-select:focus {
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.form-control::placeholder {
    color: #6c757d;
    opacity: 1;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 8px 16px;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.5;
    text-align: center;
    text-decoration: none;
    vertical-align: middle;
    cursor: pointer;
    border: 1px solid transparent;
    border-radius: 4px;
    transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    user-select: none;
}

.btn:focus {
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.btn:hover {
    text-decoration: none;
}

.btn-primary {
    color: #fff;
    background-color: #007bff;
    border-color: #007bff;
}

.btn-primary:hover {
    color: #fff;
    background-color: #0056b3;
    border-color: #004085;
}

.btn-primary:focus,
.btn-primary.focus {
    box-shadow: 0 0 0 0.2rem rgba(38, 143, 255, 0.5);
}

.btn-secondary {
    color: #fff;
    background-color: #6c757d;
    border-color: #6c757d;
}

.btn-secondary:hover {
    color: #fff;
    background-color: #545b62;
    border-color: #4e555b;
}

.btn-block {
    display: block;
    width: 100%;
}

.btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

/* Map container */
.map-container {
    height: 450px;
    width: 100%;
    border-bottom: 1px solid #e9ecef;
}

#map {
    width: 100%;
    height: 100%;
}

/* Custom map markers */
.custom-marker {
    background: transparent;
    width: 30px;
    height: 30px;
    position: relative;
    cursor: pointer;
}

.marker-label {
    background-color: #ff0000 !important;
    color: #ffffff !important;
    font-size: 16px;
    font-weight: bold;
    text-align: center;
    line-height: 30px;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: block;
    position: relative;
    z-index: 10;
}

.marker-label.highlighted {
    background-color: #28a745;
    transform: scale(1.2);
    z-index: 1000;
}

.marker-popup {
    max-width: 300px;
}

.marker-popup h3.h3class {
    font-size: 16px;
    margin-bottom: 10px;
    color: #333;
}

.marker-popup p {
    margin: 4px 0;
    font-size: 14px;
    color: #6c757d;
}

.marker-popup a.hrefmap {
    color: #007bff;
    text-decoration: none;
}

.marker-popup a.hrefmap:hover {
    text-decoration: underline;
}

/* Results section */
.icarolcontent {
    padding: 20px;
}

.results-header {
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e9ecef;
}

.results-header h4 {
    margin: 0;
    font-size: 20px;
    color: #495057;
}

/* Result items */
.result-item {
    display: flex;
    gap: 12px;
    padding: 16px;
    margin-bottom: 16px;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: #fff;
}

.result-item:hover {
    border-color: #80bdff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.result-marker {
    flex: 0 0 30px;
    height: 30px;
    background-color: #dc3545;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
}

.result-content {
    flex: 1;
}

.result-title {
    margin: 0 0 8px 0;
    font-size: 18px;
    font-weight: 600;
    color: #495057;
    line-height: 1.3;
}

.result-agency {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 500;
    color: #6c757d;
}

.result-description {
    margin: 0 0 12px 0;
    font-size: 14px;
    color: #6c757d;
    line-height: 1.5;
}

.result-address {
    margin: 8px 0;
    font-size: 14px;
    color: #495057;
}

.result-website {
    margin: 8px 0 0 0;
}

.result-website a {
    color: #007bff;
    text-decoration: none;
    font-weight: 500;
}

.result-website a:hover {
    text-decoration: underline;
}

/* No results and error states */
.no-results,
.error-message {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
    font-size: 16px;
}

.error-message {
    color: #dc3545;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
}

/* Pagination */
.pagination-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 24px 0;
    padding: 20px 0;
    border-top: 1px solid #e9ecef;
}

.page-info {
    margin-right: 16px;
    font-size: 14px;
    color: #6c757d;
}

.page-number,
.prev-page,
.next-page {
    padding: 6px 12px;
    font-size: 14px;
    border: 1px solid #dee2e6;
    background-color: #fff;
    color: #495057;
    text-decoration: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.page-number:hover,
.prev-page:hover,
.next-page:hover {
    background-color: #e9ecef;
    border-color: #adb5bd;
}

.page-number.current {
    background-color: #007bff;
    border-color: #007bff;
    color: #fff;
}

.prev-page:disabled,
.next-page:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Loading spinner */
.loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-text {
    color: #fff;
    font-size: 18px;
    font-weight: 500;
    background-color: rgba(0, 0, 0, 0.8);
    padding: 20px 30px;
    border-radius: 8px;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .split-container {
        flex-direction: column;
    }
    
    .split-30,
    .split-70 {
        flex: none;
        width: 100%;
    }
    
    .split-30 {
        order: 2;
    }
    
    .split-70 {
        order: 1;
    }
    
    .map-container {
        height: 300px;
    }
    
    .result-item {
        flex-direction: column;
        gap: 8px;
    }
    
    .result-marker {
        align-self: flex-start;
    }
    
    .pagination-wrapper {
        flex-wrap: wrap;
        gap: 4px;
    }
    
    .page-info {
        width: 100%;
        text-align: center;
        margin: 0 0 8px 0;
    }
}

@media (max-width: 480px) {
    .icarol-container {
        padding: 0 10px;
    }
    
    .split-30,
    .icarolcontent {
        padding: 15px;
    }
    
    .map-container {
        height: 250px;
    }
    
    .result-title {
        font-size: 16px;
    }
    
    .result-agency {
        font-size: 14px;
    }
    
    .result-description {
        font-size: 13px;
    }
}

/* Accessibility improvements */
.btn:focus,
.form-control:focus,
.form-select:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

.result-item:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Screen reader only text */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Enhanced Loading Animations */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Spinner styles */
.spinner {
    border: 3px solid rgba(0, 123, 255, 0.3);
    border-top: 3px solid #007bff;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

.spinner.small {
    width: 24px;
    height: 24px;
    border-width: 2px;
}

/* Button Loading Animation */
.btn-loading {
    position: relative;
    overflow: hidden;
    pointer-events: none;
}

.btn-loading:after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin-top: -8px;
    margin-left: -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.btn-loading .btn-text {
    opacity: 0;
}

/* Map Loading Overlay */
.map-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    border-radius: 8px;
}

.map-loading .loading-wrapper {
    text-align: center;
}

.map-loading .loading-text {
    margin-top: 10px;
    font-size: 14px;
    color: #6c757d;
}

/* Skeleton Loading */
.skeleton-loading {
    padding: 20px;
}

.skeleton-item {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    margin-bottom: 16px;
    overflow: hidden;
}

.skeleton-header {
    height: 20px;
    background: linear-gradient(90deg, #f8f9fa 25%, #e9ecef 50%, #f8f9fa 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    margin-bottom: 12px;
    border-radius: 4px;
}

.skeleton-line {
    height: 14px;
    background: linear-gradient(90deg, #f8f9fa 25%, #e9ecef 50%, #f8f9fa 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    margin-bottom: 8px;
    border-radius: 4px;
}

.skeleton-line.short {
    width: 60%;
}

.skeleton-line.medium {
    width: 80%;
}

.skeleton-line.long {
    width: 95%;
}

/* Search Loading State */
.search-loading {
    padding: 40px 20px;
    text-align: center;
}

.search-loading .loading-wrapper {
    max-width: 300px;
    margin: 0 auto;
}

/* Enhanced default state styling */
#default-state {
    border-radius: 8px;
    background: #f8f9fa;
    border: 1px dashed #dee2e6;
}

/* Progress Bar for Advanced Loading */
.progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(0, 123, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #007bff, #0056b3);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 2px;
}

/* Original result item styling */
.contDiv {
    display: flex;
    align-items: flex-start;
    margin-bottom: 10px;
    gap: 10px;
}

.contDiv img {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
}

.contDiv div {
    flex: 1;
}

.h3class.forLineheight {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 5px 0;
    line-height: 1.3;
}

.h4class.forLineheight {
    font-size: 16px;
    font-weight: 500;
    margin: 0 0 8px 0;
    line-height: 1.3;
    color: #666;
}

.h3class.forLineheight a,
.h4class.forLineheight a {
    color: #007bff;
    text-decoration: none;
}

.h3class.forLineheight a:hover,
.h4class.forLineheight a:hover {
    text-decoration: underline;
}

.contDescDiv {
    margin-bottom: 10px;
}

.contDescDiv p {
    margin: 0;
    line-height: 1.5;
    color: #333;
}

.icarolhref {
    color: #007bff;
    text-decoration: none;
    font-size: 14px;
}

.icarolhref:hover {
    text-decoration: underline;
}

.contDescDiv hr {
    border: 0;
    height: 1px;
    background-color: #e9ecef;
    margin: 10px 0;
}
