﻿/**
 * Astroracolo Planetary Widget CSS
 * File: static/css/planetary-widget.css
 */

/* === BASE WIDGET === */
.planetary-widget {
    background: linear-gradient(135deg, #1a1040 0%, #2c1b5a 50%, #3d2a72 100%);
    border-radius: 20px;
    padding: 1.5rem;
    color: white;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
    min-height: 400px;
    font-family: 'Montserrat', sans-serif;
}

.planetary-widget::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
        radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        radial-gradient(circle at 40% 60%, rgba(255, 158, 68, 0.02) 2px, transparent 2px);
    background-size: 40px 40px, 60px 60px, 80px 80px;
    animation: twinkleBackground 15s ease-in-out infinite;
    pointer-events: none;
    z-index: 0;
}

@keyframes twinkleBackground {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* === HEADER === */
.widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    position: relative;
    z-index: 2;
}

.widget-title {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #e1d5f7;
}

.widget-icon {
    font-size: 1.4rem;
}

.widget-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    opacity: 0.8;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4caf50;
    animation: pulse 2s ease-in-out infinite;
}

.status-indicator.status-loading {
    background: #ff9800;
    animation: spin 1s linear infinite;
}

.status-indicator.status-active {
    background: #4caf50;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* === DISPLAY PRINCIPALE === */
.planetary-display {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 1.5rem;
    min-height: 300px;
}

.planetary-wheel {
    position: relative;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.05) 0%, transparent 70%);
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 
        inset 0 0 30px rgba(255, 255, 255, 0.1),
        0 0 50px rgba(107, 63, 160, 0.3);
}

/* === ZODIACO === */
.zodiac-ring {
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border-radius: 50%;
}

.zodiac-segments {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

.zodiac-segment {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50%;
    height: 50%;
    transform-origin: left bottom;
    pointer-events: none;
}

.segment-label {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: 0.7rem;
    opacity: 0.6;
    transition: opacity 0.3s ease;
}

.zodiac-segment:hover .segment-label {
    opacity: 1;
}

.sign-symbol {
    font-size: 1rem;
    color: var(--sign-color, #fff);
    filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.5));
}

.sign-name {
    font-size: 0.9rem;
    text-transform: capitalize;
    color: rgba(10, 10, 10, 0.8);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* === CENTRO SISTEMA === */
.system-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 10;
}

.earth-symbol {
    font-size: 2rem;
    margin-bottom: 0.25rem;
    animation: rotate 60s linear infinite;
}

@keyframes rotate {
    to { transform: rotate(360deg); }
}

