/**
 * Desenvolvido por B20 Conteúdo Digital
 * https://www.b20.com.br
 * Todos os direitos reservados
 */

/* CSS Variables */
:root {
    --primary-color: #2563EB;
    --secondary-color: #16A34A;
    --accent-color: #D97706; /* Darker amber for contrast in light mode */
    --surface-color: #F8FAFC;
    --text-color: #1E293B;
    --text-muted: #64748B;
    --primary-hover: color-mix(in srgb, var(--primary-color) 85%, black);
    --primary-light: color-mix(in srgb, var(--primary-color) 15%, white);
    --bg-color: #ffffff;
    --border-color: #E2E8F0;
    --border-radius: 12px;
    --spacing-unit: 8px;
    --spacing-unit: 8px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.02);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --font-family-sans: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-family-serif: 'Merriweather', Georgia, serif;
}

:root[data-theme="dark"] {
    --bg-color: #0F172A;
    --surface-color: #1E293B;
    --text-color: #F8FAFC;
    --text-muted: #94A3B8;
    --border-color: #334155;
    --accent-color: #FBBF24; /* Lighter amber for contrast in dark mode */
    --primary-light: rgba(37, 99, 235, 0.2); 
    --primary-hover: color-mix(in srgb, var(--primary-color) 70%, white);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg-color: #0F172A;
        --surface-color: #1E293B;
        --text-color: #F8FAFC;
        --text-muted: #94A3B8;
        --border-color: #334155;
        --accent-color: #FBBF24; /* Lighter amber for contrast in dark mode */
        --primary-light: rgba(37, 99, 235, 0.2); 
        --primary-hover: color-mix(in srgb, var(--primary-color) 70%, white);
        --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
        --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
        --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
    }
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: clamp(14px, 2.5vw, 18px);
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family-sans);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    padding-top: 70px;
    padding-bottom: env(safe-area-inset-bottom, 0);
    transition: var(--transition);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: calc(var(--spacing-unit) * 2);
}

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

p {
    margin-bottom: calc(var(--spacing-unit) * 2);
    color: var(--text-muted);
}

/* Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 calc(var(--spacing-unit) * 2);
}

/* Header */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: var(--bg-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 calc(var(--spacing-unit) * 2);
    box-shadow: var(--shadow-md);
    z-index: 1000;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
}

.header-logo {
    display: flex;
    align-items: center;
    gap: calc(var(--spacing-unit) * 1.5);
}

.header-logo img {
    height: 36px;
    width: auto;
    object-fit: contain;
}

.header-logo h1 {
    font-size: 1.5rem;
    color: var(--primary-color);
    margin: 0;
}

/* Desktop Navigation */
.desktop-nav {
    display: none;
    gap: calc(var(--spacing-unit) * 0.5); /* Reduced gap */
}

.desktop-nav .nav-link {
    display: flex;
    align-items: center;
    gap: calc(var(--spacing-unit) * 0.5); /* Reduced icon-text gap */
    padding: calc(var(--spacing-unit)) calc(var(--spacing-unit) * 1.5); /* Reduced padding */
    border-radius: var(--border-radius);
    color: var(--text-color);
    text-decoration: none;
    transition: var(--transition);
    font-weight: 500;
    font-size: 0.9rem; /* Reduced font size */
}

.desktop-nav .nav-link:hover,
.desktop-nav .nav-link.active {
    background: var(--primary-color);
    color: white;
    transform: translateY(-1px);
}

.header-actions {
    display: flex;
    gap: calc(var(--spacing-unit));
}

.btn-icon {
    width: 44px;
    height: 44px;
    border: none;
    background: var(--surface-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-color);
}

.btn-icon:hover {
    background: var(--primary-color);
    color: white;
    transform: scale(1.05);
}

/* Bottom Navigation (Mobile) */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: var(--bg-color);
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom, 0);
    border-top: 1px solid var(--border-color);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: calc(var(--spacing-unit)) calc(var(--spacing-unit) * 2);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 11px;
    font-weight: 500;
    transition: var(--transition);
    min-width: 64px;
}

.nav-item i {
    font-size: 20px;
    transition: transform 0.2s ease;
}

.nav-item.active {
    color: var(--primary-color);
}

.nav-item.active i {
    transform: scale(1.15);
}

.nav-item-fab {
    width: 56px;
    height: 56px;
    background: var(--primary-color);
    border-radius: 50%;
    margin-top: -28px;
    color: white !important;
    box-shadow: var(--shadow-lg);
}

.nav-item-fab i {
    font-size: 24px;
}

.nav-item-fab span {
    display: none;
}

/* Main Content */
main {
    min-height: calc(100vh - 140px);
    padding: calc(var(--spacing-unit) * 3) 0;
}

