/* 
 * DerivLingo - Duolingo Inspired Design
 * Color Scheme: Deriv Green (#00A382), White, Light Gray
 */

:root {
    --primary: #00A382;
    --primary-dark: #008C6A;
    --primary-light: #E5F6F2;
    --secondary: #FFB74D;
    --success: #58CC02;
    --danger: #FF4B4B;
    --warning: #FFC800;
    --text-dark: #1F1F1F;
    --text-gray: #4A5568;
    --text-light: #718096;
    --bg-light: #F7FAFC;
    --bg-white: #FFFFFF;
    --border-light: #E2E8F0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-hover: 0 20px 25px -5px rgba(0, 163, 130, 0.1), 0 10px 10px -5px rgba(0, 163, 130, 0.04);
    --border-radius: 24px;
    --border-radius-sm: 12px;
    --font-main: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-main);
    background: linear-gradient(135deg, var(--bg-light) 0%, #FFFFFF 100%);
    color: var(--text-dark);
    line-height: 1.6;
    min-height: 100vh;
}

/* Duolingo Style Containers */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Navigation */
.navbar {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
    padding: 12px 0;
    border-bottom: 1px solid rgba(0, 163, 130, 0.1);
}

.navbar-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 28px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-decoration: none;
    letter-spacing: -0.5px;
}

.logo span {
    background: linear-gradient(135deg, var(--secondary) 0%, #FF9800 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Navigation Links */
.nav-links {
    display: flex;
    gap: 8px;
    align-items: center;
}

.nav-link {
    color: var(--text-gray);
    text-decoration: none;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 30px;
    transition: all 0.2s;
}

.nav-link:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.nav-link.active {
    background: var(--primary);
    color: white;
}

/* Streak Badge */
.streak-badge {
    background: linear-gradient(135deg, #FF6B6B, #FF8E53);
    color: white;
    padding: 6px 16px;
    border-radius: 30px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 10px rgba(255, 107, 107, 0.3);
}

.streak-badge i {
    font-size: 18px;
    animation: flame-flicker 1.5s infinite;
}

@keyframes flame-flicker {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.1); }
}

/* Lesson Cards */
.lesson-card {
    background: var(--bg-white);
    border-radius: var(--border-radius);
    padding: 28px;
    box-shadow: var(--shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
}

.lesson-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--success));
    opacity: 0;
    transition: opacity 0.3s;
}

.lesson-card.completed::before {
    opacity: 1;
}

.lesson-card.completed {
    background: linear-gradient(145deg, #FFFFFF, #F8FFF8);
    border-left: 8px solid var(--success);
}

.lesson-card.in-progress {
    border-left: 8px solid var(--secondary);
    animation: glow 2s infinite;
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 183, 77, 0.4); }
    50% { box-shadow: 0 0 20px 10px rgba(255, 183, 77, 0.2); }
}

.lesson-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
}

/* Progress Bar */
.progress-container {
    background: #EDF2F7;
    border-radius: 30px;
    height: 12px;
    overflow: hidden;
    margin: 16px 0;
}

.progress-bar {
    background: linear-gradient(90deg, var(--primary), var(--success));
    height: 100%;
    border-radius: 30px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shimmer 2s infinite;
}

/* Buttons */
.btn {
    padding: 12px 28px;
    border-radius: 50px;
    font-weight: 600;
    font-size: 16px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 10px rgba(0, 163, 130, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 163, 130, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--secondary), #FF9800);
    color: white;
    box-shadow: 0 4px 10px rgba(255, 183, 77, 0.3);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

.btn-outline:hover {
    background: var(--primary-light);
}

/* Lesson Content Styling - IMPROVED for database content */
.lesson-content {
    background: white;
    border-radius: var(--border-radius);
    padding: 40px;
    margin: 30px 0;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border-light);
    line-height: 1.8;
}

.lesson-content h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 1.5rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    border-bottom: 3px solid var(--primary-light);
    padding-bottom: 1rem;
}