.center-label {
    font-size: 0.7rem;
    font-weight: 500;
    opacity: 0.8;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* === PIANETI === */
.planets-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.planet-marker {
    position: absolute;
    top: 50%;
    left: 50%;
    width: var(--planet-size, 32px);
    height: var(--planet-size, 32px);
    margin: calc(var(--planet-size, 32px) / -2) 0 0 calc(var(--planet-size, 32px) / -2);
    cursor: pointer;
    z-index: 5;
    opacity: 0;
    transform: scale(0);
    transition: all 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.planet-marker.planet-visible {
    opacity: 1;
    transform: scale(1);
}

.planet-body {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--planet-color);
    box-shadow: 
        0 0 20px rgba(0, 0, 0, 0.3),
        inset 0 2px 4px rgba(255, 255, 255, 0.2),
        0 0 15px var(--planet-color);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.planet-marker:hover .planet-body {
    transform: scale(1.2);
    box-shadow: 
        0 0 30px rgba(0, 0, 0, 0.4),
        inset 0 2px 4px rgba(255, 255, 255, 0.3),
        0 0 25px var(--planet-color);
}

.planet-symbol {
    font-size: calc(var(--planet-size, 32px) * 0.5);
    font-weight: bold;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    z-index: 2;
}

.planet-ring {
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    animation: ringRotate 10s linear infinite;
}

@keyframes ringRotate {
    to { transform: rotate(360deg); }
}

.retrograde-indicator {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff5252;
    color: white;
    border-radius: 50%;
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    font-weight: bold;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    z-index: 3;
}

/* === TOOLTIP === */
.planet-tooltip {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.95);
    color: white;
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 0.8rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 20;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.planet-marker:hover .planet-tooltip {
    opacity: 1;
}

.tooltip-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.retro-badge {
    background: #ff5252;
    color: white;
    padding: 1px 4px;
    border-radius: 4px;
    font-size: 0.6rem;
    font-weight: bold;
}

.tooltip-body {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.tooltip-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

.tooltip-row span:first-child {
    opacity: 0.8;
}

.tooltip-row span:last-child {
    font-weight: 600;
}

/* === ASPETTI SVG === */
.aspects-overlay {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 1;
}

/* === LOADING === */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 18px;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.loading-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.cosmic-loader {
    position: relative;
    width: 60px;
    height: 60px;
    margin-bottom: 1rem;
}

.loader-orbit {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: #ff9e44;
    border-radius: 50%;
    animation: spin 2s linear infinite;
}

.loader-planet {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    background: #6b3fa0;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(107, 63, 160, 0.6);
    animation: pulse 1.5s ease-in-out infinite;
}

.loading-overlay p {
    font-size: 0.9rem;
    opacity: 0.9;
    margin: 0;
}

/* === ERRORE === */
.error-display {
    text-align: center;
    padding: 1rem;
}

.error-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.error-display p {
    margin: 0.5rem 0;
    font-weight: 600;
}

.error-display small {
    display: block;
    opacity: 0.7;
    margin-bottom: 1rem;
}

.retry-btn {
    background: #ff9e44;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.3s ease;
}

.retry-btn:hover {
    background: #e67e1a;
}

/* === INFO WIDGET === */
.widget-info {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    position: relative;
    z-index: 2;
}

.planetary-highlights {
    flex: 1;
}

.highlight-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 0.75rem;
}

.highlight-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 0.75rem 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    transition: background-color 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.highlight-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.highlight-item.highlight-warning {
    background: rgba(255, 152, 0, 0.1);
    border-color: rgba(255, 152, 0, 0.3);
}

.highlight-icon {
    font-size: 1.2rem;
    margin-bottom: 0.25rem;
}

.highlight-title {
    font-size: 0.7rem;
    opacity: 0.8;
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.highlight-value {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.1rem;
    color: #e1d5f7;
}

.highlight-detail {
    font-size: 0.6rem;
    opacity: 0.7;
}

/* === AZIONI === */
.widget-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.refresh-btn,
.fullscreen-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.refresh-btn:hover,
.fullscreen-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.refresh-btn:active,
.fullscreen-btn:active {
    transform: translateY(0);
}

/* === TEMI === */
.planetary-widget[data-theme="minimal"] {
    background: #f8f9fa;
    color: #333;
    border: 1px solid #e9ecef;
}

.planetary-widget[data-theme="minimal"]::before {
    display: none;
}

.planetary-widget[data-theme="elegant"] {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .planetary-widget {
        padding: 1rem;
        min-height: 350px;
    }
    
    .widget-header {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
        margin-bottom: 1rem;
    }
    
    .highlight-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }
    
    .highlight-item {
        padding: 0.5rem 0.25rem;
    }
    
    .highlight-title,
    .highlight-value {
        font-size: 0.7rem;
    }
    
    .widget-info {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .widget-actions {
        flex-direction: row;
        justify-content: center;
    }
    
    .planet-tooltip {
        font-size: 0.7rem;
        padding: 0.5rem;
    }
}

@media (max-width: 480px) {
    .highlight-grid {
        grid-template-columns: 1fr;
    }
    
    .planetary-wheel {
        width: 250px !important;
        height: 250px !important;
    }
    
    .zodiac-segment .segment-label {
        font-size: 0.6rem;
    }
    
    .sign-symbol {
        font-size: 0.8rem;
    }
}

/* File: static/css/planetary-widget.css
   Aggiungi o modifica questi stili per risolvere il problema dei tooltip */

/* ===== FIX TOOLTIP OVERLAP ===== */

/* Assicura che i tooltip abbiano z-index alto */
.planet-tooltip {
    position: absolute;
    bottom: 70px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.95);
    color: white;
    padding: 1rem;
    border-radius: 12px;
    font-size: 0.9rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 9999; /* Z-index molto alto */
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    
    /* Impedisce che il tooltip vada fuori schermo */
    max-width: 200px;
    word-wrap: break-word;
}

/* Tooltip visibile al hover con animazione migliorata */
.planet-marker:hover .planet-tooltip {
    opacity: 1;
    transform: translateX(-50%) translateY(-10px);
    z-index: 10000; /* Z-index ancora più alto quando visibile */
}

/* Assicura che i pianeti abbiano z-index appropriati ma inferiori ai tooltip */
.planet-marker {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 60px;
    height: 60px;
    margin: -30px 0 0 -30px;
    transform-origin: 200px center;
    cursor: pointer;
    z-index: 100; /* Z-index più basso dei tooltip */
    transition: z-index 0.1s ease;
}

/* Quando un pianeta è in hover, aumenta il suo z-index ma rimane sotto i tooltip */
.planet-marker:hover {
    z-index: 500;
}

/* Sistema di tooltip intelligente - posizionamento dinamico */
.planet-marker.tooltip-top .planet-tooltip {
    bottom: 70px;
    top: auto;
}

.planet-marker.tooltip-bottom .planet-tooltip {
    top: 70px;
    bottom: auto;
}

.planet-marker.tooltip-left .planet-tooltip {
    left: -210px;
    right: auto;
    transform: translateY(-50%);
    top: 50%;
    bottom: auto;
}

.planet-marker.tooltip-right .planet-tooltip {
    right: -210px;
    left: auto;
    transform: translateY(-50%);
    top: 50%;
    bottom: auto;
}

/* Stili per tooltip compatti quando ci sono collisioni */
.planet-tooltip.compact {
    padding: 0.5rem;
    font-size: 0.8rem;
}

.planet-tooltip.compact .tooltip-header {
    margin-bottom: 0.25rem;
}

.planet-tooltip.compact .tooltip-body {
    display: none; /* Nasconde dettagli in modalità compatta */
}

/* Indicatore di collisione */
.planet-marker.collision-detected {
    animation: pulse-collision 1s infinite;
}

@keyframes pulse-collision {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 255, 0, 0.4); }
    50% { box-shadow: 0 0 0 5px rgba(255, 255, 0, 0); }
}

