/**
 * Transhydro Weather - Clean Modern Design v8
 */

/* Container - Clean white design */
.thw-weather-container {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    background: #f5f7fa;
    border-radius: 16px;
    box-sizing: border-box;
}

.thw-weather-container *,
.thw-weather-container *::before,
.thw-weather-container *::after {
    box-sizing: border-box;
}

/* Header */
.thw-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.thw-title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: #333;
}

.thw-current-time {
    font-size: 0.9rem;
    color: #666;
}

/* Search Box - Fixed overflow */
.thw-search-box {
    margin-bottom: 25px;
    display: flex;
    gap: 10px;
    position: relative;
    background: white;
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.thw-search-input {
    flex: 1;
    min-width: 0;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
    background: #f9f9f9;
}

.thw-search-input:focus {
    border-color: #2196F3;
    background: white;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.thw-search-btn {
    padding: 12px 20px;
    background: #2196F3;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.3s;
    flex-shrink: 0;
}

.thw-search-btn:hover {
    background: #1976D2;
}

.thw-gps-btn {
    padding: 12px 16px;
    background: #f5f5f5;
    color: #333;
    border: 1px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.3s;
    flex-shrink: 0;
}

.thw-gps-btn:hover {
    background: #e8e8e8;
    border-color: #2196F3;
}

.thw-search-results {
    position: absolute;
    top: calc(100% - 5px);
    left: 15px;
    right: 15px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    z-index: 100;
    display: none;
    max-height: 300px;
    overflow-y: auto;
}

.thw-search-results.active {
    display: block;
}

.thw-search-result-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    transition: background 0.2s;
    color: #333;
}

.thw-search-result-item:hover {
    background: #f5f5f5;
}

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

/* Section */
.thw-section {
    margin-bottom: 30px;
}

.thw-section-title {
    color: #333;
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0 0 15px 0;
    padding: 10px 15px;
    background: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.thw-section-icon {
    font-size: 1.3rem;
}

/* Cards Grid */
.thw-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
    gap: 20px;
}

/* Card */
.thw-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
}

.thw-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.12);
}

/* Card Header */
.thw-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 18px;
    background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%);
    color: white;
}

