/* frontend/css/style.css - Donnersberg Schaaf Challenge */

/* ============= RESET & BASE ============= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #31a354;
    --primary-dark: #238b45;
    --secondary: #addd8e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --success: #31a354;
    --light-green: #f7fcb9;
    --dark: #1f2937;
    --light: #f9fafb;
    --gray: #6b7280;
    --border: #e5e7eb;

    --bg-body: linear-gradient(135deg, #f7fcb9 0%, #addd8e 50%, #31a354 100%);
    --bg-container: white;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
    --shadow-xl: 0 20px 25px rgba(0,0,0,0.15);

    --radius: 8px;
    --radius-lg: 12px;
    --transition: all 0.3s ease;
}

/* Dark Theme */
[data-theme="dark"] {
    --primary: #31a354;
    --primary-dark: #238b45;
    --secondary: #4a5568;
    --light-green: #2d3748;
    --dark: #e5e7eb;
    --light: #1a202c;
    --gray: #a0aec0;
    --border: #4a5568;

    --bg-body: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #334155 100%);
    --bg-container: #1e293b;
    --text-primary: #e5e7eb;
    --text-secondary: #a0aec0;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow: 0 4px 6px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.5);
    --shadow-xl: 0 20px 25px rgba(0,0,0,0.6);
}

body {
    font-family: 'Urbanist', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-body);
    min-height: 100vh;
    padding: 10px;
    transition: var(--transition);
}

@media (min-width: 768px) {
    body {
        padding: 20px;
    }
}

/* ============= TYPOGRAPHY ============= */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 1rem;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }

@media (min-width: 768px) {
    h1 { font-size: 2.5rem; }
    h2 { font-size: 2rem; }
    h3 { font-size: 1.5rem; }
}

p { margin-bottom: 1rem; }

/* ============= HEADER ============= */
header {
    background: var(--bg-container);
    padding: 1rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    margin-bottom: 0.75rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

@media (min-width: 768px) {
    header {
        padding: 1.5rem 2rem;
        margin-bottom: 1rem;
    }
}

.logo-container {
    width: 100%;
    display: flex;
    justify-content: center;
}

.header-logo {
    max-width: 350px;
    width: 100%;
    height: auto;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
    transition: var(--transition);
}

@media (min-width: 768px) {
    .header-logo {
        max-width: 450px;
    }
}

@media (min-width: 1024px) {
    .header-logo {
        max-width: 550px;
    }
}

.header-logo:hover {
    transform: scale(1.05);
}

/* ============= NAVIGATION CONTROLS ============= */
.navigation-controls {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0.5rem;
}

@media (min-width: 768px) {
    .navigation-controls {
        gap: 1rem;
        margin-bottom: 1.5rem;
        padding: 0.75rem;
    }
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--bg-container);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.icon-btn:hover {
    background: var(--light);
    border-color: var(--primary);
    transform: scale(1.1);
}

.icon-btn .material-symbols-outlined {
    font-size: 24px;
}

.lang-text {
    font-weight: 700;
    font-size: 14px;
}

.header-back-nav {
    display: flex;
    justify-content: center;
    width: 100%;
}

.back-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--bg-container);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    text-decoration: none;
}

.back-btn:hover {
    background: var(--light);
    border-color: var(--primary);
    transform: scale(1.1);
}

.back-btn .material-symbols-outlined {
    font-size: 24px;
}

header nav {
    display: flex;
    gap: 1rem;
}

header nav a {
    color: var(--gray);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    transition: var(--transition);
    font-weight: 500;
}

header nav a:hover {
    background: var(--light);
    color: var(--primary);
}

/* ============= CONTAINER ============= */
.container {
    max-width: 1200px;
    margin: 0 auto;
    background: var(--bg-container);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    padding: 1rem;
}

@media (min-width: 768px) {
    .container {
        padding: 2.5rem;
    }
}

/* ============= SECTIONS ============= */
section {
    margin-bottom: 2rem;
}

@media (min-width: 768px) {
    section {
        margin-bottom: 3rem;
    }
}

section:last-child {
    margin-bottom: 0;
}

section h2 {
    text-align: center;
}

.page-title {
    text-align: center;
    margin-bottom: 2rem;
}

.info-section h2,
.action-section h2,
.map-section h2,
.search-section h2,
.stats-section h2,
.leaderboard-section h2 {
    text-align: center;
}

.welcome-section {
    text-align: center;
    padding: 1rem 0;
    border-bottom: 2px solid var(--border);
}

@media (min-width: 768px) {
    .welcome-section {
        padding: 2rem 0;
    }
}

.description {
    font-size: 1rem;
    color: var(--gray);
    max-width: 700px;
    margin: 0 auto;
}

@media (min-width: 768px) {
    .description {
        font-size: 1.1rem;
    }
}

/* ============= STEPS ============= */
.steps {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-top: 1rem;
}