/* ===== MIGLIORAMENTI RESPONSIVE ===== */

/* Tooltip più piccoli su schermi mobili */
@media (max-width: 768px) {
    .planet-tooltip {
        font-size: 0.8rem;
        padding: 0.75rem;
        max-width: 150px;
        bottom: 60px;
    }
    
    .planet-marker {
        width: 50px;
        height: 50px;
        margin: -25px 0 0 -25px;
        transform-origin: 140px center;
    }
    
    .planet-tooltip.compact {
        padding: 0.4rem;
        font-size: 0.7rem;
    }
}

/* ===== HIGHLIGHT IMPROVEMENTS ===== */

/* Migliora gli highlights per evitare sovrapposizioni */
.highlight-item {
    position: relative;
    z-index: 50;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 0.5rem;
    transition: all 0.3s ease;
}

.highlight-item:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
    z-index: 60;
}

.highlight-item.highlight-warning {
    border-color: rgba(255, 193, 7, 0.5);
    background: rgba(255, 193, 7, 0.1);
}

/* ===== WIDGET ACTIONS IMPROVEMENTS ===== */

/* Pulsanti widget con z-index appropriato */
.widget-actions {
    position: relative;
    z-index: 200;
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 1rem;
}

.refresh-btn,
.fullscreen-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.refresh-btn:hover,
.fullscreen-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

/* ===== LOADING OVERLAY IMPROVEMENTS ===== */

/* Loading overlay con z-index corretto */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 16px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 9000; /* Più alto dei pianeti ma più basso dei tooltip */
    backdrop-filter: blur(10px);
}

.loading-overlay.visible {
    opacity: 1;
    visibility: visible;
}

/* ===== ASPECTS OVERLAY ===== */

/* SVG degli aspetti con z-index appropriato */
.aspects-overlay {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 10; /* Più basso di tutto per stare dietro */
}

/* ===== ZODIAC RING ===== */

/* Anello zodiacale con z-index base */
.zodiac-ring {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    bottom: 10px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
    z-index: 1; /* Molto basso */
}

.zodiac-segments {
    width: 100%;
    height: 100%;
    position: relative;
}

.zodiac-segment {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50%;
    height: 2px;
    transform-origin: left center;
    z-index: 2;
}

/* ===== SYSTEM CENTER ===== */

/* Centro del sistema con z-index intermedio */
.system-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 50;
}

.earth-symbol {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.center-label {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 500;
}

/* ===== WIDGET CONTAINER ===== */

/* Container principale con overflow controllato */
.planetary-widget {
    position: relative;
    background: linear-gradient(135deg, rgba(44, 27, 90, 0.95), rgba(107, 63, 160, 0.95));
    border-radius: 20px;
    padding: 1.5rem;
    color: white;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: visible; /* Permette ai tooltip di uscire */
    z-index: 1;
}

.planetary-display {
    position: relative;
    overflow: visible; /* Importante per i tooltip */
}

.planetary-wheel {
    position: relative;
    margin: 0 auto;
    overflow: visible; /* Importante per i tooltip */
}

/* ===== PERFORMANCE OPTIMIZATIONS ===== */

/* Ottimizzazioni per le performance */
.planet-marker,
.planet-tooltip,
.highlight-item {
    will-change: transform, opacity;
    transform: translateZ(0); /* Forza accelerazione hardware */
}

/* Riduce il repainting durante le animazioni */
.planet-marker:hover .planet-symbol {
    transform: scale(1.3) translateZ(0);
}

/* ===== ACCESSIBILITY ===== */

/* Miglioramenti per l'accessibilità */
.planet-marker:focus {
    outline: 2px solid #ff9e44;
    outline-offset: 2px;
}

.planet-marker:focus .planet-tooltip {
    opacity: 1;
    transform: translateX(-50%) translateY(-10px);
}

/* Riduce animazioni per utenti che preferiscono meno movimento */
@media (prefers-reduced-motion: reduce) {
    .planet-marker,
    .planet-tooltip,
    .loading-overlay {
        transition: none;
        animation: none;
    }
}