.lesson-content h2 {
    font-size: 2rem;
    font-weight: 700;
    margin: 2rem 0 1rem;
    color: var(--text-dark);
    position: relative;
}

.lesson-content h2::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 0;
    width: 60px;
    height: 3px;
    background: var(--primary);
    border-radius: 3px;
}

.lesson-content h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 1.5rem 0 1rem;
    color: var(--text-dark);
}

.lesson-content p {
    font-size: 1.125rem;
    line-height: 1.8;
    margin-bottom: 1.5rem;
    color: var(--text-gray);
}

.lesson-content ul, 
.lesson-content ol {
    margin: 1rem 0 1.5rem 1.5rem;
    color: var(--text-gray);
}

.lesson-content li {
    font-size: 1.125rem;
    line-height: 1.8;
    margin-bottom: 0.5rem;
}

.lesson-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--border-radius);
    margin: 2rem 0;
    box-shadow: var(--shadow);
}

.lesson-content blockquote {
    background: var(--primary-light);
    border-left: 6px solid var(--primary);
    padding: 1.5rem;
    margin: 2rem 0;
    border-radius: var(--border-radius-sm);
    font-style: italic;
    color: var(--text-dark);
}

.lesson-content pre {
    background: #1F2937;
    color: #F3F4F6;
    padding: 1.5rem;
    border-radius: var(--border-radius-sm);
    overflow-x: auto;
    margin: 1.5rem 0;
    font-family: 'Fira Code', monospace;
}

.lesson-content code {
    background: #F1F5F9;
    color: var(--primary-dark);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
}