@media (min-width: 768px) {
    .steps {
        grid-template-columns: repeat(2, 1fr);
        gap: 2rem;
        margin-top: 2rem;
    }
}

@media (min-width: 1024px) {
    .steps {
        grid-template-columns: repeat(4, 1fr);
    }
}

.step {
    text-align: center;
    padding: 1rem;
    background: var(--light-green);
    border-radius: var(--radius-lg);
    transition: var(--transition);
    border: 2px solid var(--secondary);
}

@media (min-width: 768px) {
    .step {
        padding: 1.5rem;
    }
}

.step:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    background: white;
}

.step-number {
    display: inline-block;
    width: 50px;
    height: 50px;
    line-height: 50px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border-radius: 50%;
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 1rem;
}

.step h3 {
    color: var(--dark);
    margin-bottom: 0.5rem;
}

.step p {
    color: var(--gray);
    margin: 0;
}

/* ============= ACTION SECTIONS ============= */
.action-section {
    background: var(--light);
    padding: 1rem;
    border-radius: var(--radius-lg);
    text-align: center;
}

@media (min-width: 768px) {
    .action-section {
        padding: 2rem;
    }
}

.action-section.primary {
    background: linear-gradient(135deg, var(--light-green), var(--secondary));
    border: 2px solid var(--primary);
}

/* ============= BUTTONS ============= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    text-align: center;
    width: 100%;
}

@media (min-width: 768px) {
    .btn {
        padding: 0.875rem 1.75rem;
        font-size: 1rem;
        width: auto;
    }
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: var(--shadow);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: white;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--primary);
    color: white;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* ============= START NUMBER CARD ============= */
.start-number-card {
    background: white;
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    margin-top: 2rem;
    border: 3px solid var(--success);
    animation: slideIn 0.4s ease;
}

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

.success-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.start-number {
    font-size: 3rem;
    font-weight: bold;
    color: var(--primary);
    letter-spacing: 0.5rem;
    margin: 1.5rem 0;
    font-family: 'Courier New', monospace;
}

.validity-info {
    background: var(--light);
    padding: 1rem;
    border-radius: var(--radius);
    margin: 1.5rem 0;
}

.warning {
    color: var(--warning);
    font-weight: 600;
    margin-top: 0.5rem;
}

.action-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* ============= NOTES LIST ============= */
.notes-list {
    list-style: none;
    padding-left: 0;
}

.notes-list li {
    padding: 0.75rem 0;
    padding-left: 2rem;
    position: relative;
    border-bottom: 1px solid var(--border);
}

.notes-list li:before {
    content: '✓';
    position: absolute;
    left: 0;
    color: var(--success);
    font-weight: bold;
}

/* ============= CHECKPOINT PAGE ============= */
.checkpoint-page {
    max-width: 600px;
}

.checkpoint-header {
    text-align: center;
    margin-bottom: 2rem;
}

.checkpoint-icon {
    font-size: 4rem;
    margin: 1rem 0;
}

.checkpoint-info {
    text-align: center;
    font-size: 1.1rem;
    color: var(--gray);
    margin-bottom: 2rem;
}

/* ============= FORMS ============= */
.checkpoint-form, .search-form {
    max-width: 500px;
    margin: 0 auto;
}

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

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

.form-group input {
    width: 100%;
    padding: 0.875rem;
    font-size: 1.1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    transition: var(--transition);
    text-align: center;
    font-family: 'Courier New', monospace;
    letter-spacing: 0.3rem;
}

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

.form-group small {
    display: block;
    margin-top: 0.5rem;
    color: var(--gray);
    font-size: 0.875rem;
}

/* ============= PROGRESS ============= */
.progress-info {
    margin: 1.5rem 0;
}

.progress-bar {
    width: 100%;
    height: 30px;
    background: var(--border);
    border-radius: 15px;
    overflow: hidden;
    margin-top: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), var(--secondary));
    transition: width 0.5s ease;
}

/* ============= SUCCESS/ERROR MESSAGES ============= */
.success-card, .completion-card {
    background: white;
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    text-align: center;
    animation: slideIn 0.4s ease;
    margin-top: 2rem;
}

.success-card {
    border: 3px solid var(--success);
}

.completion-card {
    border: 3px solid var(--warning);
}

.completion-icon {
    font-size: 4rem;
}

.final-time {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--primary);
    margin: 1rem 0;
}

.error-message {
    background: #fee2e2;
    color: var(--danger);
    padding: 1rem;
    border-radius: var(--radius);
    border: 2px solid var(--danger);
    margin: 1rem 0;
    font-weight: 500;
}

/* ============= LEADERBOARD ============= */
.search-section {
    background: var(--light);
    padding: 2rem;
    border-radius: var(--radius-lg);
    margin-bottom: 2rem;
    text-align: center;
}

.search-form {
    display: flex;
    gap: 1rem;
    justify-content: center;
    align-items: center;
}

.search-form input {
    flex: 1;
}

