/* SIMPLE, STABLE CSS FOR SOLIFRET */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-color: #1a1a2e;
    --text-color: #f1f1f1;
    --card-bg: #16213e;
    --card-border: #2d3748;
    --card-hover: #4cc9f0;
    --primary-color: #4cc9f0;
    --secondary-color: #a9a9a9;
    --accent-color: #72efdd;
    --shadow: rgba(0,0,0,0.2);
}

[data-theme="light"] {
    --bg-color: #f8f9fa;
    --text-color: #333;
    --card-bg: white;
    --card-border: #e9ecef;
    --card-hover: #3498db;
    --primary-color: #3498db;
    --secondary-color: #6c757d;
    --accent-color: #2c3e50;
    --shadow: rgba(0,0,0,0.05);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    transition: background 0.3s ease, color 0.3s ease;
}

main {
    max-width: 800px;
    margin: 0 auto;
    padding: 1rem;
}

/* HEADER - SIMPLE AND STABLE */
header {
    text-align: center;
    margin-bottom: 2rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--card-border);
}

.header-container {
    position: relative;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 300;
    color: var(--accent-color);
    margin: 0;
    line-height: 1;
}

.theme-toggle {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: 1px solid var(--card-border);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    transition: all 0.2s ease;
    color: var(--text-color);
}

.theme-toggle:hover {
    background: var(--card-border);
    transform: translateY(-50%) scale(1.1);
}

header p {
    color: var(--secondary-color);
    font-size: 1rem;
    margin-top: 0.5rem;
}

/* NAVIGATION */
.nav {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.nav-btn {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    color: var(--text-color);
    padding: 0.75rem 2rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s ease;
    font-family: inherit;
}

.nav-btn:hover,
.nav-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* CONTENT PAGES */
.page-content {
    display: none;
}

.page-content.active {
    display: block;
}

/* QUOTES */
.quotes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.quote-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.quote-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px var(--shadow);
    border-color: var(--card-hover);
}

.quote-card.selected {
    border-color: var(--card-hover);
    background: var(--card-bg);
    opacity: 0.9;
}

.quote-content {
    font-size: 1.2rem;
    line-height: 1.6;
    color: var(--text-color);
    margin-bottom: 1rem;
    font-style: italic;
}

.quote-author {
    font-size: 1rem;
    color: var(--secondary-color);
    text-align: right;
    font-weight: 500;
}

.rank-badge {
    display: inline-block;
    background: var(--primary-color);
    color: white;
    font-size: 0.8rem;
    font-weight: bold;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    margin-right: 0.5rem;
    vertical-align: middle;
}

.top-three-rank {
    background: linear-gradient(135deg, #ffd700, #ff9500);
    color: #000;
}

.other-rank {
    background: var(--secondary-color);
    color: white;
}



/* LOADING & ERRORS */
#loading, #top-quotes-loading {
    text-align: center;
    padding: 3rem;
    color: var(--secondary-color);
}

.spinner {
    border: 3px solid var(--card-border);
    border-radius: 50%;
    border-top: 3px solid var(--primary-color);
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1.5rem;
}

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

.error {
    text-align: center;
    padding: 2rem;
    color: #ff6b6b;
    background: rgba(255, 107, 107, 0.1);
    border: 1px solid rgba(255, 107, 107, 0.3);
    border-radius: 12px;
}

/* FOOTER */
footer {
    text-align: center;
    padding: 2rem 1rem;
    border-top: 1px solid var(--card-border);
    margin-top: 2rem;
}

#refresh-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 1rem 2rem;
    font-size: 1.1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: opacity 0.2s ease;
    margin-bottom: 1rem;
}

#refresh-btn:hover {
    opacity: 0.9;
}

.footer-note {
    color: var(--secondary-color);
    font-size: 0.9rem;
}

/* PWA PROMPT */
.pwa-prompt {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 400px;
    background: var(--card-bg);
    border: 2px solid var(--primary-color);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    z-index: 1000;
}

.pwa-prompt.hidden {
    display: none;
}

.pwa-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

.pwa-overlay.hidden {
    display: none;
}

.pwa-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.pwa-icon {
    width: 48px;
    height: 48px;
    background: var(--primary-color);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
}

.pwa-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-color);
    margin: 0;
}

.pwa-message {
    color: var(--text-color);
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.pwa-instructions {
    background: var(--bg-color);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.5rem;
    border-left: 4px solid var(--primary-color);
}

.pwa-instructions ol {
    margin: 0;
    padding-left: 1.2rem;
}

.pwa-instructions li {
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.pwa-buttons {
    display: flex;
    gap: 0.75rem;
}

.pwa-btn {
    flex: 1;
    padding: 0.75rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.pwa-btn.primary:hover {
    opacity: 0.9;
}

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

/* MOBILE RESPONSIVE */
@media (max-width: 768px) {
    main {
        padding: 0.75rem;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .header-container {
        height: 50px;
    }
    
    .theme-toggle {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }
    
    .nav-btn {
        padding: 0.6rem 1.5rem;
        font-size: 0.95rem;
    }
    
    .quotes-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .quote-card {
        padding: 1.25rem;
    }
    
    .quote-content {
        font-size: 1.1rem;
    }
    
    .pwa-prompt {
        width: 95%;
        bottom: 10px;
    }
}

@media (max-width: 480px) {
    main {
        padding: 0.5rem;
    }
    
    header h1 {
        font-size: 1.75rem;
    }
    
    .header-container {
        height: 45px;
    }
    
    .theme-toggle {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }
    
    .nav {
        gap: 0.5rem;
    }
    
    .nav-btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
    
    #refresh-btn {
        width: 100%;
        padding: 0.875rem;
    }
}