/* Namespace all styles with .sww- (Santanu Weather Widget) prefix to avoid conflicts */

/* Base Container - Mobile First */
.sww-weather-widget-card {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
    max-width: 360px;
    margin: 20px auto;
    padding: 0.75rem;
    background-color: #ffffff;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    position: relative;
    box-sizing: border-box;
}

.sww-weather-widget-card * {
    box-sizing: border-box;
}

/* Header with buttons */
.sww-weather-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.sww-location-display {
    flex: 1;
    background: #f5f5f5;
    padding: 0.6rem 0.8rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #2c3e50;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sww-header-buttons {
    display: flex;
    gap: 0.4rem;
}

.sww-search-btn,
.sww-refresh-btn {
    border: none;
    border-radius: 8px;
    padding: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}

.sww-search-btn {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.3);
}

.sww-search-btn:hover {
    background: linear-gradient(135deg, #2980b9 0%, #21618c 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.4);
}

.sww-refresh-btn {
    background: linear-gradient(135deg, #27ae60 0%, #229954 100%);
    box-shadow: 0 2px 8px rgba(39, 174, 96, 0.3);
}

.sww-refresh-btn:hover {
    background: linear-gradient(135deg, #229954 0%, #1e8449 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(39, 174, 96, 0.4);
}

.sww-refresh-btn:active {
    animation: sww-spin 0.6s ease-in-out;
}

.sww-search-btn svg,
.sww-refresh-btn svg {
    display: block;
    stroke: white;
    stroke-width: 2.5;
}

/* Main Content Container */
.sww-weather-content {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Current Weather Section */
.sww-current-section {
    display: flex;
    flex-direction: row;
    gap: 0.75rem;
    background: #f9fafb;
    border-radius: 12px;
    padding: 0.75rem;
}

.sww-current-left {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
}

.sww-weather-icon-box {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #e8f4f8 0%, #d4e9f2 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sww-weather-icon-box img {
    width: 64px;
    height: 64px;
    display: block;
}

.sww-weather-stats {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    width: 100%;
}

.sww-weather-stats p {
    margin: 0;
    font-size: 0.75rem;
    color: #566573;
    line-height: 1.4;
}

/* Current Weather Details (Right side) */
.sww-current-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.sww-current-details h2 {
    font-size: 1rem;
    font-weight: 700;
    color: #2c3e50;
    margin: 0 0 0.3rem 0;
    line-height: 1.2;
}

.sww-current-temp {
    font-size: 2.2rem;
    font-weight: 700;
    color: #17202a;
    margin: 0.2rem 0;
    line-height: 1;
}

.sww-feels-like {
    font-size: 0.8rem;
    color: #7f8c8d;
    margin: 0.2rem 0 0.4rem 0;
}

.sww-condition-text {
    font-size: 0.85rem;
    color: #566573;
    font-weight: 500;
    margin: 0 0 0.4rem 0;
}

.sww-temp-minmax {
    display: flex;
    gap: 0.8rem;
    font-size: 0.8rem;
    color: #566573;
    margin: 0.4rem 0;
}

.sww-temp-minmax span {
    display: inline-block;
}

.sww-detail-item {
    font-size: 0.78rem;
    color: #566573;
    margin: 0.15rem 0;
    line-height: 1.4;
}

.sww-last-updated {
    font-size: 0.7rem;
    color: #95a5a6;
    margin-top: 0.3rem;
    font-style: italic;
}

.sww-default-badge {
    font-size: 0.7rem;
    color: #95a5a6;
    font-weight: 400;
}

/* Forecast Section */
.sww-forecast-section {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
}

.sww-forecast-card {
    background: #f9fafb;
    border-radius: 10px;
    padding: 0.7rem 0.5rem;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.06);
    transition: transform 0.2s ease-out, box-shadow 0.2s ease-out;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.sww-forecast-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.sww-forecast-card h4 {
    font-size: 0.75rem;
    font-weight: 600;
    color: #34495e;
    margin: 0 0 0.4rem 0;
    line-height: 1.2;
    width: 100%;
    text-align: center;
}

.sww-forecast-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 0.3rem;
    display: block;
}

.sww-forecast-condition {
    font-size: 0.72rem;
    color: #627d98;
    margin: 0.2rem 0;
    line-height: 1.3;
    width: 100%;
    text-align: center;
}

.sww-forecast-minmax {
    display: flex;
    gap: 0.6rem;
    justify-content: center;
    font-size: 0.7rem;
    color: #627d98;
    margin: 0.2rem 0;
    width: 100%;
}

.sww-forecast-minmax span {
    display: inline-block;
}

.sww-forecast-temp,
.sww-forecast-humidity {
    font-size: 0.7rem;
    color: #627d98;
    margin: 0.15rem 0;
    line-height: 1.3;
    width: 100%;
    text-align: center;
}

/* Loading State */
.sww-loading-container {
    text-align: center;
    padding: 2rem 1rem;
}

.sww-spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: sww-spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

.sww-loading-container p {
    color: #7f8c8d;
    font-size: 0.9rem;
    margin: 0;
}

/* Error State */
.sww-error {
    text-align: center;
    padding: 2rem 1rem;
}

.sww-error p {
    color: #e74c3c;
    font-size: 0.9rem;
    margin: 0 0 1rem 0;
}

.sww-retry-btn {
    background: #3498db;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s ease;
}

.sww-retry-btn:hover {
    background: #2980b9;
}

/* Modal Styles */
.sww-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    padding: 1rem;
}

.sww-modal-content {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.sww-modal-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sww-modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #2c3e50;
}

.sww-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #7f8c8d;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.sww-modal-close:hover {
    color: #2c3e50;
}

.sww-modal-body {
    padding: 1.5rem;
}

.sww-search-input {
    width: 100%;
    padding: 0.8rem;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 0.95rem;
    margin-bottom: 1rem;
    transition: border-color 0.2s ease;
}

.sww-search-input:focus {
    outline: none;
    border-color: #3498db;
}

.sww-search-results {
    max-height: 250px;
    overflow-y: auto;
    margin-bottom: 1rem;
}

.sww-search-result-item {
    padding: 0.8rem;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s ease;
    font-size: 0.9rem;
}

.sww-search-result-item:hover {
    background: #f0f0f0;
}

.sww-search-result-item strong {
    color: #2c3e50;
}

.sww-searching,
.sww-no-results {
    text-align: center;
    color: #7f8c8d;
    padding: 1rem;
    font-size: 0.9rem;
}

.sww-use-current-location {
    width: 100%;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.8rem;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s ease;
}

.sww-use-current-location:hover {
    background: #2980b9;
}

/* Typography Reset */
.sww-weather-widget-card p,
.sww-weather-widget-card h2,
.sww-weather-widget-card h3,
.sww-weather-widget-card h4 {
    line-height: 1.45;
}

.sww-weather-widget-card p strong {
    font-weight: 600;
    color: #333;
}

/* Tablet/Desktop Responsive - Landscape Layout */
@media only screen and (min-width: 768px) {
    .sww-weather-widget-card {
        max-width: 900px;
        padding: 1rem;
    }

    .sww-weather-content {
        flex-direction: row;
        gap: 1rem;
    }

    /* Current weather section - left side */
    .sww-current-section {
        flex: 0 0 340px;
        min-height: 200px;
    }

    /* Forecast section - right side, side by side */
    .sww-forecast-section {
        flex: 1;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.8rem;
        align-content: stretch;
    }

    .sww-forecast-card {
        padding: 0.9rem 0.7rem;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        min-height: 200px;
    }

    .sww-current-details h2 {
        font-size: 1.1rem;
    }

    .sww-current-temp {
        font-size: 2.5rem;
    }

    .sww-forecast-icon {
        width: 56px;
        height: 56px;
    }

    /* Make weather icon and stats side by side on desktop */
    .sww-current-left {
        flex-direction: column;
        gap: 0.6rem;
        align-items: flex-start;
    }

    .sww-weather-icon-box {
        width: 90px;
        height: 90px;
    }

    .sww-weather-icon-box img {
        width: 72px;
        height: 72px;
    }

    .sww-weather-stats {
        width: 100%;
    }
}

/* Larger Desktop */
@media (min-width: 1025px) {
    .sww-weather-widget-card {
        max-width: 1000px;
    }

    .sww-current-section {
        flex: 0 0 360px;
    }

    .sww-weather-icon-box {
        width: 100px;
        height: 100px;
    }

    .sww-weather-icon-box img {
        width: 80px;
        height: 80px;
    }

    .sww-current-temp {
        font-size: 2.8rem;
    }

    .sww-forecast-card {
        padding: 1rem 0.8rem;
    }

    .sww-forecast-icon {
        width: 64px;
        height: 64px;
    }
}

/* Print Styles */
@media print {
    .sww-weather-header,
    .sww-modal {
        display: none !important;
    }
}