/* ===== CSS VARIABLES ===== */
:root {
    --primary: #3b82f6; --primary-dark: #1d4ed8; --secondary: #10b981;
    --accent: #f59e0b; --danger: #ef4444; --bg-dark: #0a1628; --bg-mid: #1e3a8a;
    --text-light: #ffffff; --text-dark: #1f2937; --text-muted: #6b7280;
}

/* ===== BASE ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-mid) 50%, #0f172a 100%);
    color: var(--text-light); min-height: 100vh; line-height: 1.6;
}

@keyframes fadeInUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin { 100% { transform: rotate(360deg); } }

/* ===== HEADER ===== */
.main-header { text-align: center; padding: 40px 20px; }
.header-content { max-width: 600px; margin: 0 auto; animation: fadeInUp 0.8s ease; }
.header-image { width: 140px; height: 140px; border-radius: 50%; border: 4px solid rgba(255,255,255,0.2); margin-bottom: 20px; object-fit: cover; }
.main-title { font-family: 'Cinzel', serif; font-size: 2.5em; font-weight: 600; background: linear-gradient(to right, #fff, #93c5fd); -webkit-background-clip: text; -webkit-text-fill-color: transparent; margin-bottom: 10px; }
.live-clock { font-size: 1.1em; color: #93c5fd; margin-bottom: 20px; }
.auth-section { margin-top: 20px; }
.user-welcome { background: rgba(255,255,255,0.1); backdrop-filter: blur(10px); padding: 15px 25px; border-radius: 12px; border: 1px solid rgba(255,255,255,0.2); }
.user-email { display: block; font-weight: 600; margin-bottom: 10px; color: #93c5fd; }
.user-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ===== CONTAINER ===== */
.container { max-width: 850px; margin: 0 auto; padding: 20px; animation: fadeInUp 0.8s ease 0.2s both; }

/* ===== FORM ===== */
.main-form { background: rgba(255,255,255,0.05); backdrop-filter: blur(10px); padding: 35px; border-radius: 16px; border: 1px solid rgba(255,255,255,0.1); margin-bottom: 30px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 500; color: #93c5fd; }
.form-select, .form-input { width: 100%; padding: 14px 18px; border: 2px solid rgba(255,255,255,0.1); border-radius: 12px; background: rgba(255,255,255,0.08); color: white; font-size: 1em; transition: all 0.3s ease; }
.form-select:focus, .form-input:focus { outline: none; border-color: var(--primary); background: rgba(255,255,255,0.12); }
.form-select option { background: #1e293b; color: white; }

/* ===== BUTTONS ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 24px; border: none; border-radius: 12px; font-size: 1em; font-weight: 600; cursor: pointer; transition: all 0.3s ease; text-decoration: none; font-family: inherit; }
.btn-primary { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%); color: white; width: 100%; padding: 16px; font-size: 1.1em; box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5); }
.btn-secondary { background: rgba(255,255,255,0.1); color: white; border: 1px solid rgba(255,255,255,0.2); }
.btn-secondary:hover { background: rgba(255,255,255,0.2); }
.btn-admin { background: linear-gradient(135deg, var(--accent) 0%, #d97706 100%); color: white; }
.btn-diagnostics { background: linear-gradient(135deg, var(--secondary) 0%, #059669 100%); color: white; }
.btn-google { background: white; color: #1f2937; border: 1px solid #e5e7eb; font-weight: 500; }
.btn-google:hover { background: #f9fafb; transform: translateY(-1px); }
.top-reset-bar { text-align: center; margin-bottom: 30px; animation: fadeInUp 0.5s ease; }
.btn-reset-large { background: linear-gradient(135deg, var(--accent) 0%, #d97706 100%); color: white; padding: 16px 32px; font-size: 1.1em; border-radius: 50px; box-shadow: 0 4px 15px rgba(245, 158, 11, 0.4); text-decoration: none; }
.btn-reset-large:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(245, 158, 11, 0.5); }
form.hidden { display: none !important; }

/* ===== LOADER ===== */
.overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(10, 22, 40, 0.95); backdrop-filter: blur(5px); display: flex; flex-direction: column; justify-content: center; align-items: center; z-index: 9999; }
.spinner-container { position: relative; width: 80px; height: 80px; margin-bottom: 30px; }
.spinner { width: 100%; height: 100%; border: 4px solid rgba(255,255,255,0.1); border-top: 4px solid var(--primary); border-radius: 50%; animation: spin 1s linear infinite; }
.spinner-ring { position: absolute; top: -10px; left: -10px; right: -10px; bottom: -10px; border: 2px solid transparent; border-top: 2px solid #93c5fd; border-radius: 50%; animation: spin 2s linear infinite reverse; opacity: 0.5; }
.loading-text { font-size: 1.3em; font-weight: 500; color: white; animation: pulse 2s ease-in-out infinite; margin-bottom: 10px; }
.loading-subtext { color: #94a3b8; font-size: 0.9em; }
.hidden { display: none !important; }

/* ===== RESULTS ===== */
.result-container { background: white; color: var(--text-dark); padding: 40px; border-radius: 16px; margin-top: 30px; box-shadow: 0 20px 40px rgba(0,0,0,0.3); animation: fadeInUp 0.6s ease; position: relative; max-width: 800px; margin-left: auto; margin-right: auto; }
.result-header { text-align: center; margin-bottom: 30px; padding-bottom: 20px; border-bottom: 2px solid #e5e7eb; }
.result-header h2 { font-family: 'Cinzel', serif; font-size: 2em; color: var(--bg-mid); margin-bottom: 10px; line-height: 1.3; }
.author-name { color: #6b7280; font-style: italic; font-size: 1.1em; }

/* ===== FORMATTED CONTENT ===== */
.content-body { line-height: 1.8; color: #374151; font-size: 1.05em; }
.content-body h3.section-header { 
    color: #1e40af; 
    margin-top: 28px; 
    margin-bottom: 16px; 
    font-family: 'Cinzel', serif; 
    font-size: 1.4em; 
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 8px;
}
.content-body h4.point-header { 
    color: #1e3a8a; 
    margin-top: 22px; 
    margin-bottom: 12px; 
    font-weight: 600; 
    font-size: 1.15em; 
}
.content-body ul.content-list { 
    margin: 16px 0 16px 24px; 
    padding-left: 20px;
}
.content-body ul.content-list li { 
    margin-bottom: 10px; 
    line-height: 1.7;
    position: relative;
}
.content-body ul.content-list li::marker { color: var(--primary); font-size: 1.2em; }
.content-body ul.content-list li strong { color: #1e40af; font-weight: 600; }
.content-body li.sub-point { margin-left: 20px; list-style-type: circle; color: #4b5563; }
.content-body p { margin-bottom: 16px; text-align: justify; }
.content-body p.scripture-quote { 
    font-style: italic; 
    color: #4b5563; 
    border-left: 3px solid var(--primary); 
    padding-left: 16px; 
    margin: 20px 0;
    background: #f8fafc;
    padding: 16px;
    border-radius: 0 8px 8px 0;
}

/* ===== GRADE BADGE ===== */
.grade-badge { position: absolute; top: 20px; right: 20px; background: linear-gradient(135deg, #10b981 0%, #059669 100%); color: white; padding: 15px 20px; border-radius: 12px; text-align: center; box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3); }
.grade-score { font-size: 0.75em; opacity: 0.9; margin-bottom: 4px; }
.grade-letter { font-size: 2em; font-weight: 700; line-height: 1; }
.grade-label { font-size: 0.7em; opacity: 0.9; margin-top: 4px; }
.grade-A { background: linear-gradient(135deg, #10b981 0%, #059669 100%); }
.grade-B { background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%); }
.grade-C { background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); }
.grade-D { background: linear-gradient(135deg, #f97316 0%, #ea580c 100%); }
.grade-F { background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%); }
.feedback-box { background: #fef3c7; border-left: 4px solid #f59e0b; padding: 20px; margin: 20px 0 25px 0; border-radius: 0 8px 8px 0; }
.feedback-box h4 { color: #92400e; margin-bottom: 12px; font-size: 1em; }
.feedback-box ul { margin: 0; padding-left: 20px; color: #92400e; font-size: 0.95em; }
.feedback-box li { margin-bottom: 6px; }

/* ===== VIDEO & ACTIONS ===== */
.video-section { margin-top: 35px; padding-top: 25px; border-top: 1px solid #e5e7eb; }
.video-section h3 { font-family: 'Cinzel', serif; color: #1e40af; margin-bottom: 15px; }
.video-wrapper { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; border-radius: 12px; box-shadow: 0 4px 6px rgba(0,0,0,0.1); }
.video-wrapper iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: none; }
.action-buttons { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 30px; padding-top: 20px; border-top: 1px solid #e5e7eb; }
.action-buttons .btn { flex: 1; min-width: 140px; padding: 14px 20px; }
.btn-print { background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%); color: white; }
.btn-copy { background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%); color: white; }
.btn-reset { background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%) !important; color: white; }
.btn:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.2); }

/* ===== FOOTER ===== */
.main-footer { margin-top: 60px; padding: 40px 20px; border-top: 1px solid rgba(255,255,255,0.1); }
.footer-content { max-width: 900px; margin: 0 auto; }
.disclaimer { text-align: left; font-size: 0.85em; line-height: 1.7; color: #94a3b8; margin-bottom: 20px; padding: 20px; background: rgba(255,255,255,0.03); border-radius: 12px; border-left: 3px solid var(--primary); }
.copyright { text-align: center; font-size: 0.9em; color: #64748b; }

/* ===== MOBILE ===== */
@media (max-width: 768px) {
    .main-title { font-size: 1.8em; }
    .form-row { grid-template-columns: 1fr; }
    .grade-badge { position: relative; top: auto; right: auto; margin-bottom: 20px; display: inline-block; }
    .action-buttons { flex-direction: column; }
    .action-buttons .btn { width: 100%; }
    .user-actions { flex-direction: column; align-items: center; }
    .result-container { padding: 25px 20px; }
    .content-body h3.section-header { font-size: 1.2em; }
    .content-body h4.point-header { font-size: 1em; }
}

/* ===== PRINT STYLES - OPTIMIZED ===== */
@media print {
    @page { margin: 0.75in; size: auto; }
    
    * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
    
    body { 
        background: white !important; 
        color: black !important; 
        font-family: 'Times New Roman', Georgia, serif;
        font-size: 11pt;
        line-height: 1.5;
    }
    
    /* Hide UI elements */
    .main-header, .main-form, .action-buttons, .video-section, 
    .main-footer, .auth-section, .top-reset-bar, .feedback-box,
    .grade-badge, .spinner-container { 
        display: none !important; 
    }
    
    /* Reset container */
    .container { 
        max-width: 100% !important; 
        padding: 0 !important; 
        margin: 0 !important;
        animation: none !important;
    }
    
    /* Result styling for print */
    .result-container { 
        box-shadow: none !important; 
        padding: 0 !important; 
        margin: 0 !important; 
        color: black !important; 
        background: white !important;
        border: none !important;
        max-width: 100% !important;
    }
    
    /* Header */
    .result-header { 
        border-bottom: 2pt solid #1e3a8a !important; 
        margin-bottom: 20pt !important; 
        padding-bottom: 10pt !important;
        text-align: center !important;
    }
    .result-header h2 { 
        color: #1e3a8a !important; 
        font-size: 18pt !important; 
        font-family: 'Times New Roman', serif !important;
        margin-bottom: 8pt !important;
    }
    .author-name { 
        font-size: 11pt !important; 
        color: #374151 !important; 
        font-style: italic !important;
    }
    
    /* Content - ensure clean paragraphs */
    .content-body { 
        font-size: 11pt !important; 
        line-height: 1.6 !important; 
        color: black !important;
    }
    
    .content-body h3.section-header { 
        color: #1e3a8a !important; 
        font-size: 14pt !important; 
        margin-top: 18pt !important;
        margin-bottom: 10pt !important;
        border-bottom: 1pt solid #ccc !important;
        font-family: 'Times New Roman', serif !important;
        text-transform: uppercase !important;
        letter-spacing: 0.5pt !important;
        page-break-after: avoid !important;
    }
    
    .content-body h4.point-header { 
        color: #1e40af !important; 
        font-size: 12pt !important; 
        margin-top: 12pt !important;
        margin-bottom: 6pt !important;
        font-weight: bold !important;
        page-break-after: avoid !important;
    }
    
    /* Lists */
    .content-body ul.content-list { 
        margin: 8pt 0 12pt 20pt !important;
        padding-left: 15pt !important;
    }
    .content-body ul.content-list li { 
        margin-bottom: 6pt !important;
        line-height: 1.5 !important;
    }
    .content-body li.sub-point { margin-left: 15pt !important; }
    
    /* Paragraphs */
    .content-body p { 
        margin-bottom: 10pt !important; 
        text-align: justify !important;
        orphans: 3; 
        widows: 3;
    }
    
    .content-body p.scripture-quote { 
        font-style: italic !important;
        border-left: 2pt solid #1e3a8a !important;
        padding-left: 12pt !important;
        margin: 12pt 0 !important;
        background: #f8fafc !important;
        color: #374151 !important;
    }
    
    /* Prevent awkward breaks */
    h2, h3, h4 { page-break-after: avoid !important; }
    ul, ol { page-break-inside: avoid !important; }
    li { page-break-inside: avoid !important; }
    p { page-break-inside: avoid !important; }
    
    /* Ensure links show text */
    a { text-decoration: none !important; color: black !important; }
}
.header-image {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    border: 4px solid rgba(255,255,255,0.2);
    box-shadow: 0 0 30px rgba(59, 130, 246, 0.4);
    margin-bottom: 20px;
    object-fit: cover;
    object-position: center 20%; /* Focus on face (upper portion) instead of center */
    object-position: center top; /* Alternative: focus on very top */
}

/* ===== LANGUAGE TOGGLE ===== */
.language-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 25px;
    padding: 15px;
    background: rgba(255,255,255,0.05);
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.1);
}

.toggle-label {
    font-weight: 500;
    color: #93c5fd;
    font-size: 0.95em;
}

.toggle-buttons {
    display: flex;
    gap: 8px;
}

.toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 45px;
    height: 40px;
    border-radius: 8px;
    background: rgba(255,255,255,0.1);
    color: white;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9em;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.toggle-btn:hover {
    background: rgba(255,255,255,0.2);
    transform: translateY(-2px);
}

.toggle-btn.active {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    border-color: #60a5fa;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

/* ===== TYPE TOGGLE (Lesson/Talk) ===== */
.type-toggle {
    display: flex;
    gap: 10px;
    background: rgba(255,255,255,0.05);
    padding: 4px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.1);
}

.type-option {
    flex: 1;
    cursor: pointer;
}

.type-option input {
    display: none;
}

.type-option span {
    display: block;
    padding: 12px 20px;
    text-align: center;
    border-radius: 8px;
    color: #94a3b8;
    font-weight: 500;
    transition: all 0.3s ease;
}

.type-option input:checked + span {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* ===== AUDIENCE SELECT ===== */
.audience-select {
    cursor: pointer;
}

/* ===== TIPS SECTION ===== */
.tips-section {
    margin-top: 40px;
    padding: 30px;
    background: rgba(255,255,255,0.03);
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.1);
}

.tips-title {
    font-family: 'Cinzel', serif;
    color: #fbbf24;
    text-align: center;
    margin-bottom: 25px;
    font-size: 1.4em;
}

.tips-grid, .mistakes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.mistakes-title {
    color: #f87171;
    font-size: 1.1em;
    margin-bottom: 15px;
    text-align: center;
    font-weight: 600;
}

.tip-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 15px;
    border-radius: 10px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    transition: transform 0.3s ease;
}

.tip-card:hover {
    transform: translateY(-3px);
}

.tip-card.positive {
    border-left: 4px solid #10b981;
}

.tip-card.negative {
    border-left: 4px solid #ef4444;
    background: rgba(239, 68, 68, 0.05);
}

.tip-icon {
    font-size: 1.2em;
    font-weight: bold;
    flex-shrink: 0;
}

.tip-card.positive .tip-icon {
    color: #10b981;
}

.tip-card.negative .tip-icon {
    color: #ef4444;
}

.tip-card p {
    margin: 0;
    font-size: 0.9em;
    line-height: 1.5;
    color: #e2e8f0;
}

/* ===== AUDIENCE TAG ===== */
.audience-tag {
    display: inline-block;
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 600;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== MOBILE ADJUSTMENTS ===== */
@media (max-width: 768px) {
    .language-toggle {
        flex-direction: column;
        gap: 10px;
    }
    
    .toggle-buttons {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .tips-grid, .mistakes-grid {
        grid-template-columns: 1fr;
    }
    
    .type-toggle {
        flex-direction: column;
    }
}

/* ===== LANGUAGE TOGGLE - CIRCULAR & VISIBLE ===== */
.language-toggle {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 30px;
    padding: 20px;
    background: rgba(255,255,255,0.08);
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.15);
}

.toggle-label {
    font-weight: 600;
    color: #e2e8f0;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.toggle-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #ffffff;
    color: #1e3a8a;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.85em;
    border: 3px solid transparent;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
    text-transform: uppercase;
}

.toggle-btn:hover {
    transform: scale(1.1) translateY(-3px);
    box-shadow: 0 6px 20px rgba(255,255,255,0.3);
    border-color: #60a5fa;
}

.toggle-btn.active {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: #1e3a8a;
    border-color: #ffffff;
    box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.3), 0 6px 20px rgba(251, 191, 36, 0.4);
    transform: scale(1.05);
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .toggle-btn {
        width: 45px;
        height: 45px;
        font-size: 0.8em;
    }
}