File size: 8,187 Bytes
cdcd73e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
import streamlit as st
import datetime
from utils import (
    download_ephe_files, get_location_data, calculate_julian_day,
    get_planet_positions, calculate_houses
)
from chart_generator import create_wheel_chart, PLANET_NAMES

# Zodiac sign symbols and names
ZODIAC_SYMBOLS = {
    "Aries": "♈",
    "Taurus": "♉",
    "Gemini": "♊",
    "Cancer": "♋",
    "Leo": "♌",
    "Virgo": "♍",
    "Libra": "♎",
    "Scorpio": "♏",
    "Sagittarius": "♐",
    "Capricorn": "♑",
    "Aquarius": "♒",
    "Pisces": "♓"
}

def calcular_signo(longitude):
    signo = ""
    if 0 <= longitude < 30:
        signo = "Aries"
    elif 30 <= longitude < 60:
        signo = "Taurus"
    elif 60 <= longitude < 90:
        signo = "Gemini"
    elif 90 <= longitude < 120:
        signo = "Cancer"
    elif 120 <= longitude < 150:
        signo = "Leo"
    elif 150 <= longitude < 180:
        signo = "Virgo"
    elif 180 <= longitude < 210:
        signo = "Libra"
    elif 210 <= longitude < 240:
        signo = "Scorpio"
    elif 240 <= longitude < 270:
        signo = "Sagittarius"
    elif 270 <= longitude < 300:
        signo = "Capricorn"
    elif 300 <= longitude < 330:
        signo = "Aquarius"
    elif 330 <= longitude < 360:
        signo = "Pisces"
    return signo

# Configuração da página
st.set_page_config(
    page_title="Visualizador de Mapa Astral",
    page_icon="🌟",
    layout="centered"
)

# Carregar CSS personalizado
with open("styles/custom.css") as f:
    st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)

# Inicializar arquivos de efemérides
if not download_ephe_files():
    st.error("Falha ao inicializar dados astronômicos. Por favor, tente novamente.")
    st.stop()

# Título e descrição
st.markdown("""
<div style='text-align: center; padding: 2rem 0;'>
    <h1 class='glow-text'>✨ Visualizador de Mapa Astral ✨</h1>
</div>
""", unsafe_allow_html=True)

st.markdown("""
<div class='cosmic-card'>
    <p style='text-align: center; font-size: 1.2rem;'>
        Descubra seu mapa astral através deste visualizador interativo.<br>
        Insira seus dados de nascimento abaixo para revelar as posições celestiais no momento do seu nascimento.
    </p>
</div>
""", unsafe_allow_html=True)

# Formulário de entrada
st.markdown("<div class='cosmic-card'>", unsafe_allow_html=True)
if st.viewport_width < 768:
    # Layout em uma coluna para dispositivos móveis
    birth_date = st.date_input(
        "Data de Nascimento",
        min_value=datetime.date(1900, 1, 1),
        max_value=datetime.date.today(),
        help="Selecione sua data de nascimento"
    )
    
    birth_time = st.time_input(
        "Hora de Nascimento",
        help="Insira o horário mais preciso possível"
    )
    
    birth_place = st.text_input(
        "Local de Nascimento",
        placeholder="Ex: São Paulo, Brasil",
        help="Digite a cidade e país de nascimento"
    )
else:
    # Layout em três colunas para desktop
    col1, col2, col3 = st.columns(3)
    with col1:
        birth_date = st.date_input(
            "Data de Nascimento",
            min_value=datetime.date(1900, 1, 1),
            max_value=datetime.date.today(),
            help="Selecione sua data de nascimento"
        )
    
    with col2:
        birth_time = st.time_input(
            "Hora de Nascimento",
            help="Insira o horário mais preciso possível"
        )
    
    with col3:
        birth_place = st.text_input(
            "Local de Nascimento",
            placeholder="Ex: São Paulo, Brasil",
            help="Digite a cidade e país de nascimento"
        )

