/**
 * Morocco Dam Water Statistics Styles
 * Complete rebuild - Simple and reliable water fill animation
 */

/* Main container for dams with search */
.morocco-dams-container {
    width: 100%;
    margin: 0px 0;
}

/* Weather Alarm Section - Minimalistic RTL Design */
.morocco-weather-alarm-section {
    margin: 0 auto 20px;
    max-width: 100%;
    direction: rtl;
}

.morocco-weather-alarm-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: #fff3cd;
    border-right: 4px solid #f59e0b;
    border-radius: 4px;
    text-decoration: none;
    color: #78350f;
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1.5;
    transition: all 0.2s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Arabic UI Text', 'Noto Sans Arabic', Roboto, sans-serif;
    direction: rtl;
    text-align: right;
}

.morocco-weather-alarm-link:hover {
    background: #fef3c7;
    color: #451a03;
    text-decoration: none;
    border-right-color: #d97706;
}

.morocco-weather-alarm-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
    line-height: 1;
}

.morocco-weather-alarm-text {
    flex: 1;
}

/* Responsive adjustments for weather alarm */
@media (max-width: 768px) {
    .morocco-weather-alarm-link {
        font-size: 0.9rem;
        padding: 10px 14px;
        gap: 8px;
    }
    
    .morocco-weather-alarm-icon {
        font-size: 1.1rem;
    }
}

@media (max-width: 480px) {
    .morocco-weather-alarm-section {
        margin-bottom: 15px;
    }
    
    .morocco-weather-alarm-link {
        font-size: 0.85rem;
        padding: 8px 12px;
        gap: 6px;
        line-height: 1.4;
    }
    
    .morocco-weather-alarm-icon {
        font-size: 1rem;
    }
}

/* SEO Meta Section - Minimalist Design */
.morocco-dams-seo-meta {
    max-width: 100%;
    margin: 0 auto 20px;
    padding: 0;
    direction: rtl;
    text-align: right;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Arabic UI Text', 'Noto Sans Arabic', Roboto, sans-serif;
    color: #64748b;
    font-size: 0.875rem;
    line-height: 1.6;
}

/* SEO Tooltip Wrapper */
.morocco-dams-seo-tooltip-wrapper {
    position: relative;
    display: inline-block;
    margin: 0 auto 20px;
    text-align: center;
    width: 100%;
}

.morocco-dams-seo-tooltip-trigger {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    font-size: 1.25rem;
    line-height: 1;
    width: 32px;
    height: 32px;
}

.morocco-dams-seo-tooltip-trigger:hover {
    background: #f1f5f9;
    color: #3b82f6;
    transform: scale(1.1);
}

.morocco-dams-seo-tooltip-trigger:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.morocco-dams-seo-tooltip-icon {
    display: block;
    font-size: 1.25rem;
    line-height: 1;
}

/* Tooltip SEO Meta - Hidden by default, shown on hover */
.morocco-dams-seo-meta.seo-tooltip {
    position: absolute;
    top: 100%;
    right: 50%;
    transform: translateX(50%);
    margin-top: 8px;
    min-width: 280px;
    max-width: 400px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
    transform: translateX(50%) translateY(-4px);
}

/* Ensure tooltip content is visible and styled */
.morocco-dams-seo-meta.seo-tooltip .morocco-dams-intro,
.morocco-dams-seo-meta.seo-tooltip .morocco-dams-last-updated {
    margin: 0;
    padding: 0;
}

.morocco-dams-seo-meta.seo-tooltip .morocco-dams-intro {
    margin-bottom: 8px;
}

.morocco-dams-seo-tooltip-wrapper:hover .morocco-dams-seo-meta.seo-tooltip,
.morocco-dams-seo-tooltip-wrapper:focus-within .morocco-dams-seo-meta.seo-tooltip {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(50%) translateY(0);
}

/* Tooltip arrow */
.morocco-dams-seo-meta.seo-tooltip::before {
    content: '';
    position: absolute;
    bottom: 100%;
    right: 50%;
    transform: translateX(50%);
    border: 6px solid transparent;
    border-bottom-color: #e2e8f0;
    margin-bottom: -1px;
}

.morocco-dams-seo-meta.seo-tooltip::after {
    content: '';
    position: absolute;
    bottom: 100%;
    right: 50%;
    transform: translateX(50%);
    border: 5px solid transparent;
    border-bottom-color: #ffffff;
}

