/* Stock Prediction Dashboard Styles */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #0f1419;
    color: #e1e8ed;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

header {
    background: linear-gradient(135deg, #1a2634 0%, #0f1419 100%);
    border-bottom: 2px solid #1e3a5f;
    padding: 20px 0;
    margin-bottom: 30px;
}

h1 {
    font-size: 2em;
    margin-bottom: 10px;
    color: #58a6ff;
}

.subtitle {
    color: #8b949e;
    font-size: 0.9em;
}

.regime-banner {
    background: #1e3a5f;
    border-left: 4px solid #58a6ff;
    padding: 15px 20px;
    margin-bottom: 30px;
    border-radius: 5px;
}

.regime-banner h2 {
    font-size: 1.2em;
    margin-bottom: 10px;
    color: #58a6ff;
}

.regime-info {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
}

.regime-stat {
    display: flex;
    flex-direction: column;
}

.regime-stat-label {
    font-size: 0.8em;
    color: #8b949e;
    text-transform: uppercase;
}

.regime-stat-value {
    font-size: 1.1em;
    font-weight: 600;
    color: #e1e8ed;
}

.stocks-table {
    background: #161b22;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #30363d;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: #0d1117;
}

thead th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    color: #58a6ff;
    border-bottom: 2px solid #30363d;
    font-size: 0.9em;
    text-transform: uppercase;
}

tbody tr {
    border-bottom: 1px solid #21262d;
    transition: background 0.2s;
}

tbody tr:hover {
    background: #1c2128;
}

tbody td {
    padding: 15px;
    font-size: 0.95em;
}

.ticker-cell {
    font-weight: 600;
    color: #58a6ff;
    font-size: 1.1em;
}

.ticker-link {
    color: #58a6ff;
    text-decoration: none;
}

.ticker-link:hover {
    text-decoration: underline;
}

.score-cell {
    font-weight: 500;
}

.score-high {
    color: #3fb950;
}

.score-medium {
    color: #d29922;
}

.score-low {
    color: #f85149;
}

.risk-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 600;
}

.risk-A {
    background: #1a7f37;
    color: white;
}

.risk-B {
    background: #9a6700;
    color: white;
}

.risk-C {
    background: #cf222e;
    color: white;
}

.risk-D {
    background: #8b1921;
    color: white;
}

.price-cell {
    font-family: 'Courier New', monospace;
}

/* Detail Page */
.detail-header {
    background: #1e3a5f;
    padding: 30px;
    border-radius: 8px;
    margin-bottom: 30px;
}

.detail-header h1 {
    font-size: 2.5em;
    margin-bottom: 15px;
}

.scores-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.score-card {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 15px;
    height: 100%;
}

.score-card p {
    margin-bottom: 8px;
    font-size: 0.9em;
}

.score-card strong {
    color: #e1e8ed;
    font-weight: 600;
}

/* Color-coded metrics */
.metric-positive {
    color: #3fb950 !important;
    font-weight: 600;
}

.metric-negative {
    color: #f85149 !important;
    font-weight: 600;
}

.metric-neutral {
    color: #d29922 !important;
    font-weight: 600;
}

.metric-risk-low {
    color: #3fb950 !important;
    font-weight: 600;
}

.metric-risk-medium {
    color: #d29922 !important;
    font-weight: 600;
}

.metric-risk-high {
    color: #f85149 !important;
    font-weight: 600;
}

.score-card h3 {
    font-size: 0.85em;
    color: #8b949e;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.score-value {
    font-size: 1.6em;
    font-weight: 700;
    margin-bottom: 5px;
}

.score-bar {
    height: 8px;
    background: #21262d;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 10px;
}

.score-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s;
}