.search-result {
    margin-top: 1.5rem;
    padding: 1.5rem;
    border-radius: var(--radius);
    animation: slideIn 0.3s ease;
}

.search-result.success {
    background: #d1fae5;
    border: 2px solid var(--success);
}

.search-result.error {
    background: #fee2e2;
    border: 2px solid var(--danger);
}

.search-result.info {
    background: #dbeafe;
    border: 2px solid var(--primary);
}

.search-result-card h3 {
    margin-bottom: 1rem;
}

.result-details {
    display: grid;
    gap: 0.75rem;
}

.result-item {
    padding: 0.75rem;
    background: white;
    border-radius: var(--radius);
}

/* ============= STATS ============= */
.stats-section {
    margin-bottom: 2rem;
}

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

.stat-card {
    background: var(--light);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    text-align: center;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}

.stat-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary);
}

.stat-label {
    color: var(--gray);
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

/* ============= TABLE ============= */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.leaderboard-table thead {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
}

.leaderboard-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.875rem;
    letter-spacing: 0.05em;
}

.leaderboard-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}

.leaderboard-table tbody tr:hover {
    background: var(--light);
}

.leaderboard-table tbody tr.rank-1 {
    background: linear-gradient(90deg, #fef3c7, transparent);
}

.leaderboard-table tbody tr.rank-2 {
    background: linear-gradient(90deg, #e0e7ff, transparent);
}

.leaderboard-table tbody tr.rank-3 {
    background: linear-gradient(90deg, #fed7aa, transparent);
}

.leaderboard-table td {
    padding: 1rem;
}

.rank-cell {
    font-weight: bold;
    font-size: 1.2rem;
}

.start-number-cell {
    font-family: 'Courier New', monospace;
    letter-spacing: 0.1em;
}

.time-cell {
    font-weight: 600;
    color: var(--primary);
}

.load-more-container {
    text-align: center;
    margin-top: 2rem;
}

/* ============= LOADING ============= */
.loading {
    text-align: center;
    padding: 3rem;
}

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

.spinner.small {
    width: 20px;
    height: 20px;
    border-width: 3px;
}

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

/* ============= EMPTY STATE ============= */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--gray);
}

.empty-state p:first-child {
    font-size: 4rem;
    margin-bottom: 1rem;
}

/* ============= HELP SECTION ============= */
.help-section {
    background: var(--light);
    padding: 1.5rem;
    border-radius: var(--radius);
    margin-top: 2rem;
}

.help-section h3 {
    margin-bottom: 1rem;
}

.help-section ul {
    list-style: none;
    padding: 0;
}

.help-section li {
    padding: 0.5rem 0;
    padding-left: 1.5rem;
    position: relative;
}

.help-section li:before {
    content: '💡';
    position: absolute;
    left: 0;
}

/* ============= FOOTER ============= */
footer {
    text-align: center;
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--bg-container);
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
    box-shadow: var(--shadow);
}

footer p {
    margin: 0.25rem 0;
}

footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
}

footer a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* ============= MATERIAL ICONS ============= */
.material-symbols-outlined {
    vertical-align: middle;
    font-size: 1.2em;
}

h2 .material-symbols-outlined {
    font-size: 1.3em;
    margin-right: 0.25rem;
}

.success-icon .material-symbols-outlined {
    font-size: 3rem;
    color: var(--success);
}

.warning .material-symbols-outlined {
    font-size: 1.2em;
    vertical-align: middle;
}

/* ============= MAP SECTION ============= */
.map-section {
    margin-bottom: 2rem;
}

@media (min-width: 768px) {
    .map-section {
        margin-bottom: 3rem;
    }
}

.route-map {
    width: 100%;
    height: 300px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    margin-top: 1rem;
    border: 2px solid var(--secondary);
}

@media (min-width: 768px) {
    .route-map {
        height: 450px;
    }
}

@media (min-width: 1024px) {
    .route-map {
        height: 500px;
    }
}

.map-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}

.map-loading.hidden {
    display: none;
}

/* ============= UTILITY CLASSES ============= */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mt-2 {
    margin-top: 2rem;
}

/* ============= RESPONSIVE ============= */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .success-card, .completion-card {
        padding: 1.5rem;
        margin-top: 1rem;
    }

    .success-icon {
        font-size: 3rem;
    }

    .checkpoint-form {
        margin: 1rem 0;
    }
    
    header {
        padding: 1rem;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    .container {
        padding: 1.5rem;
    }
    
    h1 { font-size: 2rem; }
    h2 { font-size: 1.5rem; }
    
    .steps {
        grid-template-columns: 1fr;
    }
    
    .start-number {
        font-size: 2rem;
        letter-spacing: 0.3rem;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .search-form {
        flex-direction: column;
    }
    
    .leaderboard-table {
        font-size: 0.875rem;
    }
    
    .leaderboard-table th,
    .leaderboard-table td {
        padding: 0.75rem 0.5rem;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}