if st.button("✨ Gerar Mapa Astral ✨", key="generate"):
    try:
        with st.spinner("🌟 Calculando posições celestiais..."):
            location_data = get_location_data(birth_place)
            jd = calculate_julian_day(birth_date, birth_time, location_data['timezone'])
            planet_positions = get_planet_positions(jd)
            houses = calculate_houses(
                jd,
                location_data['latitude'],
                location_data['longitude']
            )

            # Calcular signo solar
            signo_solar = calcular_signo(planet_positions['Sun']['longitude'])
            simbolo_solar = ZODIAC_SYMBOLS[signo_solar]

            st.markdown("<div style='text-align: center;'><h2 class='glow-text'>Seu Mapa Astral</h2></div>", unsafe_allow_html=True)

            # Ajuste do layout responsivo para o resultado
            if st.viewport_width < 768:
                # Layout em uma coluna para mobile
                st.markdown(f"""
                <div class='cosmic-card signo-solar-card'>
                    <div class='signo-symbol'>{simbolo_solar}</div>
                    <h2 class='signo-nome'>{signo_solar}</h2>
                    <p class='signo-grau'>{planet_positions['Sun']['longitude']:.2f}°</p>
                </div>
                """, unsafe_allow_html=True)
                
                st.markdown("<div class='chart-container'>", unsafe_allow_html=True)
                fig = create_wheel_chart(planet_positions, houses)
                st.plotly_chart(fig, use_container_width=True)
                st.markdown("</div>", unsafe_allow_html=True)
                
                st.markdown("<div class='cosmic-card'>", unsafe_allow_html=True)
                st.markdown("<h3>🌍 Posições Planetárias</h3>", unsafe_allow_html=True)
                for planet, data in planet_positions.items():
                    planet_name = PLANET_NAMES.get(planet, planet)  # Usar nome traduzido
                    st.write(f"✨ {planet_name}: {data['longitude']:.2f}°")

                st.markdown("<h3>🏠 Cúspides das Casas</h3>", unsafe_allow_html=True)
                for i, cusp in enumerate(houses['cusps'], 1):
                    st.write(f"Casa {i}: {cusp:.2f}°")
                st.markdown("</div>", unsafe_allow_html=True)

                st.markdown("<div class='cosmic-card'>", unsafe_allow_html=True)
                st.markdown("<h3>🌟 Pontos Importantes</h3>", unsafe_allow_html=True)
                st.write(f"⭐ Ascendente: {houses['ascendant']:.2f}°")
                st.write(f"🌠 Meio do Céu: {houses['mc']:.2f}°")
                st.markdown("</div>", unsafe_allow_html=True)
            else:
                # Layout em duas colunas para desktop
                chart_col, info_col = st.columns([2, 1])

                with chart_col:
                    st.markdown("<div class='chart-container'>", unsafe_allow_html=True)
                    fig = create_wheel_chart(planet_positions, houses)
                    st.plotly_chart(fig, use_container_width=True)
                    st.markdown("</div>", unsafe_allow_html=True)

                with info_col:
                    st.markdown("<div class='cosmic-card'>", unsafe_allow_html=True)
                    st.markdown("<h3>🌍 Posições Planetárias</h3>", unsafe_allow_html=True)
                    for planet, data in planet_positions.items():
                        planet_name = PLANET_NAMES.get(planet, planet)  # Usar nome traduzido
                        st.write(f"✨ {planet_name}: {data['longitude']:.2f}°")

                    st.markdown("<h3>🏠 Cúspides das Casas</h3>", unsafe_allow_html=True)
                    for i, cusp in enumerate(houses['cusps'], 1):
                        st.write(f"Casa {i}: {cusp:.2f}°")
                    st.markdown("</div>", unsafe_allow_html=True)

                    st.markdown("<div class='cosmic-card'>", unsafe_allow_html=True)
                    st.markdown("<h3>🌟 Pontos Importantes</h3>", unsafe_allow_html=True)
                    st.write(f"⭐ Ascendente: {houses['ascendant']:.2f}°")
                    st.write(f"🌠 Meio do Céu: {houses['mc']:.2f}°")
                    st.markdown("</div>", unsafe_allow_html=True)

    except Exception as e:
        st.error(f"Ocorreu um erro: {str(e)}")

# Rodapé
st.markdown("""
<div class='cosmic-card' style='text-align: center; margin-top: 2rem;'>
    <p>Feito com ✨ e energia cósmica</p>
</div>
""", unsafe_allow_html=True)