/* ===================================
   OBV 吸籌策略選股系統 - 樣式表
   =================================== */

/* CSS Variables */
:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: #1a2234;
    --bg-card-hover: #243044;
    --text-primary: #f0f4f8;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-blue: #3b82f6;
    --accent-cyan: #06b6d4;
    --accent-green: #10b981;
    --accent-red: #ef4444;
    --accent-yellow: #f59e0b;
    --accent-purple: #8b5cf6;
    --gradient-primary: linear-gradient(135deg, #3b82f6 0%, #06b6d4 100%);
    --gradient-electronics: linear-gradient(135deg, #8b5cf6 0%, #06b6d4 100%);
    --gradient-financial: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 8px 30px rgba(59, 130, 246, 0.2);
    --border-radius: 16px;
    --border-radius-sm: 8px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* App Container */
.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    padding: 24px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: sticky;
    top: 0;
    background: rgba(10, 14, 23, 0.95);
    backdrop-filter: blur(10px);
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 2rem;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.update-time {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.badge {
    background: var(--gradient-primary);
    color: white;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Strategy Section */
.strategy-section {
    padding: 32px 0;
}

.strategy-card {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 28px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.strategy-card h2 {
    font-size: 1.25rem;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.strategy-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}

.strategy-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
}

.strategy-item:hover {
    background: rgba(255, 255, 255, 0.06);
    transform: translateY(-2px);
}

.strategy-icon {
    font-size: 1.75rem;
    flex-shrink: 0;
}

.strategy-text strong {
    display: block;
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.strategy-text p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Main Content */
.main-content {
    padding: 20px 0 40px;
}

/* Sector Section */
.sector-section {
    margin-bottom: 48px;
}

.sector-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.sector-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sector-icon {
    font-size: 1.75rem;
}

.sector-badge {
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sector-badge.electronics {
    background: var(--gradient-electronics);
    color: white;
}

.sector-badge.financial {
    background: var(--gradient-financial);
    color: white;
}

/* Stock Grid */
.stock-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

/* Stock Card */
.stock-card {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 24px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stock-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-primary);
    opacity: 0;
    transition: var(--transition);
}

.stock-card:hover {
    background: var(--bg-card-hover);
    box-shadow: var(--shadow-hover);
    transform: translateY(-4px);
}

.stock-card:hover::before {
    opacity: 1;
}

.stock-card.electronics::before {
    background: var(--gradient-electronics);
}

.stock-card.financial::before {
    background: var(--gradient-financial);
}

/* Card Header */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.stock-info h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.stock-code {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.stock-price {
    text-align: right;
}

.price-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.price-change {
    font-size: 0.85rem;
    font-weight: 500;
    margin-top: 2px;
}

.price-change.up {
    color: var(--accent-green);
}

.price-change.down {
    color: var(--accent-red);
}

.price-change.flat {
    color: var(--text-muted);
}

/* Indicators */
.indicators {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.indicator {
    background: rgba(255, 255, 255, 0.03);
    padding: 12px;
    border-radius: var(--border-radius-sm);
}

.indicator-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.indicator-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.indicator-value.positive {
    color: var(--accent-green);
}

.indicator-value.negative {
    color: var(--accent-red);
}

/* Signal Tags */
.signal-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.signal-tag {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 500;
}

.signal-tag.obv-up {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-green);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.signal-tag.macd-golden {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-yellow);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.signal-tag.sideways {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-blue);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.signal-tag.net-buy {
    background: rgba(139, 92, 246, 0.15);
    color: var(--accent-purple);
    border: 1px solid rgba(139, 92, 246, 0.3);
}

/* Net Buy/Sell Section */
.net-buy-sell-section {
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--border-radius-sm);
    padding: 14px;
    margin-bottom: 16px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.net-buy-sell-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

.net-buy-sell-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
}

.net-buy-sell-total {
    font-size: 0.85rem;
    font-weight: 700;
}

.net-buy-sell-total.positive {
    color: var(--accent-green);
}

.net-buy-sell-total.negative {
    color: var(--accent-red);
}

/* Net Buy/Sell Chart - with 0 axis line */
.net-buy-sell-chart {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
    gap: 4px;
    position: relative;
}

/* 0 軸線 */
.net-buy-sell-chart::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 1px;
    background: rgba(255, 255, 255, 0.2);
    z-index: 1;
}

/* 0 軸線標籤 */
.net-buy-sell-chart::after {
    content: '0';
    position: absolute;
    left: -12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.55rem;
    color: var(--text-muted);
}

.bar-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    height: 100%;
}

.bar-wrapper {
    width: 100%;
    height: 55px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.bar {
    width: 80%;
    max-width: 20px;
    min-height: 3px;
    transition: var(--transition);
    position: absolute;
    z-index: 2;
}

.bar.positive {
    bottom: 50%;
    border-radius: 2px 2px 0 0;
    background: linear-gradient(180deg, var(--accent-green) 0%, rgba(16, 185, 129, 0.6) 100%);
}

.bar.negative {
    top: 50%;
    border-radius: 0 0 2px 2px;
    background: linear-gradient(0deg, var(--accent-red) 0%, rgba(239, 68, 68, 0.6) 100%);
}

.bar-container:hover .bar {
    opacity: 0.8;
    transform: scaleY(1.1);
}

.bar-date {
    font-size: 0.55rem;
    color: var(--text-muted);
    margin-top: 4px;
    white-space: nowrap;
}

.no-data {
    width: 100%;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 20px 0;
}

/* Entry Signal Banner */
.entry-signal-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    margin: -24px -24px 16px -24px;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

/* Entry Signal Banner Types */
.entry-signal-banner.strong_buy {
    background: linear-gradient(135deg, rgba(0, 184, 148, 0.3) 0%, rgba(0, 184, 148, 0.15) 100%);
    border-bottom: 2px solid #00b894;
}

.entry-signal-banner.buy {
    background: linear-gradient(135deg, rgba(9, 132, 227, 0.3) 0%, rgba(9, 132, 227, 0.15) 100%);
    border-bottom: 2px solid #0984e3;
}

.entry-signal-banner.watch {
    background: linear-gradient(135deg, rgba(99, 110, 114, 0.3) 0%, rgba(99, 110, 114, 0.15) 100%);
    border-bottom: 2px solid #636e72;
}

.entry-signal-banner.sell {
    background: linear-gradient(135deg, rgba(225, 112, 85, 0.3) 0%, rgba(225, 112, 85, 0.15) 100%);
    border-bottom: 2px solid #e17055;
}

.entry-signal-banner.strong_sell,
.entry-signal-banner.avoid {
    background: linear-gradient(135deg, rgba(214, 48, 49, 0.3) 0%, rgba(214, 48, 49, 0.15) 100%);
    border-bottom: 2px solid #d63031;
}

.signal-emoji {
    font-size: 1.5rem;
    line-height: 1;
}

.signal-text {
    font-size: 0.95rem;
    font-weight: 700;
}

.entry-signal-banner.strong_buy .signal-text {
    color: #00b894;
}

.entry-signal-banner.buy .signal-text {
    color: #0984e3;
}

.entry-signal-banner.watch .signal-text {
    color: #b2bec3;
}

.entry-signal-banner.sell .signal-text {
    color: #e17055;
}

.entry-signal-banner.strong_sell .signal-text,
.entry-signal-banner.avoid .signal-text {
    color: #d63031;
}

.signal-summary {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-left: auto;
    text-align: right;
}

/* Stop Loss / Take Profit */
.stop-loss-take-profit {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 16px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--border-radius-sm);
}

.sltp-item {
    flex: 1;
    text-align: center;
    padding: 8px;
    border-radius: 6px;
}

.sltp-item.stop-loss {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.sltp-item.entry {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.sltp-item.take-profit {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.sltp-label {
    display: block;
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.sltp-item.stop-loss .sltp-value {
    color: var(--accent-red);
}

.sltp-item.entry .sltp-value {
    color: var(--accent-blue);
}

.sltp-item.take-profit .sltp-value {
    color: var(--accent-green);
}

.sltp-value {
    font-size: 0.9rem;
    font-weight: 700;
}


/* Analysis */
.analysis {
    background: rgba(255, 255, 255, 0.02);
    padding: 14px;
    border-radius: var(--border-radius-sm);
    border-left: 3px solid var(--accent-cyan);
}

.analysis-title {
    font-size: 0.75rem;
    color: var(--accent-cyan);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.analysis-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Loading Placeholder */
.loading-placeholder {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Footer */
.footer {
    padding: 32px 0;
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    font-size: 0.85rem;
}

.footer p {
    margin-bottom: 8px;
}

.copyright {
    font-size: 0.75rem;
}

/* ========================================
   Responsive - Mobile Optimizations
   ======================================== */

/* Tablet */
@media (max-width: 1024px) {
    .app-container {
        padding: 0 16px;
    }

    .stock-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 16px;
    }
}

/* Mobile */
@media (max-width: 768px) {

    /* Header - Compact */
    .header {
        padding: 16px 0;
        position: sticky;
        top: 0;
    }

    .header-content {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .logo {
        justify-content: center;
    }

    .logo h1 {
        font-size: 1.1rem;
    }

    .logo-icon {
        font-size: 1.5rem;
    }

    .header-info {
        justify-content: center;
        flex-wrap: wrap;
    }

    /* Strategy Section */
    .strategy-section {
        padding: 20px 0;
    }

    .strategy-card {
        padding: 20px;
    }

    .strategy-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .strategy-item {
        padding: 14px;
    }

    /* Stock Grid - Single Column */
    .stock-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    /* Stock Card - Touch Friendly */
    .stock-card {
        padding: 18px;
        border-radius: 14px;
    }

    .card-header {
        margin-bottom: 14px;
    }

    .stock-info h3 {
        font-size: 1rem;
    }

    .price-value {
        font-size: 1.3rem;
    }

    /* Indicators - Stacked */
    .indicators {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .indicator {
        padding: 10px;
    }

    .indicator-label {
        font-size: 0.7rem;
    }

    .indicator-value {
        font-size: 0.85rem;
    }

    /* Signal Tags - Wrap Better */
    .signal-tags {
        gap: 6px;
    }

    .signal-tag {
        font-size: 0.65rem;
        padding: 4px 8px;
    }

    /* Entry Signal Banner */
    .entry-signal-banner {
        padding: 10px 14px;
        margin: -18px -18px 14px -18px;
        flex-wrap: wrap;
    }

    .signal-emoji {
        font-size: 1.3rem;
    }

    .signal-text {
        font-size: 0.9rem;
    }

    .signal-summary {
        width: 100%;
        text-align: left;
        margin-left: 0;
        margin-top: 6px;
        font-size: 0.7rem;
    }

    /* Stop Loss Take Profit */
    .stop-loss-take-profit {
        flex-direction: row;
        gap: 6px;
        padding: 10px;
    }

    .sltp-item {
        padding: 6px 4px;
    }

    .sltp-label {
        font-size: 0.6rem;
    }

    .sltp-value {
        font-size: 0.8rem;
    }

    /* Net Buy Sell Section */
    .net-buy-sell-section {
        padding: 12px;
    }

    .net-buy-sell-chart {
        height: 60px;
    }

    /* Footer */
    .footer {
        padding: 24px 0;
    }

    .footer p {
        font-size: 0.8rem;
    }

    /* Buttons - Touch Friendly */
    button,
    .btn,
    .scan-btn {
        min-height: 44px;
        min-width: 44px;
        font-size: 0.9rem;
        padding: 10px 16px;
    }

    /* Back Link */
    .back-link {
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    /* Section Titles */
    .sector-header h2 {
        font-size: 1.2rem;
    }

    .section-title {
        font-size: 1.1rem;
    }

    /* Category Menu */
    .category-menu-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 8px !important;
    }

    .cat-item {
        padding: 10px 8px !important;
        font-size: 0.75rem !important;
    }

    /* Subsector Tabs */
    .subsector-tabs {
        gap: 6px;
        padding: 10px 0;
    }

    .subsector-tab {
        padding: 6px 10px;
        font-size: 0.75rem;
    }
}

/* Small Mobile (iPhone SE, etc.) */
@media (max-width: 375px) {
    .app-container {
        padding: 0 12px;
    }

    .header {
        padding: 12px 0;
    }

    .logo h1 {
        font-size: 1rem;
    }

    .stock-card {
        padding: 14px;
    }

    .price-value {
        font-size: 1.2rem;
    }

    .indicators {
        grid-template-columns: 1fr;
    }

    .category-menu-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .stop-loss-take-profit {
        flex-direction: column;
    }
}

/* Animation for cards appearing */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.stock-card {
    animation: fadeInUp 0.5s ease-out forwards;
}

.stock-card:nth-child(1) {
    animation-delay: 0.1s;
}

.stock-card:nth-child(2) {
    animation-delay: 0.2s;
}

.stock-card:nth-child(3) {
    animation-delay: 0.3s;
}

.stock-card:nth-child(4) {
    animation-delay: 0.4s;
}


/* Category Dashboard Cards */
.category-card {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 30px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 200px;
    cursor: pointer;
}

.category-card:hover {
    background: var(--bg-card-hover);
    box-shadow: var(--shadow-hover);
    transform: translateY(-5px);
    border-color: rgba(255, 255, 255, 0.1);
}

.category-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--gradient-primary);
    opacity: 0.7;
    transition: var(--transition);
}

.category-card:hover::before {
    opacity: 1;
    height: 6px;
}

.category-icon {
    font-size: 3rem;
    margin-bottom: 20px;
    filter: drop-shadow(0 0 10px rgba(59, 130, 246, 0.3));
    transition: var(--transition);
}

.category-card:hover .category-icon {
    transform: scale(1.1);
}

.category-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 10px;
    letter-spacing: 1px;
}

.category-count {
    background: rgba(255, 255, 255, 0.05);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.category-action {
    margin-top: 25px;
    color: var(--accent-blue);
    font-size: 0.9rem;
    font-weight: 600;
    opacity: 0;
    transform: translateY(10px);
    transition: var(--transition);
}

.category-card:hover .category-action {
    opacity: 1;
    transform: translateY(0);
}