/* Hide SEO meta visually but keep it accessible to search engines (fallback for non-tooltip mode) */
.morocco-dams-seo-meta.seo-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.morocco-dams-intro {
    margin: 0 0 8px 0;
    padding: 0;
    color: #64748b;
    font-size: 0.875rem;
}

.morocco-dams-source {
    display: inline-block;
    margin-right: 8px;
    color: #94a3b8;
    font-size: 0.8125rem;
}

.morocco-dams-source a {
    color: #3b82f6;
    text-decoration: none;
    transition: color 0.2s ease;
}

.morocco-dams-source a:hover {
    color: #2563eb;
    text-decoration: underline;
}

.morocco-dams-last-updated {
    margin: 0;
    padding: 0;
    color: #94a3b8;
    font-size: 0.8125rem;
    font-weight: 400;
}

.morocco-dams-last-updated strong {
    font-weight: 500;
    color: #64748b;
    margin-left: 6px;
}

.morocco-dams-last-updated span {
    color: #94a3b8;
}

.morocco-dams-last-updated-sep {
    margin: 0 6px;
    color: #cbd5e1;
}

/* Responsive adjustments for SEO meta */
@media (max-width: 768px) {
    .morocco-dams-seo-meta {
        font-size: 0.8125rem;
        margin-bottom: 16px;
    }
    
    .morocco-dams-intro {
        font-size: 0.8125rem;
    }
    
    .morocco-dams-source,
    .morocco-dams-last-updated {
        font-size: 0.75rem;
    }
    
    /* Tooltip responsive adjustments */
    .morocco-dams-seo-meta.seo-tooltip {
        min-width: 240px;
        max-width: calc(100vw - 40px);
        right: 50%;
        transform: translateX(50%);
    }
    
    .morocco-dams-seo-tooltip-trigger {
        width: 36px;
        height: 36px;
        font-size: 1.1rem;
    }
}

@media (max-width: 480px) {
    .morocco-dams-seo-meta.seo-tooltip {
        min-width: 200px;
        padding: 10px 12px;
        font-size: 0.75rem;
    }
    
    .morocco-dams-seo-tooltip-trigger {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }
}

/* Weather City Dropdown Styles */
.morocco-weather-city-wrapper {
    max-width: 400px;
    margin: 0 auto 20px;
}

.morocco-weather-city-select {
    width: 100%;
    padding: 14px 20px;
    font-size: 16px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Arabic UI Text', 'Noto Sans Arabic', Roboto, sans-serif;
    color: #1e293b;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 18px center;
    background-size: 12px;
    padding-right: 45px;
    direction: rtl;
}

.morocco-weather-city-select:hover {
    border-color: #cbd5e1;
}

.morocco-weather-city-select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 2px 12px rgba(59, 130, 246, 0.2);
}

.morocco-weather-city-select option {
    padding: 10px;
    font-size: 16px;
    direction: rtl;
}

/* Dropdown Select Styles */
.morocco-dams-select-wrapper {
    max-width: 400px;
    margin: 0 auto;
}

.morocco-dams-select {
    width: 100%;
    padding: 14px 20px;
    font-size: 16px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #1e293b;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 18px center;
    background-size: 12px;
    padding-right: 45px;
}

.morocco-dams-select:hover {
    border-color: #cbd5e1;
}

.morocco-dams-select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 2px 12px rgba(59, 130, 246, 0.2);
}

.morocco-dams-select option {
    padding: 10px;
    font-size: 16px;
}

/* Hidden state for filtered out dams */
.dam-widget-wrapper.hidden {
    display: none !important;
}

/* Hidden state for total statistics wrapper */
.morocco-dams-total-wrapper.hidden {
    display: none !important;
}

/* Dams Grid Title Wrapper (integrated with select) */
.morocco-dams-grid-title-wrapper {
    margin: 5px auto 5px;
    padding: 7px;
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border: 2px solid #e2e8f0;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    max-width: 800px;
    text-align: center;
    direction: rtl;
}

.morocco-dams-grid-title {
    font-size: 26px;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 20px 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Arabic UI Text', 'Noto Sans Arabic', Roboto, sans-serif;
    line-height: 1.4;
    letter-spacing: -0.02em;
}

