/* ============================================
   AstroCronos - Estilos Principales
   ============================================ */

:root {
    --primary-color: #6c5ce7;
    --secondary-color: #a29bfe;
    --accent-color: #fd79a8;
    --dark-bg: #2d3436;
    --light-bg: #f5f6fa;
    --text-dark: #2d3436;
    --text-light: #636e72;
    --border-color: #dfe6e9;
    --success-color: #00b894;
    --error-color: #d63031;
    --warning-color: #fdcb6e;
    
    --transition: all 0.3s ease;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.15);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--light-bg);
    color: var(--text-dark);
    line-height: 1.6;
}

/* ============ NAVBAR ============ */

.navbar {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 1rem 0;
    box-shadow: var(--shadow-lg);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar-brand h1 {
    font-size: 1.8rem;
    margin-bottom: 0.25rem;
}

.navbar-brand .subtitle {
    font-size: 0.85rem;
    opacity: 0.9;
}

.nav-list {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-link {
    color: white;
    text-decoration: none;
    transition: var(--transition);
    cursor: pointer;
    font-weight: 500;
}

.nav-link:hover {
    opacity: 0.8;
    text-decoration: underline;
}

.navbar-auth {
    display: flex;
    gap: 1rem;
}

.btn-login, .btn-logout {
    padding: 0.5rem 1.5rem;
    border: 2px solid white;
    background: transparent;
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
}

.btn-login:hover {
    background: white;
    color: var(--primary-color);
}

.btn-logout:hover {
    background: var(--error-color);
    border-color: var(--error-color);
}

/* ============ CONTAINER ============ */

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* ============ SECTIONS ============ */

.section {
    min-height: calc(100vh - 100px);
    padding: 2rem 0;
}

/* ============ HERO ============ */

.hero {
    text-align: center;
    padding: 4rem 2rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-radius: 8px;
    margin-bottom: 2rem;
}

.hero h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.hero p {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    opacity: 0.95;
}

/* ============ BUTTONS ============ */

.btn-primary, .btn-secondary {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: #5f4fd1;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--border-color);
    color: var(--text-dark);
}

.btn-secondary:hover {
    background: #d0d7de;
}

.btn-large {
    padding: 1rem 2.5rem;
    font-size: 1.1rem;
}

.btn-block {
    width: 100%;
}

/* ============ FORMS ============ */

.auth-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    max-width: 500px;
    margin: 2rem auto;
}

.auth-form {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
}

.auth-form h2 {
    margin-bottom: 1.5rem;
    color: var(--primary-color);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-dark);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
    transition: var(--transition);
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.1);
}

.auth-switch {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--text-light);
}

.auth-switch a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
}

.auth-switch a:hover {
    text-decoration: underline;
}

/* ============ CALCULATOR LAYOUT ============ */

.calculator-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-top: 2rem;
}

.form-panel, .results-panel {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.form-panel h3, .results-panel h3 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
}

/* ============ CHART VISUALIZATION ============ */

.chart-container {
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 450px;
}

#chartSvg {
    max-width: 100%;
    height: auto;
}

/* ============ RESULTS TABLE ============ */

.results-table {
    margin-bottom: 2rem;
}

.results-table h4 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

thead {
    background: var(--primary-color);
    color: white;
}

th, td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

tbody tr:hover {
    background: var(--light-bg);
}

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

/* ============ ACTION BUTTONS ============ */

.action-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.action-buttons button {
    flex: 1;
}

/* ============ CHARTS GRID ============ */

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.chart-card {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: var(--transition);
    cursor: pointer;
}

.chart-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.chart-card h4 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.chart-card p {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.chart-card .chart-date {
    font-weight: 600;
    color: var(--text-dark);
}

/* ============ PROFILE CONTAINER ============ */

.profile-container {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    max-width: 600px;
    margin: 2rem auto;
}

#profileInfo {
    display: grid;
    gap: 1.5rem;
}

.profile-field {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.profile-field:last-child {
    border-bottom: none;
}

.profile-field label {
    font-weight: 600;
    color: var(--primary-color);
}

/* ============ ALERTS ============ */

.alert {
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    font-weight: 500;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* ============ LOADING ============ */

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============ RESPONSIVE ============ */

@media (max-width: 768px) {
    .navbar-container {
        flex-direction: column;
        gap: 1rem;
    }

    .nav-list {
        gap: 1rem;
        flex-wrap: wrap;
    }

    .calculator-layout {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .hero h2 {
        font-size: 1.8rem;
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }

    .profile-field {
        grid-template-columns: 1fr;
    }

    .action-buttons {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 1rem;
    }

    .auth-form {
        padding: 1.5rem;
    }

    .navbar-brand h1 {
        font-size: 1.3rem;
    }

    .nav-list {
        display: none;
    }
}

/* ============================================
   CITY AUTOCOMPLETE (Nominatim)
   Requiere:
   - input #ciudad
   - contenedor #citySuggestions (lo añadiremos en app.html)
   ============================================ */

.city-autocomplete {
    position: relative;
}

#citySuggestions {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 6px);
    background: #fff;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    overflow: hidden;
    display: none;
    max-height: 260px;
    overflow-y: auto;
}

.city-suggestion {
    padding: 0.75rem 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 1px solid var(--border-color);
}

.city-suggestion:last-child {
    border-bottom: none;
}

.city-suggestion:hover {
    background: var(--light-bg);
}

.city-suggestion strong {
    color: var(--text-dark);
}

.city-suggestion small {
    color: var(--text-light);
    display: block;
    margin-top: 0.15rem;
}

/* En móvil: que no se salga del contenedor */
@media (max-width: 768px) {
    #citySuggestions {
        max-height: 220px;
    }
}
