/* ============================================
   Ghost Mode — 幽靈模式專屬樣式
   ============================================ */

/* Import shared design system */
@import url('./style.css');

/* Ghost accent colors */
:root {
    --ghost-primary: #6366f1;
    --ghost-secondary: #818cf8;
    --ghost-glow: rgba(99, 102, 241, 0.15);
    --ghost-gradient: linear-gradient(135deg, #6366f1, #06b6d4);
}

/* ---- Page Layout ---- */
.ghost-container {
    position: relative;
    z-index: 1;
    max-width: 960px;
    margin: 0 auto;
    padding: 40px 24px 80px;
}

/* ---- Mode Tabs ---- */
.ghost-mode-tab {
    flex: 1;
    padding: 12px 20px;
    border: 1px solid var(--border-subtle);
    background: transparent;
    color: var(--text-dim);
    font-family: var(--font-tc);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.ghost-mode-tab:first-child {
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.ghost-mode-tab:last-child {
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    border-left: none;
}

.ghost-mode-tab:hover {
    color: var(--text-secondary);
    border-color: var(--border-accent);
}

.ghost-mode-tab.active {
    background: var(--ghost-glow);
    border-color: var(--ghost-primary);
    color: var(--ghost-secondary);
    font-weight: 700;
}

.ghost-mode-panel {
    display: none;
}

.ghost-mode-panel.active {
    display: block;
    animation: fadeInUp 0.3s ease-out;
}

/* ---- Ghost Header ---- */
.ghost-header {
    text-align: center;
    margin-bottom: 40px;
}

.ghost-header h1 {
    font-size: 2.2rem;
    font-weight: 800;
    background: var(--ghost-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.ghost-header p {
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.6;
}

.ghost-header .back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.9rem;
    transition: var(--transition);
    margin-bottom: 20px;
}

.ghost-header .back-link:hover {
    color: var(--ghost-secondary);
}

/* ---- Setup Panel ---- */
.ghost-setup {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 28px;
    margin-bottom: 32px;
}

.ghost-setup h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--ghost-secondary);
}

.ghost-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.ghost-form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.ghost-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.btn-ghost {
    background: var(--ghost-gradient);
    color: white;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.3);
}

.btn-ghost:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(99, 102, 241, 0.5);
}

/* ---- Results ---- */
.ghost-results {
    display: none;
}

.ghost-results.active {
    display: block;
    animation: fadeInUp 0.5s ease-out;
}

/* ---- Comparison Table ---- */
.ghost-comparison {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 28px;
    margin-bottom: 32px;
    overflow-x: auto;
}

.ghost-comparison h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.compare-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.compare-table th {
    text-align: left;
    padding: 12px 16px;
    color: var(--text-dim);
    border-bottom: 2px solid var(--border-accent);
    font-weight: 500;
    font-size: 0.85rem;
}

.compare-table th:not(:first-child) {
    text-align: right;
}

.compare-table td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(124, 58, 237, 0.06);
    font-family: var(--font-en);
}

.compare-table td:not(:first-child) {
    text-align: right;
}

.compare-table td:first-child {
    font-family: var(--font-tc);
    color: var(--text-secondary);
    font-weight: 500;
}

.compare-table tr:last-child td {
    border-bottom: none;
}

.compare-table .highlight-row td {
    background: rgba(99, 102, 241, 0.08);
    font-weight: 700;
    font-size: 1.05rem;
}

.col-insurance {
    color: var(--accent-yellow) !important;
}

.col-stock {
    color: var(--accent-cyan) !important;
}

/* ---- Summary Cards ---- */
.ghost-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.ghost-stat-card {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 20px;
    text-align: center;
}

.ghost-stat-card .stat-icon {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.ghost-stat-card .stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    font-family: var(--font-en);
    margin-bottom: 4px;
}

.ghost-stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-dim);
}

/* ---- Chart ---- */
.ghost-chart-section {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 28px;
    margin-bottom: 32px;
}

.ghost-chart-section h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-secondary);
}

.ghost-chart-container {
    height: 350px;
    position: relative;
}

/* ---- Yearly Detail Table ---- */
.ghost-yearly-table {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 28px;
    margin-bottom: 32px;
    overflow-x: auto;
}

.ghost-yearly-table h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-secondary);
}

.detail-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    white-space: nowrap;
}

.detail-table th {
    text-align: right;
    padding: 10px 12px;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border-subtle);
    font-weight: 500;
}

.detail-table th:first-child {
    text-align: center;
}

.detail-table td {
    text-align: right;
    padding: 8px 12px;
    border-bottom: 1px solid rgba(124, 58, 237, 0.05);
    font-family: var(--font-en);
}

.detail-table td:first-child {
    text-align: center;
    color: var(--text-secondary);
    font-family: var(--font-tc);
}

.detail-table tr:hover td {
    background: rgba(99, 102, 241, 0.04);
}

/* ---- Insurance Input Section ---- */
.ghost-insurance-toggle {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-subtle);
}

.ghost-insurance-toggle label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
}

.ghost-insurance-inputs {
    display: none;
    margin-top: 16px;
}

.ghost-insurance-inputs.active {
    display: block;
}

/* ---- Loading ---- */
.ghost-loading {
    display: none;
    text-align: center;
    padding: 40px;
}

.ghost-loading.active {
    display: block;
}

/* ---- Responsive ---- */
@media (max-width: 640px) {
    .ghost-container {
        padding: 20px 16px 60px;
    }

    .ghost-header h1 {
        font-size: 1.6rem;
    }

    .ghost-form-row,
    .ghost-form-row-2 {
        grid-template-columns: 1fr;
    }

    .ghost-actions {
        flex-direction: column;
    }

    .ghost-summary-grid {
        grid-template-columns: 1fr 1fr;
    }

    .ghost-setup,
    .ghost-comparison,
    .ghost-chart-section,
    .ghost-yearly-table {
        padding: 18px;
    }
}

/* ---- Select Input ---- */
.form-select {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-tc);
    font-size: 1rem;
    transition: var(--transition);
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
    padding-right: 2.5rem;
}

.form-select:focus {
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}

/* ---- Generic Ghost Table ---- */
.ghost-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    table-layout: auto; /* Allow flexible column widths for horizontal scrolling */
    margin-bottom: 20px;
}

.ghost-table th {
    text-align: right;
    padding: 12px 10px;
    color: var(--text-dim);
    border-bottom: 2px solid var(--border-accent);
    font-weight: 600;
    font-size: 0.85rem;
    white-space: nowrap; /* Prevent headers from squishing */
    vertical-align: middle;
}

.ghost-table th:first-child {
    text-align: left;
}


.ghost-table td {
    padding: 12px 10px;
    border-bottom: 1px solid rgba(124, 58, 237, 0.05);
    font-family: var(--font-en);
    text-align: right;
    white-space: nowrap; /* Prevent data cells from squishing */
}

.ghost-table td:first-child {
    text-align: left;
    font-family: var(--font-tc);
    font-weight: 500;
}

.ghost-table tr:hover td {
    background: rgba(99, 102, 241, 0.04);
}

.ghost-table .text-cyan { color: var(--accent-cyan); }
.ghost-table .text-purple { color: var(--accent-purple); }
.ghost-table .text-green { color: var(--accent-green); }
.ghost-table .text-red { color: var(--accent-red); }