.fill-green {
    background: linear-gradient(90deg, #1a7f37 0%, #3fb950 100%);
}

.fill-yellow {
    background: linear-gradient(90deg, #9a6700 0%, #d29922 100%);
}

.fill-red {
    background: linear-gradient(90deg, #cf222e 0%, #f85149 100%);
}

/* Detail Page Flippable Cards */
.detail-flip-card {
    perspective: 1000px;
    height: 180px;
    cursor: pointer;
}

.detail-flip-card .flip-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.detail-flip-card.flipped .flip-card-inner {
    transform: rotateY(180deg);
}

.detail-flip-card .flip-card-front,
.detail-flip-card .flip-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 8px;
}

.detail-flip-card .flip-card-front {
    background: transparent;
}

.detail-flip-card .flip-card-back {
    transform: rotateY(180deg);
    background: #0d1117;
    border: 1px solid #30363d;
    padding: 15px;
    overflow-y: auto;
}

.explanation-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.explanation-card h3 {
    color: #58a6ff;
    font-size: 0.9em;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 2px solid #30363d;
}

.explanation-text {
    color: #e1e8ed;
    font-size: 0.85em;
    line-height: 1.5;
    flex-grow: 1;
}

.verdict-text {
    font-weight: 600;
    font-size: 1em;
}

.detail-flip-card .flip-hint {
    text-align: center;
    margin-top: auto;
    padding-top: 8px;
    color: #8b949e;
    font-size: 0.75em;
}

.scores-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.back-link {
    display: inline-block;
    margin-bottom: 20px;
    color: #58a6ff;
    text-decoration: none;
    font-weight: 500;
}

.back-link:hover {
    text-decoration: underline;
}

.loading {
    text-align: center;
    padding: 50px;
    font-size: 1.2em;
    color: #8b949e;
}

.error {
    background: #cf222e;
    color: white;
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
}

/* Flippable Cards */
.view-toggle {
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
}

.view-toggle button {
    background: #21262d;
    color: #e1e8ed;
    border: 1px solid #30363d;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.2s;
}

.view-toggle button.active {
    background: #1e3a5f;
    border-color: #58a6ff;
    color: #58a6ff;
}

.view-toggle button:hover {
    background: #30363d;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 25px;
    margin-top: 20px;
}

.flip-card {
    perspective: 1000px;
    height: 400px;
}

.flip-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: left;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    cursor: pointer;
}

.flip-card.flipped .flip-card-inner {
    transform: rotateY(180deg);
}

.flip-card-front,
.flip-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 12px;
    padding: 25px;
    background: #161b22;
    border: 1px solid #30363d;
    overflow-y: auto;
}

.flip-card-back {
    transform: rotateY(180deg);
    background: #0d1117;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #30363d;
}

.card-ticker {
    font-size: 1.8em;
    font-weight: 700;
    color: #58a6ff;
}

.card-rank {
    background: #1e3a5f;
    color: #58a6ff;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: 600;
}

.card-scores {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

.card-score-item {
    background: #0d1117;
    padding: 12px;
    border-radius: 8px;
    border-left: 3px solid #30363d;
}

.card-score-label {
    font-size: 0.75em;
    color: #8b949e;
    text-transform: uppercase;
    margin-bottom: 5px;
    display: block;
}

.card-score-value {
    font-size: 1.4em;
    font-weight: 700;
}

.card-score-item.high {
    border-left-color: #3fb950;
}

.card-score-item.high .card-score-value {
    color: #3fb950;
}

.card-score-item.medium {
    border-left-color: #d29922;
}

.card-score-item.medium .card-score-value {
    color: #d29922;
}

.card-score-item.low {
    border-left-color: #f85149;
}

.card-score-item.low .card-score-value {
    color: #f85149;
}

.card-fundamentals {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #30363d;
}

.card-fund-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.9em;
}

.card-fund-label {
    color: #8b949e;
}

.card-fund-value {
    color: #e1e8ed;
    font-weight: 500;
}

.flip-hint {
    text-align: center;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #30363d;
    color: #8b949e;
    font-size: 0.85em;
}

.flip-hint-icon {
    display: inline-block;
    margin-left: 5px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Back of card - Explanations */
.explanation-section {
    margin-bottom: 20px;
}

.explanation-section h4 {
    color: #58a6ff;
    font-size: 1em;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.explanation-section p {
    color: #e1e8ed;
    font-size: 0.9em;
    line-height: 1.6;
    margin-bottom: 10px;
}

.verdict-box {
    background: #1e3a5f;
    border-left: 4px solid #58a6ff;
    padding: 15px;
    margin-top: 20px;
    border-radius: 6px;
}

.verdict-box h4 {
    color: #58a6ff;
    margin-bottom: 10px;
}

.verdict-box p {
    color: #e1e8ed;
    font-weight: 500;
}

.verdict-buy {
    border-left-color: #3fb950;
}

.verdict-buy h4 {
    color: #3fb950;
}

.verdict-avoid {
    border-left-color: #f85149;
}

.verdict-avoid h4 {
    color: #f85149;
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    table {
        font-size: 0.85em;
    }

    thead th, tbody td {
        padding: 10px 5px;
    }

    .scores-grid {
        grid-template-columns: 1fr;
    }

    .cards-grid {
        grid-template-columns: 1fr;
    }

    .flip-card {
        height: 450px;
    }

    .card-scores {
        grid-template-columns: 1fr;
    }
}
