/* ═══════════════════════════════════════════════════════
   🧾 TAX CALCULATOR & REPORT — Feature 14.2
   Capital gains tax, dividend tax, annual summary, export
   ═══════════════════════════════════════════════════════ */

/* ── Page Header ── */
.tax-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}
.tax-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary, #fff);
    display: flex;
    align-items: center;
    gap: 10px;
}
.tax-title svg {
    width: 26px;
    height: 26px;
    color: #f59e0b;
}

/* Year Selector */
.tax-year-select {
    display: flex;
    align-items: center;
    gap: 8px;
}
.tax-year-select label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted, #94a3b8);
}
.tax-year-select select {
    background: var(--bg-elevated, #1e293b);
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    border-radius: 10px;
    color: var(--text-primary, #fff);
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M1.646 4.646a.5.5 0 01.708 0L8 10.293l5.646-5.647a.5.5 0 01.708.708l-6 6a.5.5 0 01-.708 0l-6-6a.5.5 0 010-.708z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}
.tax-year-select select:focus {
    border-color: rgba(245,158,11,0.5);
}

/* ── Summary Cards ── */
.tax-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}
.tax-summary-card {
    background: var(--bg-elevated, #1e293b);
    border: 1px solid var(--border-color, rgba(255,255,255,0.06));
    border-radius: 14px;
    padding: 16px;
    position: relative;
    overflow: hidden;
    transition: border-color 0.2s;
}
.tax-summary-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--accent, #6366f1);
}
.tax-summary-card:hover {
    border-color: rgba(148,163,184,0.15);
}
.tax-summary-card.accent-amber::before   { background: #f59e0b; }
.tax-summary-card.accent-green::before   { background: #22c55e; }
.tax-summary-card.accent-red::before     { background: #ef4444; }
.tax-summary-card.accent-blue::before    { background: #3b82f6; }
.tax-summary-card.accent-purple::before  { background: #a855f7; }
.tax-summary-card .card-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted, #94a3b8);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}
.tax-summary-card .card-value {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-primary, #fff);
    line-height: 1.2;
}
.tax-summary-card .card-sub {
    font-size: 11px;
    color: var(--text-muted, #94a3b8);
    margin-top: 4px;
}

/* ── Tab Bar ── */
.tax-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-elevated, #1e293b);
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 20px;
    overflow-x: auto;
}
.tax-tab {
    flex: 1;
    min-width: 90px;
    padding: 10px 14px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text-muted, #94a3b8);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    text-align: center;
}
.tax-tab:hover {
    color: var(--text-primary, #fff);
    background: rgba(255,255,255,0.05);
}
.tax-tab.active {
    background: rgba(245,158,11,0.15);
    color: #f59e0b;
}

/* ── Panels ── */
.tax-panel {
    display: none;
}
.tax-panel.active {
    display: block;
    animation: taxFadeIn 0.25s ease;
}
@keyframes taxFadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ── Capital Gains Section ── */
.tax-cg-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.tax-cg-stat {
    background: var(--bg-elevated, #1e293b);
    border: 1px solid var(--border-color, rgba(255,255,255,0.06));
    border-radius: 14px;
    padding: 16px;
    text-align: center;
}
.tax-cg-stat .stat-label {
    font-size: 11px;
    color: var(--text-muted, #94a3b8);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}
.tax-cg-stat .stat-value {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-primary, #fff);
}
.tax-cg-stat .stat-value.text-amber { color: #f59e0b; }
.tax-cg-stat .stat-value.text-green { color: #22c55e; }
.tax-cg-stat .stat-value.text-red   { color: #ef4444; }

/* Transaction Table */
.tax-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 14px;
    border: 1px solid var(--border-color, rgba(255,255,255,0.06));
    margin-bottom: 20px;
}
.tax-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}
.tax-table thead th {
    background: var(--bg-elevated, #1e293b);
    color: var(--text-muted, #94a3b8);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 10px 8px;
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid var(--border-color, rgba(148,163,184,0.1));
    position: sticky;
    top: 0;
    z-index: 1;
}
.tax-table thead th:last-child,
.tax-table tbody td:last-child {
    text-align: right;
}
.tax-table tbody tr {
    transition: background 0.15s;
}
.tax-table tbody tr:hover {
    background: rgba(255,255,255,0.03);
}
.tax-table tbody td {
    padding: 10px 8px;
    font-size: 12px;
    color: var(--text-primary, #fff);
    border-bottom: 1px solid var(--border-color, rgba(148,163,184,0.06));
    white-space: nowrap;
}
.tax-table .stock-code {
    font-weight: 700;
}
.tax-table .type-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
}
.type-badge.buy  { background: rgba(34,197,94,0.15); color: #22c55e; }
.type-badge.sell { background: rgba(239,68,68,0.15); color: #ef4444; }

/* Total row */
.tax-table tfoot td {
    padding: 10px 8px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-primary, #fff);
    border-top: 2px solid var(--border-color, rgba(148,163,184,0.15));
    background: rgba(255,255,255,0.02);
}

/* ── Dividend Tax Section ── */
.tax-div-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.tax-div-card {
    background: var(--bg-elevated, #1e293b);
    border: 1px solid var(--border-color, rgba(255,255,255,0.06));
    border-radius: 14px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: border-color 0.2s;
}
.tax-div-card:hover {
    border-color: rgba(245,158,11,0.2);
}
.tax-div-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: rgba(245,158,11,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #f59e0b;
}
.tax-div-icon svg { width: 20px; height: 20px; }
.tax-div-info {
    flex: 1;
    min-width: 0;
}
.tax-div-info .stock {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary, #fff);
}
.tax-div-info .detail {
    font-size: 12px;
    color: var(--text-muted, #94a3b8);
    margin-top: 2px;
}
.tax-div-amounts {
    text-align: right;
    flex-shrink: 0;
}
.tax-div-amounts .gross {
    font-size: 14px;
    font-weight: 700;
    color: #22c55e;
}
.tax-div-amounts .tax-amt {
    font-size: 12px;
    color: #ef4444;
    margin-top: 2px;
}

/* ── Report / Summary Section ── */
.tax-report-card {
    background: var(--bg-elevated, #1e293b);
    border: 1px solid var(--border-color, rgba(255,255,255,0.06));
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
}
.tax-report-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary, #fff);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.tax-report-title svg { width: 20px; height: 20px; color: #f59e0b; }
.tax-report-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color, rgba(148,163,184,0.06));
}
.tax-report-row:last-child {
    border-bottom: none;
}
.tax-report-row .rpt-label {
    font-size: 13px;
    color: var(--text-muted, #94a3b8);
}
.tax-report-row .rpt-value {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary, #fff);
}
.tax-report-row.total {
    border-top: 2px solid var(--border-color, rgba(148,163,184,0.15));
    padding-top: 14px;
    margin-top: 4px;
}
.tax-report-row.total .rpt-label {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary, #fff);
}
.tax-report-row.total .rpt-value {
    font-size: 18px;
    color: #f59e0b;
}

/* Chart */
.tax-chart-container {
    position: relative;
    height: 260px;
    margin-top: 16px;
    background: rgba(0,0,0,0.15);
    border-radius: 12px;
    padding: 12px;
}
.tax-chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

/* ── Export Buttons ── */
.tax-export-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.tax-export-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    border-radius: 10px;
    background: var(--bg-elevated, #1e293b);
    color: var(--text-primary, #fff);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.tax-export-btn:hover {
    border-color: rgba(245,158,11,0.4);
    background: rgba(245,158,11,0.08);
    color: #f59e0b;
}
.tax-export-btn svg { width: 16px; height: 16px; }

/* ── Tips Section ── */
.tax-tips-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.tax-tip-card {
    background: var(--bg-elevated, #1e293b);
    border: 1px solid var(--border-color, rgba(255,255,255,0.06));
    border-radius: 14px;
    padding: 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    transition: border-color 0.2s;
}
.tax-tip-card:hover {
    border-color: rgba(245,158,11,0.2);
}
.tax-tip-num {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: rgba(245,158,11,0.12);
    color: #f59e0b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 800;
    flex-shrink: 0;
}
.tax-tip-content {
    flex: 1;
}
.tax-tip-content .tip-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary, #fff);
    margin-bottom: 4px;
}
.tax-tip-content .tip-desc {
    font-size: 12px;
    color: var(--text-muted, #94a3b8);
    line-height: 1.5;
}

/* ── Info Banner ── */
.tax-info-banner {
    background: rgba(245,158,11,0.08);
    border: 1px solid rgba(245,158,11,0.2);
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 12px;
    color: var(--text-muted, #94a3b8);
    line-height: 1.5;
}
.tax-info-banner svg { flex-shrink: 0; width: 18px; height: 18px; color: #f59e0b; margin-top: 1px; }

/* ── Empty State ── */
.tax-empty {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted, #94a3b8);
}
.tax-empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}
.tax-empty-text {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary, #fff);
    margin-bottom: 6px;
}
.tax-empty-sub {
    font-size: 13px;
}

/* ── Loading ── */
.tax-loading {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted, #94a3b8);
    font-size: 14px;
}
.tax-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(245,158,11,0.2);
    border-top-color: #f59e0b;
    border-radius: 50%;
    margin: 0 auto 12px;
    animation: taxSpin 0.8s linear infinite;
}
@keyframes taxSpin { to { transform: rotate(360deg); } }

/* ── Responsive ── */
@media (max-width: 600px) {
    .tax-summary { grid-template-columns: repeat(2, 1fr); }
    .tax-summary-card { padding: 12px 10px; }
    .tax-summary-card .card-value { font-size: 16px; }
    .tax-tab { min-width: 75px; padding: 8px 10px; font-size: 12px; }
    .tax-cg-stats { grid-template-columns: 1fr 1fr; }
    .tax-cg-stat .stat-value { font-size: 16px; }
    .tax-chart-container { height: 200px; }
    .tax-export-btn { padding: 8px 14px; font-size: 12px; }
    .tax-header { flex-direction: column; align-items: flex-start; }
    .tax-table-wrap { overflow-x: hidden; }
    .tax-table thead th { font-size: 9px; padding: 8px 5px; letter-spacing: 0; }
    .tax-table tbody td { font-size: 11px; padding: 8px 5px; }
    .tax-table tfoot td { font-size: 11px; padding: 8px 5px; }
    .tax-table .type-badge { font-size: 9px; padding: 2px 5px; }
}