.section {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.section.active {
    display: block;
}

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

/* Welcome Banner */
.welcome-banner {
    position: relative;
    background: linear-gradient(135deg, var(--primary-color) 0%, color-mix(in srgb, var(--primary-color) 60%, var(--secondary-color)) 100%);
    color: white;
    padding: calc(var(--spacing-unit) * 6) calc(var(--spacing-unit) * 4);
    border-radius: calc(var(--border-radius) * 1.5);
    text-align: left;
    margin-bottom: calc(var(--spacing-unit) * 5);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.welcome-banner::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0) 70%);
    border-radius: 50%;
    pointer-events: none;
}

.welcome-banner h2 {
    font-size: clamp(1.75rem, 5vw, 2.5rem);
    font-weight: 700;
    margin-bottom: calc(var(--spacing-unit) * 1.5);
    line-height: 1.2;
    z-index: 1;
}

.welcome-banner p {
    color: rgba(255, 255, 255, 0.9);
    font-size: clamp(1rem, 3vw, 1.15rem);
    max-width: 600px;
    margin-bottom: 0;
    z-index: 1;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: calc(var(--spacing-unit) * 3);
    margin-bottom: calc(var(--spacing-unit) * 4);
}

.stat-card {
    background: var(--surface-color);
    padding: calc(var(--spacing-unit) * 3);
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    gap: calc(var(--spacing-unit) * 2);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    border: 1px solid var(--border-color);
}

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

.stat-icon {
    font-size: 2rem;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--primary-color) 15%, transparent);
    color: var(--primary-color);
    border-radius: 50%;
}

.stat-content h3 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0;
}

.stat-content p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Section Header */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: calc(var(--spacing-unit) * 4);
    flex-wrap: wrap;
    gap: calc(var(--spacing-unit) * 2);
}

.section-header h2 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: calc(var(--spacing-unit) * 2);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: calc(var(--spacing-unit));
    padding: calc(var(--spacing-unit) * 1.5) calc(var(--spacing-unit) * 3);
    border: none;
    border-radius: var(--border-radius);
    font-family: inherit;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition);
    min-height: 44px;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

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

.btn-danger {
    background: #EF4444;
    color: white;
}

.btn-danger:hover {
    background: #DC2626;
}

/* Form Elements */
.form-group {
    margin-bottom: calc(var(--spacing-unit) * 3);
}

.form-label {
    display: block;
    margin-bottom: calc(var(--spacing-unit));
    font-weight: 500;
    color: var(--text-color);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: calc(var(--spacing-unit) * 1.5);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-family: inherit;
    font-size: 1rem;
    background: var(--bg-color);
    color: var(--text-color);
    transition: var(--transition);
}

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

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

/* Cards */
.card {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    padding: calc(var(--spacing-unit) * 3);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: var(--transition);
    will-change: transform, box-shadow;
}

.card:hover {
    box-shadow: var(--shadow-lg);
    border-color: color-mix(in srgb, var(--primary-color) 50%, var(--border-color));
    transform: translateY(-4px);
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: calc(var(--spacing-unit) * 6);
    color: var(--text-muted);
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: calc(var(--spacing-unit) * 3);
    opacity: 0.5;
}

.empty-state h3 {
    margin-bottom: calc(var(--spacing-unit) * 2);
    color: var(--text-color);
}

/* Grids */
.disciples-grid,
.notes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: calc(var(--spacing-unit) * 3);
}

/* Dashboard Sections */
.dashboard-sections {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: calc(var(--spacing-unit) * 4);
}

.recent-disciples,
.upcoming-meetings {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    padding: calc(var(--spacing-unit) * 3);
    border: 1px solid var(--border-color);
}

.recent-disciples h3,
.upcoming-meetings h3 {
    display: flex;
    align-items: center;
    gap: calc(var(--spacing-unit) * 2);
    margin-bottom: calc(var(--spacing-unit) * 3);
    color: var(--text-color);
}

/* Lessons Timeline */
.lessons-timeline {
    position: relative;
}

.lesson-item {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    padding: calc(var(--spacing-unit) * 3);
    margin-bottom: calc(var(--spacing-unit) * 3);
    border: 1px solid var(--border-color);
    position: relative;
}

.lesson-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: calc(var(--spacing-unit) * 2);
}

.lesson-number {
    background: var(--primary-color);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
}

.lesson-content h4 {
    margin: 0 0 calc(var(--spacing-unit)) 0;
    color: var(--text-color);
}

.lesson-verse {
    background: var(--primary-light);
    padding: calc(var(--spacing-unit) * 2);
    border-radius: var(--border-radius);
    font-family: var(--font-family-serif);
    font-style: italic;
    margin: calc(var(--spacing-unit) * 2) 0;
    border-left: 4px solid var(--primary-color);
}

/* Progress Charts */
.chart-container {
    background: var(--surface-color);
    padding: calc(var(--spacing-unit) * 3);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    margin-bottom: calc(var(--spacing-unit) * 3);
}

.progress-overview {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: calc(var(--spacing-unit) * 4);
}

/* Filters */
.lesson-filters,
.notes-filters {
    display: flex;
    gap: calc(var(--spacing-unit) * 2);
    margin-bottom: calc(var(--spacing-unit) * 3);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: calc(var(--spacing-unit) * 2);
}

