/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    transition: background 0.3s ease, color 0.3s ease;
}

body.dark-mode {
    color: #e5e7eb;
    background: linear-gradient(135deg, #1e3a8a 0%, #3b0764 100%);
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    backdrop-filter: blur(10px);
    transition: background 0.3s ease, color 0.3s ease;
}

body.dark-mode .container {
    background: #1f2937;
}

/* Header */
header {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    text-align: center;
    padding: 40px 30px;
    position: relative;
    overflow: hidden;
}

body.dark-mode header {
    background: linear-gradient(135deg, #2563eb 0%, #0ea5e9 100%);
}

header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.1'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E") repeat;
    opacity: 0.1;
}

header h1 {
    font-size: 2.8rem;
    font-weight: 700;
    margin-bottom: 10px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    position: relative;
    z-index: 1;
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
    position: relative;
    z-index: 1;
}

/* Theme toggle */
.theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 2;
}

.theme-toggle-label {
    display: inline-block;
    width: 60px;
    height: 34px;
    position: relative;
}

.theme-switch {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "🌞";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.4s;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.theme-switch:checked + .slider {
    background-color: #4facfe;
}

.theme-switch:checked + .slider:before {
    content: "🌙";
    transform: translateX(26px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Form styles */
.form-section {
    padding: 40px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.form-group {
    position: relative;
}

label {
    display: block;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
    font-size: 0.95rem;
}

body.dark-mode label {
    color: #d1d5db;
}

input, select {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-size: 16px;
    background: white;
    transition: all 0.3s ease;
    font-family: inherit;
}

body.dark-mode input,
body.dark-mode select {
    background: #374151;
    border-color: #4b5563;
    color: #e5e7eb;
}

input:focus, select:focus {
    outline: none;
    border-color: #4facfe;
    box-shadow: 0 0 0 4px rgba(79, 172, 254, 0.1);
    transform: translateY(-1px);
}

input::placeholder {
    color: #9ca3af;
}

body.dark-mode input::placeholder {
    color: #9ca3af;
}

small {
    display: block;
    color: #6b7280;
    font-size: 0.85rem;
    margin-top: 6px;
    line-height: 1.4;
}

body.dark-mode small {
    color: #9ca3af;
}

/* Button styles */
.fetch-button {
    width: 100%;
    padding: 18px 32px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

body.dark-mode .fetch-button {
    background: linear-gradient(135deg, #3b82f6 0%, #9333ea 100%);
}

.fetch-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.fetch-button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.fetch-button::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.fetch-button:hover::after {
    width: 300px;
    height: 300px;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #ffffff40;
    border-top: 2px solid #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Error message */
.error-message {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    border: 1px solid #f87171;
    color: #dc2626;
    padding: 16px 20px;
    margin: 20px 40px;
    border-radius: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
}

body.dark-mode .error-message {
    background: linear-gradient(135deg, #7f1d1d 0%, #991b1b 100%);
    border-color: #b91c1c;
    color: #fecaca;
}

.error-message::before {
    content: '⚠️';
    font-size: 1.2em;
}

/* Loading indicator */
.loading-indicator {
    text-align: center;
    padding: 40px;
    color: #6b7280;
}

body.dark-mode .loading-indicator {
    color: #9ca3af;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e5e7eb;
    border-top: 4px solid #4facfe;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

body.dark-mode .loading-spinner {
    border-color: #4b5563;
    border-top-color: #3b82f6;
}

/* Results section */
.results-section {
    margin: 20px 40px 40px;
    background: #f9fafb;
    border-radius: 16px;
    padding: 32px;
    border: 1px solid #e5e7eb;
}

body.dark-mode .results-section {
    background: #374151;
    border-color: #4b5563;
}

.results-header {
    margin-bottom: 24px;
}

.results-header h2 {
    color: #111827;
    font-size: 1.8rem;
    margin-bottom: 8px;
}

body.dark-mode .results-header h2 {
    color: #e5e7eb;
}

.results-meta {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    color: #6b7280;
    font-size: 0.9rem;
}

body.dark-mode .results-meta {
    color: #9ca3af;
}

.results-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.download-button, .copy-button {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
}

.download-button {
    background: linear-gradient(135deg, #10b981 0%, #34d399 100%);
    color: white;
}

body.dark-mode .download-button {
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
}

.copy-button {
    background: linear-gradient(135deg, #8b5cf6 0%, #a78bfa 100%);
    color: white;
}

body.dark-mode .copy-button {
    background: linear-gradient(135deg, #7c3aed 0%, #9333ea 100%);
}

.download-button:hover, .copy-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

/* Table styles */
.table-wrapper {
    overflow-x: auto;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    margin-bottom: 24px;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: white;
    border-radius: 12px;
    overflow: hidden;
}

body.dark-mode table {
    background: #374151;
}

th {
    background: linear-gradient(135deg, #374151 0%, #4b5563 100%);
    color: white;
    padding: 16px 20px;
    text-align: left;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

body.dark-mode th {
    background: linear-gradient(135deg, #1f2937 0%, #374151 100%);
}

td {
    padding: 16px 20px;
    border-bottom: 1px solid #f3f4f6;
    color: #374151;
    font-size: 0.95rem;
}

body.dark-mode td {
    border-bottom-color: #4b5563;
    color: #d1d5db;
}

tr:hover {
    background: #f9fafb;
}

body.dark-mode tr:hover {
    background: #4b5563;
}

tr:last-child td {
    border-bottom: none;
}

.wind-vector-graph {
    background: #f9fafb;
    border-radius: 16px;
    padding: 16px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

body.dark-mode .wind-vector-graph {
    background: #374151;
    border-color: #4b5563;
}

#windVectorCanvas {
  width: 100%;
  height: 400px;
}

/* Footer */
footer {
    background: #f9fafb;
    padding: 24px 40px;
    text-align: center;
    color: #6b7280;
    border-top: 1px solid #e5e7eb;
}

body.dark-mode footer {
    background: #374151;
    color: #9ca3af;
    border-top-color: #4b5563;
}

footer p {
    margin-bottom: 4px;
}

footer a {
    color: #4facfe;
    text-decoration: none;
    font-weight: 500;
}

body.dark-mode footer a {
    color: #3b82f6;
}

footer a:hover {
    text-decoration: underline;
}

/* Responsive design */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .container {
        border-radius: 12px;
    }
    
    header {
        padding: 30px 20px;
    }
    
    header h1 {
        font-size: 2.2rem;
    }
    
    .form-section {
        padding: 30px 20px;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .results-section {
        margin: 20px;
        padding: 24px 16px;
    }
    
    .results-actions {
        flex-direction: column;
    }
    
    .results-meta {
        flex-direction: column;
        gap: 8px;
    }
    
    footer {
        padding: 20px;
    }

    #windVectorCanvas {
        height: 300px;
    }
}

@media (max-width: 480px) {
    th, td {
        padding: 12px 8px;
        font-size: 0.85rem;
    }
    
    .compass-circle {
        width: 160px;
        height: 160px;
    }
    
    .compass-arrow {
        height: 60px;
    }
}