/* Highlight Box for Tips */
.highlight-box {
    background: linear-gradient(135deg, var(--primary-light), #FFFFFF);
    border-radius: var(--border-radius);
    padding: 30px;
    margin: 30px 0;
    border-left: 6px solid var(--primary);
    box-shadow: 0 5px 15px rgba(0, 163, 130, 0.1);
}

.highlight-box h3 {
    color: var(--primary);
    margin-top: 0;
}

.highlight-box p:last-child {
    margin-bottom: 0;
}

.tip-card {
    background: linear-gradient(135deg, #FFF3E0, #FFE0B2);
    border-radius: var(--border-radius);
    padding: 25px;
    margin: 25px 0;
    border-left: 6px solid var(--warning);
    box-shadow: 0 5px 15px rgba(255, 193, 7, 0.1);
}

.tip-card::before {
    content: '💡';
    font-size: 24px;
    margin-right: 10px;
}

/* Warning Box */
.warning-box {
    background: linear-gradient(135deg, #FFEBEE, #FFCDD2);
    border-radius: var(--border-radius);
    padding: 25px;
    margin: 25px 0;
    border-left: 6px solid var(--danger);
    color: #C62828;
}

/* Success Box */
.success-box {
    background: linear-gradient(135deg, #E8F5E9, #C8E6C9);
    border-radius: var(--border-radius);
    padding: 25px;
    margin: 25px 0;
    border-left: 6px solid var(--success);
    color: #2E7D32;
}

/* Table Styling */
.lesson-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
    border-radius: var(--border-radius-sm);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.lesson-content th {
    background: var(--primary);
    color: white;
    font-weight: 600;
    padding: 12px;
    text-align: left;
}

.lesson-content td {
    padding: 12px;
    border-bottom: 1px solid var(--border-light);
}

.lesson-content tr:nth-child(even) {
    background: #F8FAFC;
}

.lesson-content tr:hover {
    background: var(--primary-light);
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-top: 30px;
}

.stat-card {
    background: white;
    border-radius: var(--border-radius);
    padding: 24px;
    text-align: center;
    box-shadow: var(--shadow);
    transition: transform 0.3s;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-number {
    font-size: 48px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 10px 0;
}

/* Certificate Design */
.certificate {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 60px;
    border-radius: 30px;
    color: white;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.certificate::before {
    content: '🏆';
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 100px;
    opacity: 0.1;
}

/* Animations */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slide-up {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scale-in {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.animate-in {
    animation: slideIn 0.6s ease forwards;
}

.animate-slide-in {
    animation: slide-in 0.3s ease-out;
}

.animate-slide-up {
    animation: slide-up 0.4s ease-out;
}

.animate-fade-in {
    animation: fade-in 0.3s ease-out;
}

.animate-scale-in {
    animation: scale-in 0.3s ease-out;
}

/* XP Badge */
.xp-badge {
    background: linear-gradient(135deg, var(--success), #43A047);
    color: white;
    padding: 6px 16px;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 5px rgba(88, 204, 2, 0.3);
}

/* Affiliate Banner */
.affiliate-banner {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 30px;
    border-radius: var(--border-radius);
    margin: 20px 0;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.affiliate-banner::after {
    content: '💰';
    position: absolute;
    bottom: -20px;
    right: -20px;
    font-size: 120px;
    opacity: 0.1;
    transform: rotate(-15deg);
}

.affiliate-link {
    background: white;
    color: var(--primary);
    padding: 12px 24px;
    border-radius: 30px;
    display: inline-block;
    margin-top: 15px;
    font-weight: 700;
    text-decoration: none;
    transition: transform 0.3s;
}

.affiliate-link:hover {
    transform: scale(1.05);
}

/* Phone Input Styling */
.phone-wrapper {
    display: flex;
    align-items: stretch;
}

.country-code-select {
    background-color: #f9fafb;
    border: 2px solid #e5e7eb;
    border-right: none;
    border-radius: 12px 0 0 12px;
    font-size: 0.95rem;
    padding: 0 12px;
    font-weight: 500;
    color: var(--text-dark);
}

.phone-input {
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
}

/* Modal */
.modal-overlay {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    background: white;
    border-radius: 30px;
    padding: 40px;
    max-width: 450px;
    width: 90%;
    position: relative;
}

/* Progress Save Indicator */
.progress-saved {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: linear-gradient(135deg, var(--primary), var(--success));
    color: white;
    padding: 15px 30px;
    border-radius: 50px;
    box-shadow: 0 10px 30px rgba(0, 163, 130, 0.4);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 9999;
    animation: slide-in 0.3s ease-out;
    font-weight: 500;
}

/* Confetti Canvas */
#confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9998;
}

/* Lesson Lock State */
.lesson-locked {
    position: relative;
    opacity: 0.7;
}

.lesson-locked::after {
    content: '🔒';
    position: absolute;
    top: 50%;
    right: 30px;
    transform: translateY(-50%);
    font-size: 24px;
    opacity: 0.5;
}

/* Responsive Design */
@media (max-width: 768px) {
    .navbar-content {
        flex-direction: column;
        gap: 15px;
    }
    
    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
        width: 100%;
    }
    
    .lesson-content {
        padding: 20px;
    }
    
    .lesson-content h1 {
        font-size: 28px;
    }
    
    .lesson-content h2 {
        font-size: 24px;
    }
    
    .lesson-content p {
        font-size: 16px;
    }
    
    .btn {
        padding: 10px 20px;
        width: 100%;
    }
    
    .progress-saved {
        left: 20px;
        right: 20px;
        bottom: 20px;
        width: auto;
    }
    
    .phone-wrapper {
        flex-direction: column;
    }
    
    .country-code-select {
        width: 100%;
        border-radius: 12px;
        border-right: 2px solid #e5e7eb;
        margin-bottom: 8px;
        padding: 12px;
    }
    
    .phone-input {
        border-radius: 12px !important;
    }
}

/* Print Styles */
@media print {
    .navbar,
    .btn,
    .affiliate-banner,
    .progress-saved {
        display: none;
    }
    
    .lesson-content {
        box-shadow: none;
        padding: 0;
    }
}