.morocco-dams-grid-title-wrapper .morocco-dams-select-wrapper {
    max-width: 100%;
    margin: 0;
}

/* Grid container for multiple dams */
.morocco-dams-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin: 0;
    padding: 0;
}

.morocco-dams-grid[data-columns="1"] {
    grid-template-columns: 1fr;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.morocco-dams-grid[data-columns="2"] {
    grid-template-columns: repeat(2, 1fr);
}

.morocco-dams-grid[data-columns="3"] {
    grid-template-columns: repeat(3, 1fr);
}

.morocco-dams-grid[data-columns="4"] {
    grid-template-columns: repeat(4, 1fr);
}

/* Responsive grid adjustments */
@media (max-width: 1200px) {
    .morocco-dams-grid[data-columns="4"] {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 900px) {
    .morocco-dams-grid[data-columns="3"],
    .morocco-dams-grid[data-columns="4"] {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .morocco-dams-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Dam widget wrapper for sequential loading */
.dam-widget-wrapper {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.dam-widget-wrapper.loaded {
    opacity: 1;
    transform: translateY(0);
}

/* Main container */
.morocco-dam-water-stats {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border-radius: 20px;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.1);
    margin: 0;
    max-width: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    width: 100%;
}

/* Size variations */
.morocco-dam-water-stats.dam-water-small {
    max-width: 250px;
    padding: 16px;
}

.morocco-dam-water-stats.dam-water-small .dam-water-progress-container {
    width: 150px;
    height: 150px;
}

.morocco-dam-water-stats.dam-water-small .dam-water-percentage-value {
    font-size: 2rem;
}

.morocco-dam-water-stats.dam-water-medium {
    max-width: 320px;
    padding: 20px;
    margin-left: auto;
    margin-right: auto;
}

.morocco-dam-water-stats.dam-water-medium.high-water.initialized {
    margin-left: auto;
    margin-right: auto;
}

.morocco-dam-water-stats.dam-water-medium .dam-water-progress-container {
    width: 200px;
    height: 200px;
    margin-left: auto;
    margin-right: auto;
}

.morocco-dam-water-stats.dam-water-medium .dam-water-percentage-value {
    font-size: 2.5rem;
}

.morocco-dam-water-stats.dam-water-large {
    max-width: 400px;
    padding: 24px;
}

/* Progress container */
.dam-water-progress-container {
    position: relative;
    width: 280px;
    height: 280px;
    margin: 0 auto 20px;
    border-radius: 50%;
}

/* Water container - circular mask */
.dam-water-container {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    bottom: 10px;
    border-radius: 50%;
    overflow: hidden;
    background: #ffffff;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Water fill - grows from bottom */
.dam-water-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%; /* Start at 0% - will be animated to percentage */
    background: #3b82f6;
    transition: height 3.5s cubic-bezier(0.4, 0, 0.2, 1);
    /* CSS variable set by PHP inline style sets initial state */
    /* JavaScript will animate to this value when element enters viewport */
}

/* Wave effect on water surface - positioned at top of fill */
.dam-water-wave {
    position: absolute;
    top: 0; /* At the water surface (top of fill) */
    left: 0;
    width: 100%;
    height: 30px; /* Wave height */
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.4) 0%,
        rgba(255, 255, 255, 0.1) 50%,
        transparent 100%
    );
    animation: wave-animation 3s ease-in-out infinite;
    pointer-events: none;
    border-radius: 50% 50% 0 0; /* Rounded top for wave effect */
}

@keyframes wave-animation {
    0%, 100% {
        transform: translateX(0) translateY(0);
    }
    50% {
        transform: translateX(-10px) translateY(-5px);
    }
}

/* Border ring */
.dam-water-border-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 10px solid #ffffff;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    z-index: 2;
    pointer-events: none;
}

/* Percentage text */
.dam-water-percentage-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: baseline;
    justify-content: center;
    font-weight: 700;
    color: #1e293b;
    z-index: 10;
    text-shadow: 0 2px 4px rgba(255, 255, 255, 0.8);
}

