/* ===========================================
   MAPAS BONITOS - Styles
   =========================================== */

/* CSS Variables */
:root {
    --color-bg: #fafafa;
    --color-surface: #ffffff;
    --color-text: #1a1a1a;
    --color-text-muted: #6b7280;
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-accent: #f59e0b;
    --color-success: #10b981;
    --color-error: #ef4444;
    --color-border: #e5e7eb;
    
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', Menlo, monospace;
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 1rem;
    
    --container-max: 1200px;
    --header-height: 4rem;
}

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

a {
    color: inherit;
    text-decoration: none;
}

/* Layout */
.container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 1.5rem;
}

.section {
    padding: 4rem 0;
}

.section-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-align: center;
}

.section-subtitle {
    color: var(--color-text-muted);
    text-align: center;
    max-width: 600px;
    margin: 0 auto 2rem;
}

/* Header */
.header {
    position: sticky;
    top: 0;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    height: var(--header-height);
    z-index: 100;
}

.header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.25rem;
}

.logo-icon {
    font-size: 1.5rem;
}

.nav {
    display: flex;
    gap: 1.5rem;
}

.nav-link {
    color: var(--color-text-muted);
    font-weight: 500;
    transition: color 0.2s;
}

.nav-link:hover {
    color: var(--color-primary);
}

/* Hero */
.hero {
    padding: 6rem 0;
    text-align: center;
    background: linear-gradient(180deg, var(--color-surface) 0%, var(--color-bg) 100%);
}

.hero-title {
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 800;
    margin-bottom: 1rem;
    line-height: 1.2;
}

.hero-subtitle {
    font-size: 1.25rem;
    color: var(--color-text-muted);
    max-width: 600px;
    margin: 0 auto 2rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

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

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

.btn-secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.btn-secondary:hover {
    background: var(--color-bg);
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.125rem;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Gallery */
.gallery-section {
    background: var(--color-surface);
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.gallery-item {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    aspect-ratio: 3/4;
    background: var(--color-border);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    color: white;
    font-weight: 600;
}

/* Create Form */
.create-section {
    background: var(--color-bg);
}

.create-form {
    max-width: 600px;
    margin: 0 auto;
    background: var(--color-surface);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

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

.form-label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.form-input {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-hint {
    display: block;
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-top: 0.25rem;
}

/* Themes Grid */
.themes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.75rem;
}

.theme-card {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-md);
    cursor: pointer;
    overflow: hidden;
    border: 3px solid transparent;
    transition: transform 0.2s, border-color 0.2s;
}

.theme-card:hover {
    transform: scale(1.05);
}

.theme-card.selected {
    border-color: var(--color-primary);
}

.theme-card-bg {
    position: absolute;
    inset: 0;
}

.theme-card-roads {
    position: absolute;
    inset: 20%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
}

.theme-card-road {
    height: 2px;
    border-radius: 1px;
}

.theme-card-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.25rem;
    font-size: 0.625rem;
    font-weight: 600;
    text-align: center;
    background: rgba(0,0,0,0.5);
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Distance Slider */
.distance-slider {
    padding: 0 0.5rem;
}

.form-range {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: var(--color-border);
    appearance: none;
    cursor: pointer;
}

.form-range::-webkit-slider-thumb {
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--color-primary);
    cursor: pointer;
    border: 3px solid white;
    box-shadow: var(--shadow-md);
}

.distance-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.distance-labels span:nth-child(2) {
    font-weight: 600;
    color: var(--color-primary);
    font-size: 1rem;
}

/* Details */
.form-details {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.form-details summary {
    cursor: pointer;
    font-weight: 500;
    color: var(--color-text-muted);
}

.form-details[open] summary {
    margin-bottom: 1rem;
}

/* Form Actions */
.form-actions {
    text-align: center;
}

.form-note {
    margin-top: 0.75rem;
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

/* Spinner */
.spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

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

.btn-loading .spinner {
    border-color: white;
    border-right-color: transparent;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal[hidden] {
    display: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 480px;
    width: 100%;
    max-height: 90vh;
    overflow: auto;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--color-border);
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--color-border);
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

/* Status Steps */
.status-step {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    margin-bottom: 0.5rem;
}

.status-step[hidden] {
    display: none;
}

.status-icon {
    font-size: 1.5rem;
    width: 2rem;
    text-align: center;
}

.status-text {
    font-weight: 500;
}

.status-note {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-top: 0.5rem;
    margin-left: 2rem;
}

.status-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--color-success);
}

.status-error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--color-error);
}

.status-info {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--color-bg);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
}

.status-info p {
    margin-bottom: 0.25rem;
}

.error-message {
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(239, 68, 68, 0.1);
    border-radius: var(--radius-md);
    color: var(--color-error);
    font-size: 0.875rem;
}

.error-message[hidden] {
    display: none;
}

.result-preview {
    margin-top: 1rem;
    text-align: center;
}

.result-preview[hidden] {
    display: none;
}

/* Themes Showcase */
.themes-showcase {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin-top: 2rem;
}

.theme-showcase-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
}

.theme-showcase-preview {
    aspect-ratio: 4/3;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-showcase-roads {
    width: 60%;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.theme-showcase-road {
    height: 3px;
    border-radius: 2px;
}

.theme-showcase-info {
    padding: 1rem;
    border-top: 1px solid var(--color-border);
}

.theme-showcase-name {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.theme-showcase-desc {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Footer */
.footer {
    padding: 3rem 0;
    text-align: center;
    border-top: 1px solid var(--color-border);
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

.footer a {
    color: var(--color-primary);
}

.footer p {
    margin-bottom: 0.5rem;
}

/* Loading States */
.themes-loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 2rem;
    color: var(--color-text-muted);
}

/* Responsive */
@media (max-width: 768px) {
    .nav {
        display: none;
    }
    
    .hero {
        padding: 4rem 0;
    }
    
    .section {
        padding: 3rem 0;
    }
    
    .create-form {
        padding: 1.5rem;
    }
    
    .themes-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }
    
    .modal-footer {
        flex-direction: column;
    }
    
    .modal-footer .btn {
        width: 100%;
    }
}
