/* ========================================
   Typhoon Chart Styles
   ======================================== */

.typhoon-chart {
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.95) 0%, 
        rgba(248, 250, 252, 0.95) 100%);
    padding: 60px 0;
    position: relative;
    overflow: hidden;
}

.typhoon-chart::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(253deg, 
        rgba(144, 13, 13, 0.05) 9.49%, 
        rgba(161, 9, 9, 0.04) 46.22%, 
        rgba(162, 9, 9, 0.04) 71.48%, 
        rgba(170, 6, 6, 0.03) 100%);
    pointer-events: none;
}

.typhoon-chart-container {
    background: rgba(255, 255, 255, 0.98);
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 1;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.chart-title {
    font-size: 24px;
    font-weight: 700;
    color: #1a202c;
    margin-bottom: 30px;
    text-align: center;
    font-family: 'Noto Sans TC', sans-serif;
}

.canvas-wrapper {
    position: relative;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 30px;
    min-height: 550px;
}

#typhoonCanvas {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

#svgContainer {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
    z-index: 10;
}

.legend-container {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
    padding: 25px;
    background: rgba(248, 250, 252, 0.8);
    border-radius: 15px;
    backdrop-filter: blur(5px);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: white;
    border-radius: 25px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid transparent;
    font-family: 'Noto Sans TC', sans-serif;
    font-weight: 500;
}

.legend-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    border-color: rgba(59, 130, 246, 0.3);
}

.legend-item.active {
    border-color: #3b82f6;
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
    font-weight: 600;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.3);
}

.legend-item.active .legend-label {
    color: white;
}

.legend-color {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.legend-color::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 50%;
    background: inherit;
    opacity: 0.2;
}

.legend-label {
    font-size: 14px;
    color: #374151;
    font-weight: 500;
    transition: color 0.3s ease;
}

/* 動畫效果 */
@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.4;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.1);
    }
}

.dashed-circle {
    animation: pulse 2s ease-in-out infinite;
}

/* 響應式設計 */
@media (max-width: 1024px) {
    .typhoon-chart-container {
        padding: 30px;
    }
    
    .chart-title {
        font-size: 20px;
    }
    
    .canvas-wrapper {
        min-height: 450px;
    }
}

@media (max-width: 768px) {
    .typhoon-chart {
        padding: 40px 0;
    }
    
    .typhoon-chart-container {
        padding: 20px;
        margin: 0 10px;
    }
    
    .chart-title {
        font-size: 18px;
        margin-bottom: 20px;
    }
    
    .canvas-wrapper {
        min-height: 400px;
    }
    
    .legend-container {
        gap: 10px;
        padding: 20px;
    }
    
    .legend-item {
        padding: 10px 16px;
        gap: 10px;
    }
    
    .legend-color {
        width: 28px;
        height: 28px;
    }
    
    .legend-label {
        font-size: 13px;
    }
}
/* 手機版優化 */
@media (max-width: 768px) {
    .typhoon-chart {
        min-height: 450px;
        padding: 15px 10px;
        margin: 0 5px;
    }
    
    .typhoon-title {
        font-size: 16px;
        line-height: 1.5;
        margin-bottom: 20px;
        word-wrap: break-word;
        padding: 0 15px;
        text-align: center;
        font-weight: 600;
    }
    
    .typhoon-container {
        height: 400px;
        margin: 0 auto;
        max-width: calc(100vw - 30px);
        overflow: hidden;
        position: relative;
    }
    
    .typhoon-canvas {
        height: 400px !important;
        max-width: 100%;
        display: block;
        margin: 0 auto;
    }
    
    .typhoon-svg {
        height: 400px !important;
        max-width: 100%;
        overflow: visible;
        display: block;
        margin: 0 auto;
    }
    
    .typhoon-svg text {
        font-size: 10px;
        font-weight: bold;
        text-anchor: middle;
        fill: #1f2937;
    }
    
    /* 調整SVG文字位置避免截斷 - 往內往上移動 */
    .typhoon-svg text[x="50"] {
        x: 120 !important;
    }
    
    .typhoon-svg text[x="650"] {
        x: 580 !important;
    }
    
    .typhoon-svg text[y="50"] {
        y: 100 !important;
    }
    
    /* 下方文字往上移動，更靠近線條 */
    .typhoon-svg text[y="500"] {
        y: 350 !important;
    }
    
    /* 額外的文字位置調整 */
    .typhoon-svg text[x="100"] {
        x: 130 !important;
    }
    
    .typhoon-svg text[x="600"] {
        x: 570 !important;
    }
    
    /* 底部文字標籤特別調整 - 大幅往上移動 */
    .typhoon-svg text[y="480"] {
        y: 340 !important;
    }
    
    .typhoon-svg text[y="490"] {
        y: 345 !important;
    }
    
    .typhoon-svg text[y="460"] {
        y: 335 !important;
    }
    
    /* 確保所有底部文字都靠近線條 */
    .typhoon-svg text[y="470"] {
        y: 340 !important;
    }
    
    /* 確保文字在深色模式下可見 */
    [data-theme="dark"] .typhoon-svg text {
        fill: #f9fafb;
    }
}
    