.modal {
    background: var(--bg-color);
    border-radius: var(--border-radius);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: calc(var(--spacing-unit) * 3);
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition);
}

.btn-close:hover {
    color: var(--text-color);
}

.modal-body {
    padding: calc(var(--spacing-unit) * 3);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 90px;
    right: calc(var(--spacing-unit) * 2);
    z-index: 3000;
}

.toast {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: calc(var(--spacing-unit) * 2);
    margin-bottom: calc(var(--spacing-unit));
    box-shadow: var(--shadow-md);
    animation: slideIn 0.3s ease-out;
    max-width: 300px;
}

.toast.success {
    border-left: 4px solid var(--secondary-color);
}

.toast.error {
    border-left: 4px solid #EF4444;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* FAQ Section */
.faq-section {
    background: var(--surface-color);
    padding: calc(var(--spacing-unit) * 6) 0;
    margin-top: calc(var(--spacing-unit) * 6);
    border-top: 1px solid var(--border-color);
}

.faq-container {
    max-width: 800px;
    margin: 0 auto;
}

.faq-item {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    margin-bottom: calc(var(--spacing-unit) * 2);
    overflow: hidden;
}

.faq-question {
    width: 100%;
    padding: calc(var(--spacing-unit) * 3);
    background: var(--bg-color);
    border: none;
    text-align: left;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition);
    color: var(--text-color);
}

.faq-question:hover {
    background: var(--surface-color);
}

.faq-icon {
    font-size: 1.2rem;
    transition: transform 0.3s ease;
}

.faq-question[aria-expanded="true"] .faq-icon {
    transform: rotate(45deg);
}

.faq-answer {
    padding: 0 calc(var(--spacing-unit) * 3) calc(var(--spacing-unit) * 3);
    background: var(--bg-color);
    animation: fadeIn 0.3s ease-in-out;
    color: var(--text-muted);
}

/* Footer */
.app-footer {
    background: var(--surface-color);
    border-top: 1px solid var(--border-color);
    padding: calc(var(--spacing-unit) * 4) 0;
    text-align: center;
    margin-top: calc(var(--spacing-unit) * 6);
}

.app-footer p {
    margin: calc(var(--spacing-unit)) 0;
    color: var(--text-muted);
}

.b20-link {
    color: var(--primary-color);
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition);
}

.b20-link:hover {
    text-decoration: underline;
    transform: scale(1.05);
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: calc(var(--spacing-unit) * 3);
    margin: calc(var(--spacing-unit) * 2) 0;
    flex-wrap: wrap;
}

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: var(--transition);
}

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

.app-footer p {
    font-size: 0.9rem;
    margin: calc(var(--spacing-unit)) 0;
    color: var(--text-muted);
}

.b20-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: color-mix(in srgb, var(--primary-color) 10%, transparent);
    color: var(--primary-color);
    padding: 8px 16px;
    border-radius: 20px;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    transition: var(--transition);
    margin-top: calc(var(--spacing-unit));
    border: 1px solid color-mix(in srgb, var(--primary-color) 20%, transparent);
}

.b20-button:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

/* Responsive Design */
@media (max-width: 899px) {
    body {
        padding-bottom: 80px;
    }
    
    .desktop-nav {
        display: none !important;
    }
    
    .dashboard-sections {
        grid-template-columns: 1fr;
    }
    
    .progress-overview {
        grid-template-columns: 1fr;
    }
    
    .lesson-filters,
    .notes-filters {
        flex-direction: column;
    }
    
    .section-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    /* Prevenir colisão de modais com bottom-nav e banner de anúncio */
    .modal-overlay {
        padding-top: calc(var(--spacing-unit) * 2);
        padding-bottom: calc(130px + env(safe-area-inset-bottom, 0)); /* Espaço para nav (70px) + anúncio (50px) */
        align-items: flex-end; /* Posiciona o modal ligeiramente acima da área reservada */
    }
    
    .modal {
        max-height: calc(100vh - 160px - env(safe-area-inset-bottom, 0)); /* Recalcula a altura pra permitir rolagem interna sem vazar */
    }
}

@media (min-width: 900px) {
    body {
        padding-bottom: 0;
    }
    
    .desktop-nav {
        display: flex;
    }
    
    .bottom-nav {
        display: none !important;
    }
    
    .modal {
        max-width: 700px;
    }
}

@media (min-width: 1024px) {
    .container {
        padding: 0 calc(var(--spacing-unit) * 3);
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Utility Classes */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

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

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: calc(var(--spacing-unit)); }
.mb-2 { margin-bottom: calc(var(--spacing-unit) * 2); }
.mb-3 { margin-bottom: calc(var(--spacing-unit) * 3); }
.hidden, [hidden] { display: none !important; }
.visible { display: block !important; }

/* Print Styles */
@media print {
    .app-header,
    .bottom-nav,
    .btn,
    .modal-overlay {
        display: none !important;
    }
    
    body {
        padding: 0;
        background: white;
        color: black;
    }
    
    .section {
        display: block !important;
    }
}