.thw-card[data-location-type="resort"] .thw-card-header {
    background: linear-gradient(135deg, #00BCD4 0%, #0097A7 100%);
}

.thw-card[data-location-type="peak"] .thw-card-header {
    background: linear-gradient(135deg, #607D8B 0%, #455A64 100%);
}

.thw-card-title {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.thw-location-name {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.thw-elevation {
    font-size: 0.8rem;
    opacity: 0.85;
}

.thw-current-weather {
    display: flex;
    align-items: center;
    gap: 8px;
}

.thw-current-icon {
    font-size: 2rem;
}

.thw-current-temp {
    font-size: 1.6rem;
    font-weight: 700;
}

.thw-sea-temp {
    font-size: 0.9rem;
    background: rgba(255,255,255,0.2);
    padding: 3px 8px;
    border-radius: 12px;
}

/* Card Table */
.thw-card-table-wrapper {
    overflow-x: auto;
}

.thw-card-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.thw-card-table th,
.thw-card-table td {
    padding: 7px 5px;
    text-align: center;
    border-bottom: 1px solid #f0f0f0;
}

.thw-card-table thead th {
    background: #f8f9fa;
    font-weight: 600;
    color: #555;
}

.thw-day-header {
    background: #e3f2fd !important;
    color: #1565C0 !important;
    font-size: 0.85rem;
    font-weight: 700 !important;
}

.thw-period-col {
    font-size: 0.7rem;
    min-width: 48px;
    line-height: 1.2;
}

.thw-period-col small {
    display: block;
    font-size: 0.6rem;
    color: #888;
    font-weight: normal;
}

.thw-param-label {
    text-align: left !important;
    font-weight: 600;
    padding-left: 10px !important;
    width: 32px;
    background: #fafafa;
    font-size: 1rem;
}

.thw-param-col {
    width: 32px;
}

/* Data cells */
.thw-data-cell {
    font-weight: 500;
    color: #333;
    font-size: 0.8rem;
}

.thw-temp-row .thw-data-cell {
    background: #fffde7;
}

.thw-cell-icon {
    display: block;
    font-size: 1rem;
    line-height: 1;
    margin-bottom: 2px;
}

.thw-cell-temp {
    font-weight: 700;
    color: #e65100;
    font-size: 0.9rem;
}

.thw-has-precip {
    background: #e3f2fd !important;
    color: #1565C0;
    font-weight: 600;
}

.thw-strong-wind {
    background: #ffebee !important;
    color: #c62828;
    font-weight: 600;
}

.thw-sea-cell {
    background: #e0f7fa !important;
    color: #00838f;
}

.thw-snow-cell {
    background: #e8eaf6 !important;
    color: #3949ab;
}

.thw-no-data {
    color: #bbb;
}

.thw-past-period {
    opacity: 0.4;
    background: #f5f5f5 !important;
}

/* Wind direction arrow */
.thw-wind-arrow {
    font-size: 1.1rem;
    display: inline-block;
}

/* Footer */
.thw-footer {
    margin-top: 25px;
    padding: 15px;
    background: white;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.thw-footer-note {
    margin: 0 0 10px 0;
    font-size: 0.95rem;
    color: #333;
}

.thw-footer-legend {
    margin: 0;
    font-size: 0.75rem;
    color: #666;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
}

/* Modal */
.thw-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.thw-modal.active {
    display: flex;
}

.thw-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
}

.thw-modal-content {
    position: relative;
    background: white;
    border-radius: 12px;
    max-width: 95%;
    width: 650px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    animation: modalSlideIn 0.3s ease;
}

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

.thw-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    background: #2196F3;
    color: white;
}

.thw-modal-title {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
}

.thw-modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.thw-modal-close:hover {
    opacity: 1;
}

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

.thw-loading {
    text-align: center;
    padding: 40px;
    color: #666;
    font-size: 1.1rem;
}

.thw-error {
    text-align: center;
    padding: 20px;
    color: #c62828;
    background: #ffebee;
    border-radius: 8px;
    margin: 10px 0;
}

/* 15-day forecast table - Improved mobile layout */
.thw-forecast-15 {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.thw-forecast-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    min-width: 420px;
}

.thw-forecast-table th,
.thw-forecast-table td {
    padding: 8px 4px;
    text-align: center;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
}

.thw-forecast-table th {
    background: #f5f5f5;
    font-weight: 600;
    color: #555;
    font-size: 0.75rem;
    position: sticky;
    top: 0;
}

.thw-forecast-table th:first-child,
.thw-forecast-table td:first-child {
    text-align: left;
    padding-left: 8px;
}

.thw-forecast-table tbody tr:hover {
    background: #f0f7ff;
}

.thw-forecast-table tbody tr:nth-child(even) {
    background: #fafafa;
}

/* Date cell */
.thw-date-cell {
    white-space: nowrap;
    min-width: 50px;
}

.thw-date-num {
    font-weight: 600;
    color: #333;
    display: block;
    font-size: 0.85rem;
}

.thw-date-day {
    font-size: 0.65rem;
    color: #888;
    font-weight: normal;
}

/* Icon cell */
.thw-icon-cell {
    font-size: 1.1rem;
    width: 30px;
}

/* Temperature cell */
.thw-temp-cell {
    white-space: nowrap;
    min-width: 55px;
}

.thw-temp-min {
    color: #1976D2;
    font-weight: 600;
}

.thw-temp-sep {
    color: #999;
    margin: 0 1px;
}

.thw-temp-max {
    color: #e65100;
    font-weight: 600;
}

/* Precipitation cell */
.thw-precip-cell {
    min-width: 35px;
}

/* Wind cell */
.thw-wind-cell {
    white-space: nowrap;
    min-width: 40px;
}

.thw-wind-speed {
    font-weight: 500;
}

.thw-forecast-wind-arrow {
    font-size: 1rem;
    display: block;
    margin-top: 2px;
}

/* Gust cell */
.thw-gust-cell {
    min-width: 30px;
}

/* Snow cell */
.thw-snow-cell-15 {
    min-width: 35px;
    color: #3949ab;
}

/* PV cell */
.thw-forecast-table .thw-pv-cell {
    font-weight: 600;
    color: #f57c00;
    min-width: 40px;
}

/* Forecast note */
.thw-forecast-note {
    margin-top: 12px;
    text-align: center;
    color: #666;
    font-size: 0.8rem;
}

/* Nearest location container */
.thw-nearest-container {
    margin-bottom: 20px;
}

.thw-nearest-info {
    padding: 15px 20px;
    background: white;
    border-radius: 8px;
    font-size: 1rem;
    color: #333;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    margin-bottom: 15px;
}

.thw-nearest-icon {
    font-size: 1.2rem;
}

.thw-loading-gps {
    padding: 30px;
    text-align: center;
    color: #666;
    background: white;
    border-radius: 8px;
}

/* Responsive */
@media (max-width: 900px) {
    .thw-cards-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .thw-weather-container {
        padding: 10px;
        border-radius: 0;
    }
    
    .thw-header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
        padding: 12px 15px;
    }
    
    .thw-title {
        font-size: 1.2rem;
    }
    
    .thw-search-box {
        flex-wrap: wrap;
        padding: 12px;
    }
    
    .thw-search-input {
        flex: 1 1 100%;
        min-width: 0;
        margin-bottom: 8px;
    }
    
    .thw-search-btn {
        flex: 1;
    }
    
    .thw-gps-btn {
        flex: 0 0 auto;
    }
    
    .thw-card-table {
        font-size: 0.65rem;
    }
    
    .thw-card-table th,
    .thw-card-table td {
        padding: 4px 2px;
    }
    
    .thw-period-col {
        min-width: 35px;
        font-size: 0.55rem;
    }
    
    .thw-period-col small {
        font-size: 0.5rem;
    }
    
    .thw-param-label {
        font-size: 0.8rem;
        padding-left: 5px !important;
    }
    
    .thw-modal-content {
        width: 100%;
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .thw-modal-body {
        max-height: calc(100vh - 70px);
        padding: 10px;
    }
    
    /* 15-day forecast mobile */
    .thw-forecast-table {
        font-size: 0.75rem;
        min-width: 380px;
    }
    
    .thw-forecast-table th,
    .thw-forecast-table td {
        padding: 6px 3px;
    }
    
    .thw-forecast-table th {
        font-size: 0.7rem;
    }
    
    .thw-date-num {
        font-size: 0.8rem;
    }
    
    .thw-date-day {
        font-size: 0.6rem;
    }
    
    .thw-icon-cell {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .thw-search-box {
        flex-direction: column;
        gap: 8px;
    }
    
    .thw-search-input {
        width: 100%;
        margin-bottom: 0;
    }
    
    .thw-search-btn,
    .thw-gps-btn {
        width: 100%;
    }
    
    /* 15-day forecast very small screens */
    .thw-forecast-table {
        font-size: 0.7rem;
        min-width: 350px;
    }
    
    .thw-forecast-table th,
    .thw-forecast-table td {
        padding: 5px 2px;
    }
    
    .thw-date-cell {
        min-width: 42px;
    }
    
    .thw-temp-cell {
        min-width: 48px;
    }
}