#svgContainer text {
    font-size: 10px !important;
    font-weight: bold !important;
}
    
    .legend-container {
        flex-direction: column;
        align-items: center;
        gap: 8px;
        padding: 15px;
    }
    
    .legend-item {
        width: 100%;
        max-width: 280px;
        justify-content: center;
        padding: 8px 12px;
    }
}

/* 極小螢幕優化 */
@media (max-width: 480px) {
    .typhoon-chart {
        min-height: 420px;
        padding: 10px 5px;
        margin: 0;
    }
    
    .typhoon-title {
        font-size: 14px;
        line-height: 1.4;
        margin-bottom: 15px;
        padding: 0 10px;
    }
    
    .typhoon-container {
        height: 350px;
        max-width: calc(100vw - 20px);
    }
    
    .typhoon-canvas,
    .typhoon-svg {
        height: 350px !important;
    }
    
    .typhoon-svg text {
        font-size: 8px;
    }
    
    /* 極小螢幕的文字位置更嚴格控制 */
    .typhoon-svg text[x="50"] {
        x: 140 !important;
    }
    
    .typhoon-svg text[x="650"] {
        x: 560 !important;
    }
    
    .typhoon-svg text[x="100"] {
        x: 150 !important;
    }
    
    .typhoon-svg text[x="600"] {
        x: 550 !important;
    }
    
    .typhoon-svg text[y="50"] {
        y: 120 !important;
    }
    
    .typhoon-svg text[y="500"] {
        y: 320 !important;
    }
    
    .typhoon-svg text[y="480"] {
        y: 310 !important;
    }
    
    .typhoon-svg text[y="460"] {
        y: 305 !important;
    }
    
    .typhoon-svg text[y="470"] {
        y: 315 !important;
    }
    
    .typhoon-svg text[y="490"] {
        y: 325 !important;
    }
    
    .legend-container {
        padding: 10px;
        gap: 6px;
    }
    
    .legend-item {
        padding: 6px 10px;
        font-size: 12px;
    }
    
    .legend-color {
        width: 20px;
        height: 20px;
    }
}

/* 載入動畫 */
.typhoon-chart-container.loading {
    position: relative;
}

.typhoon-chart-container.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 深色模式支援 */
@media (prefers-color-scheme: dark) {
    .typhoon-chart {
        background: linear-gradient(135deg, 
            rgba(17, 24, 39, 0.95) 0%, 
            rgba(31, 41, 55, 0.95) 100%);
    }
    
    .typhoon-chart-container {
        background: rgba(31, 41, 55, 0.98);
        border-color: rgba(75, 85, 99, 0.3);
    }
    
    .chart-title {
        color: #f9fafb;
    }
    
    .legend-container {
        background: rgba(17, 24, 39, 0.8);
    }
    
    .legend-item {
        background: rgba(55, 65, 81, 0.9);
        border-color: rgba(75, 85, 99, 0.3);
    }
    
    .legend-label {
        color: #d1d5db;
    }
    
    .legend-item.active .legend-label {
        color: white;
    }
}


/* 極小螢幕的額外優化 */
@media (max-width: 480px) {
    .typhoon-chart {
        min-height: 400px;
        padding: 10px 5px;
    }
    
    .typhoon-container {
        height: 350px;
        max-width: calc(100vw - 20px);
    }
    
    .typhoon-canvas,
    .typhoon-svg {
        height: 350px !important;
    }
    
    .typhoon-svg text {
        font-size: 9px;
    }
    
    /* 極小螢幕下方文字更靠近線條 */
    .typhoon-svg text[y="500"] {
        y: 320 !important;
    }
    
    .typhoon-svg text[y="480"] {
        y: 310 !important;
    }
    
    .typhoon-svg text[y="490"] {
        y: 315 !important;
    }
    
    /* 左右文字更往內 */
    .typhoon-svg text[x="50"] {
        x: 100 !important;
    }
    
    .typhoon-svg text[x="650"] {
        x: 550 !important;
    }
}
