/* Dashboard Styles - Development/Demo */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.5;
    background: #f5f5f5;
    color: #333;
}

header {
    background: #2c3e50;
    color: white;
    padding: 1rem;
}

header h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

nav {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

nav a {
    color: #ecf0f1;
    text-decoration: none;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

nav a:hover {
    background: #34495e;
}

nav a.active {
    background: #34495e;
    font-weight: 600;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

.summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.summary-card {
    background: white;
    border-radius: 8px;
    padding: 1rem;
    border: 1px solid #e0e0e0;
}

.summary-card h2 {
    font-size: 0.9rem;
    color: #666;
    font-weight: normal;
    margin-bottom: 0.5rem;
}

.summary-card .amount {
    font-size: 1.5rem;
    font-weight: bold;
    color: #2c3e50;
}

.summary-card.income .amount {
    color: #27ae60;
}

.summary-card.expense .amount {
    color: #e74c3c;
}

.summary-card.net .amount {
    color: #3498db;
}

.section {
    background: white;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.5rem;
    border: 1px solid #e0e0e0;
}

.section h2 {
    margin-bottom: 1rem;
    color: #2c3e50;
}

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

th, td {
    padding: 0.5rem;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

th {
    background: #f8f9fa;
    font-weight: 600;
}

.amount {
    text-align: right !important;
    font-family: monospace;
}

.status.ok {
    color: #27ae60;
}

.status.warning {
    color: #f39c12;
}

.status.over {
    color: #e74c3c;
    font-weight: bold;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.card {
    background: white;
    border-radius: 8px;
    padding: 1rem;
    border: 1px solid #e0e0e0;
}

.card h3 {
    margin-bottom: 0.5rem;
    color: #2c3e50;
}

.card .amount {
    font-size: 1.3rem;
    font-weight: bold;
    color: #e74c3c;
}

.warning-budgets, .over-budgets {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.5rem;
}

.warning-budgets h3, .over-budgets h3 {
    color: #856404;
    margin-bottom: 0.5rem;
}

.empty-state {
    background: #f8f9fa;
    border: 1px dashed #ccc;
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
    color: #666;
}

.date-picker {
    margin-bottom: 1rem;
    background: white;
    padding: 0.5rem;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.date-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.date-form label {
    font-size: 0.9rem;
}

.date-form input[type="date"] {
    padding: 0.25rem;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.date-form button {
    background: #2c3e50;
    color: white;
    border: none;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
}

footer {
    text-align: center;
    padding: 1rem;
    color: #666;
    font-size: 0.9rem;
}

@media (max-width: 600px) {
    nav {
        flex-direction: column;
    }

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

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

/* ============================================
   Phase C: Visualization & Drill-down Styles
   ============================================ */

/* --- SVG Bar Chart --- */
.bar-chart {
    width: 100%;
    margin: 1rem 0;
}

.bar-chart svg {
    width: 100%;
    height: auto;
}

.bar-chart .bar {
    rx: 3;
    ry: 3;
    transition: opacity 0.15s ease;
}

.bar-chart .bar:hover {
    opacity: 0.85;
}

.bar-chart .bar-income {
    fill: #27ae60;
}

.bar-chart .bar-expense {
    fill: #e74c3c;
}

.bar-chart .bar-category {
    fill: #3498db;
}

.bar-chart .bar-commodity {
    fill: #9b59b6;
}

.bar-chart .bar-merchant {
    fill: #e67e22;
}

.bar-chart .bar-budget {
    fill: #2c3e50;
}

.bar-chart .bar-budget-remaining {
    fill: #bdc3c7;
}

.bar-chart .bar-label {
    font-size: 12px;
    fill: #333;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.bar-chart .bar-value {
    font-size: 11px;
    fill: #666;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.bar-chart .axis-line {
    stroke: #e0e0e0;
    stroke-width: 1;
}

/* --- Drill-down Links --- */
.drilldown-link {
    display: inline-block;
    margin-top: 0.5rem;
    padding: 0.25rem 0.75rem;
    background: #3498db;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.85rem;
    transition: background 0.15s ease;
}

.drilldown-link:hover {
    background: #2980b9;
}

.drilldown-label {
    font-size: 0.8rem;
    color: #888;
    margin-bottom: 0.25rem;
}

/* --- Budget Progress Bar --- */
.progress-bar-container {
    width: 100%;
    height: 24px;
    background: #ecf0f1;
    border-radius: 12px;
    overflow: hidden;
    margin: 0.5rem 0;
    position: relative;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 12px;
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    min-width: 2rem;
}

.progress-bar-fill.ok {
    background: #27ae60;
}

.progress-bar-fill.warning {
    background: #f39c12;
}

.progress-bar-fill.over {
    background: #e74c3c;
}

/* --- Overview Summary Visualization --- */
.summary-visual {
    display: flex;
    gap: 2rem;
    align-items: flex-end;
    margin: 1.5rem 0;
    padding: 1rem;
    background: white;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.summary-visual .chart-group {
    flex: 1;
    min-width: 0;
}

.summary-visual .chart-title {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

/* --- Category/Commodity/Merchant Card with Bar --- */
.card-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.card-bar .bar-track {
    flex: 1;
    height: 8px;
    background: #ecf0f1;
    border-radius: 4px;
    overflow: hidden;
}

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

.card-bar .bar-fill.category {
    background: #3498db;
}

.card-bar .bar-fill.commodity {
    background: #9b59b6;
}

.card-bar .bar-fill.merchant {
    background: #e67e22;
}

/* --- View Transactions Link --- */
.view-tx-link {
    display: inline-block;
    margin-top: 0.5rem;
    padding: 0.3rem 0.8rem;
    background: #2c3e50;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.8rem;
    transition: background 0.15s ease;
}

.view-tx-link:hover {
    background: #1a252f;
}

/* --- Drill-down Context Header --- */
.drilldown-context {
    background: #eaf4fd;
    border: 1px solid #bee0f5;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: #2c3e50;
}

.drilldown-context strong {
    color: #2980b9;
}

.drilldown-context .back-link {
    color: #3498db;
    text-decoration: none;
    margin-left: 1rem;
}

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

/* --- Mobile responsive for charts --- */
@media (max-width: 600px) {
    .summary-visual {
        flex-direction: column;
        gap: 1rem;
    }

    .card-bar {
        flex-direction: column;
        align-items: flex-start;
    }

    .card-bar .bar-track {
        width: 100%;
    }
}

/* --- User controls (login/logout) --- */
.user-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid #e0e0e0;
    margin-top: 1rem;
}

.user-controls .user-info {
    color: #2c3e50;
    font-size: 0.9rem;
    font-weight: 500;
}

.login-btn {
    background: #27ae60;
    color: white;
    padding: 0.4rem 1rem;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
}

.login-btn:hover {
    background: #2ecc71;
}

.logout-btn {
    background: #e74c3c;
    color: white;
    padding: 0.4rem 1rem;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
}

.logout-btn:hover {
    background: #c0392b;
}

/* --- Login page styles --- */
.login-container {
    max-width: 400px;
    margin: 2rem auto;
    padding: 2rem;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
}

.login-container h2 {
    margin-top: 0;
    color: #2c3e50;
    text-align: center;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0.4rem;
}

.form-group input {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1rem;
}

.btn-primary {
    background: #2c3e50;
    color: white;
    border: none;
    padding: 0.7rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    width: 100%;
}

.btn-primary:hover {
    background: #34495e;
}

.error {
    background: #fdecea;
    border: 1px solid #f5c6cb;
    color: #721c24;
    padding: 0.75rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.help-text {
    text-align: center;
    font-size: 0.85rem;
    color: #888;
    margin-top: 1rem;
}