/* High water - white text for contrast */
.morocco-dam-water-stats.high-water .dam-water-percentage-text {
    color: #ffffff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.dam-water-percentage-value {
    font-size: 3.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.dam-water-percentage-symbol {
    font-size: 2rem;
    font-weight: 600;
    margin-left: 2px;
}

/* Dam name */
.dam-water-name {
    text-align: center;
    font-size: 1.25rem;
    font-weight: 600;
    color: #1e40af;
    line-height: 1.5;
    margin-top: 16px;
    padding: 0 10px;
    direction: rtl;
}

/* Capacity info */
.dam-water-capacity {
    margin-top: 8px;
    font-size: 0.875rem;
    color: #64748b;
    text-align: center;
}

/* Error message */
.dam-water-error {
    color: #dc2626;
    padding: 10px;
    background: #fee2e2;
    border-radius: 4px;
    text-align: center;
}

/* Total Statistics Widget Wrapper */
.morocco-dams-total-wrapper {
    margin: 20px auto;
    max-width: 600px;
    padding: 20px;
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border: 3px solid #3b82f6;
    border-radius: 24px;
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.15);
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Prominent Total Statistics Widget */
.dam-water-total-prominent {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.dam-water-total-prominent .dam-water-progress-container {
    width: 300px;
    height: 300px;
    margin: 0 auto;
}

.dam-water-total-prominent .dam-water-border-ring {
    border-width: 10px;
    border-color: #3b82f6;
}

.dam-water-total-prominent .dam-water-percentage-text {
    font-size: 5rem;
    font-weight: 800;
    color: #1e40af;
}

.dam-water-total-prominent .dam-water-percentage-value {
    font-size: 5rem;
    font-weight: 800;
    color: #1e40af;
}

.dam-water-total-prominent .dam-water-percentage-symbol {
    font-size: 3rem;
    font-weight: 700;
}

.dam-water-total-prominent .dam-water-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e40af;
    margin-top: 20px;
    text-align: center;
    line-height: 1.4;
    direction: rtl;
}

.dam-water-total-prominent .dam-water-capacity {
    font-size: 1.3rem;
    color: #1e293b;
    font-weight: 600;
    margin-top: 15px;
    text-align: center;
}

/* Responsive adjustments for prominent widget */
@media (max-width: 768px) {
    .morocco-dams-total-wrapper {
        padding: 15px;
        margin: 15px auto;
    }
    
    .dam-water-total-prominent .dam-water-progress-container {
        width: 250px;
        height: 250px;
    }
    
    .dam-water-total-prominent .dam-water-percentage-value {
        font-size: 4rem;
    }
    
    .dam-water-total-prominent .dam-water-percentage-symbol {
        font-size: 2.5rem;
    }
    
    .dam-water-total-prominent .dam-water-name {
        font-size: 1.25rem;
    }
    
    .dam-water-total-prominent .dam-water-capacity {
        font-size: 1.1rem;
    }
}

@media (max-width: 480px) {
    .morocco-dams-total-wrapper {
        padding: 12px;
        margin: 12px auto;
        border-width: 2px;
    }
    
    .dam-water-total-prominent .dam-water-progress-container {
        width: 220px;
        height: 220px;
    }
    
    .dam-water-total-prominent .dam-water-percentage-value {
        font-size: 3.5rem;
    }
    
    .dam-water-total-prominent .dam-water-percentage-symbol {
        font-size: 2rem;
    }
    
    .dam-water-total-prominent .dam-water-name {
        font-size: 1.1rem;
        margin-top: 15px;
    }
    
    .dam-water-total-prominent .dam-water-capacity {
        font-size: 1rem;
        margin-top: 12px;
    }
    
    .dam-water-total-prominent .dam-water-border-ring {
        border-width: 8px;
    }
}

/* Color variations based on level */
.morocco-dam-water-stats[data-level="low"] .dam-water-fill {
    background: #f59e0b;
}

.morocco-dam-water-stats[data-level="critical"] .dam-water-fill {
    background: #ef4444;
}

/* Responsive */
@media (max-width: 768px) {
    .dam-water-progress-container {
        width: 240px;
        height: 240px;
    }
    .dam-water-percentage-value {
        font-size: 3rem;
    }
}

@media (max-width: 480px) {
    .dam-water-progress-container {
        width: 200px;
        height: 200px;
    }
    .dam-water-percentage-value {
        font-size: 2.5rem;
    }
    .dam-water-border-ring {
        border-width: 8px;
    }
}
