@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&display=swap');

:root {
    --primary-color: #0ea5e9;
    --primary-hover: #0284c7;
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #cbd5e1;
    --card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-gradient);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem 1rem;
    overflow-x: hidden;
}

header {
    position: relative;
    width: 100%;
    text-align: center;
    margin-bottom: 3rem;
    animation: fadeInDown 0.8s ease-out;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: -webkit-linear-gradient(45deg, #38bdf8, #818cf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.container {
    max-width: 95%;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Glassmorphism Card Style */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: var(--card-shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    animation: fadeInUp 0.8s ease-out;
}

.glass-panel:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.45);
}

/* Controls */
.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: flex-end;
}

.input-group {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 200px;
}

.input-group label {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.input-group input {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 0.8rem 1rem;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.3s ease;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.2);
}

button {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.8rem 2rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.2s ease;
    height: 47px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

button:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

button:active {
    transform: translateY(0);
}

/* Dashboard Stats */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.stat-card {
    text-align: center;
    padding: 1.5rem;
}

.stat-icon {
    font-size: 2rem;
    color: #38bdf8;
    margin-bottom: 1rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Chart Container */
.chart-container {
    position: relative;
    height: 400px;
    width: 100%;
}

/* Loader */
.loader-container {
    display: none;
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(4px);
    border-radius: 16px;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.loader {
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-left-color: var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

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

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

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

/* Buttons Group */
.buttons-group {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    flex: 1.2;
    min-width: 200px;
}

.buttons-group button {
    flex: 1;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08) !important;
    border: 1px solid var(--glass-border) !important;
    color: var(--text-main) !important;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
}

/* Table forecast layout */
.forecast-table-wrapper {
    overflow-x: auto;
    width: 100%;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: rgba(15, 23, 42, 0.4);
    margin-top: 1rem;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) rgba(0, 0, 0, 0.2);
}

/* Scrollbar styling for Webkit */
.forecast-table-wrapper::-webkit-scrollbar {
    height: 8px;
}
.forecast-table-wrapper::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
}
.forecast-table-wrapper::-webkit-scrollbar-thumb {
    background-color: var(--primary-color);
    border-radius: 12px;
    border: 2px solid rgba(0, 0, 0, 0.2);
}

.forecast-table {
    width: 100%;
    border-collapse: collapse;
    color: var(--text-main);
    font-size: 0.85rem;
    min-width: 1000px; /* Force scrollable columns */
}

.forecast-table th, .forecast-table td {
    padding: 0.6rem 0.4rem;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    vertical-align: middle;
}

.forecast-table th:not(.sticky-col), .forecast-table td:not(.sticky-col) {
    min-width: 65px;
}

.forecast-table td:last-child, .forecast-table th:last-child {
    border-right: none;
}

/* Sticky column styling */
.forecast-table .sticky-col {
    position: sticky;
    left: 0;
    background: #1e293b; /* Solid background to cover scroll */
    z-index: 5;
    font-weight: 600;
    text-align: left;
    padding-left: 1.2rem;
    padding-right: 1.2rem;
    border-right: 2px solid rgba(255, 255, 255, 0.15) !important;
    min-width: 130px;
    max-width: 130px;
    box-shadow: 4px 0 8px rgba(0, 0, 0, 0.3);
}

/* Specific sticky-col backgrounds for headers and sections */
.forecast-table thead th.sticky-col {
    background: #0f172a;
    z-index: 10;
}

.forecast-table tr.section-row td.sticky-col {
    background: #0f172a;
    z-index: 6;
    color: var(--text-main);
}

/* Day headers */
.forecast-table .day-title {
    background: rgba(255, 255, 255, 0.02);
    font-size: 0.95rem;
    font-weight: 700;
    color: #38bdf8;
    border-bottom: 2px solid var(--glass-border);
    padding: 0.75rem 0.5rem;
}

/* Time headers */
.forecast-table .time-title {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    background: rgba(0, 0, 0, 0.15);
    padding: 0.5rem;
}

/* Section rows (Wind / Waves labels) */
.forecast-table .section-row {
    background: rgba(15, 23, 42, 0.6);
}

.forecast-table .section-title {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text-main);
}

/* Visual Bars */
.bar-container {
    height: 75px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 4px;
}

.gust-bar {
    width: 22px;
    background-color: rgba(255, 255, 255, 0.15); /* Light grey for Gust */
    border-radius: 4px;
    display: flex;
    flex-direction: column-reverse;
    overflow: hidden;
    height: 0%; /* Set via JS */
}

.avg-bar {
    width: 100%;
    background-color: #0b2545; /* Dark navy blue for Average */
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    height: 0%; /* Set via JS */
}

/* Colors for specific values */
.forecast-table .blue-value {
    color: #38bdf8;
    font-weight: 700;
    font-size: 0.95rem;
}

.forecast-table .black-value {
    color: var(--text-main);
    font-weight: 600;
    font-size: 0.95rem;
}

.forecast-table .period-value {
    color: var(--text-main);
    font-weight: 600;
    font-size: 0.95rem;
}

/* Direction container */
.dir-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
}

.dir-arrow {
    display: inline-block;
    font-size: 1rem;
    color: #818cf8;
    line-height: 1;
}

.dir-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* Astro block styles */
.astro-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 0.5rem;
    text-align: left;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.astro-item {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
    padding-bottom: 3px;
}

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

.astro-item span:first-child {
    font-weight: 600;
}

.astro-item span:last-child {
    color: var(--text-main);
}

.moon-phase {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    font-weight: 600;
    color: #e2e8f0;
}

.moon-icon {
    font-size: 1.1rem;
    color: #f1f5f9;
}

.astro-day-header {
    font-size: 0.85rem;
    font-weight: 700;
    color: #38bdf8;
    text-align: center;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 4px;
}

/* Tide text styles */
.tide-text-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 0.5rem;
    text-align: left;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.tide-text-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
    padding-bottom: 3px;
}

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

.tide-text-item span:first-child {
    font-weight: 600;
}

.tide-high {
    color: #38bdf8;
}

.tide-low {
    color: #f43f5e;
}

/* Tide chart container */
.tide-chart-container {
    position: relative;
    height: 150px;
    width: 100%;
    padding: 0.5rem;
}

/* Responsive */
@media (max-width: 768px) {
    .controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .buttons-group {
        width: 100%;
    }
    
    button {
        width: 100%;
    }
}

/* City search and results styles */
.search-group {
    position: relative;
    flex: 1 1 100% !important;
}

.search-results-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #1e293b;
    border: 1px solid var(--glass-border);
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 220px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: var(--card-shadow);
}

.search-result-item {
    padding: 0.8rem 1rem;
    cursor: pointer;
    transition: background 0.2s ease;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.9rem;
    color: var(--text-main);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.search-result-item:hover {
    background: var(--primary-hover);
    color: white;
}

.search-result-item .details {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Language selector container and select box */
.lang-selector-container {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 1000;
}

@media (max-width: 768px) {
    .lang-selector-container {
        position: static;
        margin-bottom: 1.5rem;
        display: flex;
        justify-content: center;
        width: 100%;
    }
}

.lang-select {
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 0.5rem 0.8rem;
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.lang-select:hover {
    border-color: var(--primary-color);
    background: rgba(15, 23, 42, 0.8);
}

.lang-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.2);
}

.lang-select option {
    background: #1e293b;
    color: var(--text-main);
}
