/* --- Global & Reset --- */
:root {
    /* Material Design 3 Color Palette - Dark Theme Inspired */
    --md3-sys-color-primary: #6750A4; /* Deep Purple */
    --md3-sys-color-on-primary: #FFFFFF;
    --md3-sys-color-primary-container: #EADDFF;
    --md3-sys-color-on-primary-container: #21005D;

    --md3-sys-color-secondary: #625B71; /* Muted Gray/Purple */
    --md3-sys-color-on-secondary: #FFFFFF;
    --md3-sys-color-secondary-container: #E8DEF8;

    --md3-sys-color-tertiary: #7D5260; /* Muted Rose */
    --md3-sys-color-on-tertiary: #FFFFFF;
    --md3-sys-color-tertiary-container: #FFD8E4;

    --md3-sys-color-background: #1C1B1F; /* Very Dark Background */
    --md3-sys-color-on-background: #E6E1E5; /* Light Text */
    --md3-sys-color-surface: #1C1B1F;
    --md3-sys-color-on-surface: #E6E1E5;

    --md3-sys-color-error: #CF6679;
    --md3-sys-color-surface-variant: #49454F;
    --md3-sys-color-on-surface-variant: #CAC4D0;

    --shadow-elevation-1: 0px 1px 3px rgba(0, 0, 0, 0.2), 0px 1px 2px rgba(0, 0, 0, 0.12);
    --shadow-elevation-3: 0px 3px 5px rgba(0, 0, 0, 0.3), 0px 1px 10px rgba(0, 0, 0, 0.2), 0px 2px 4px rgba(0, 0, 0, 0.14);
}

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

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--md3-sys-color-background);
    color: var(--md3-sys-color-on-background);
    line-height: 1.6;
}

a {
    text-decoration: none;
    color: var(--md3-sys-color-primary);
    transition: color 0.3s ease;
}

a:hover {
    color: var(--md3-sys-color-tertiary);
}

.container {
    width: 90%;
    max-width: 1400px;
    margin: 24px auto;
}

/* --- Header & Navigation --- */
.app-header {
    background-color: var(--md3-sys-color-surface);
    box-shadow: var(--shadow-elevation-1);
    padding: 16px 5%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--md3-sys-color-primary);
}

.main-nav {
    display: flex;
    gap: 24px;
}

.nav-item {
    color: var(--md3-sys-color-on-surface-variant);
    padding: 8px 12px;
    border-radius: 20px;
    transition: background-color 0.3s ease, color 0.3s ease;
    font-weight: 500;
}

.nav-item:hover {
    color: var(--md3-sys-color-on-surface);
    background-color: var(--md3-sys-color-surface-variant);
}

.nav-item.active {
    color: var(--md3-sys-color-on-primary);
    background-color: var(--md3-sys-color-primary);
}

/* --- Buttons & Inputs --- */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 20px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
    font-size: 0.9rem;
}

.btn-primary {
    background-color: var(--md3-sys-color-primary);
    color: var(--md3-sys-color-on-primary);
}

.btn-primary:hover {
    background-color: var(--md3-sys-color-secondary);
    box-shadow: var(--shadow-elevation-1);
}

.btn-secondary {
    background-color: transparent;
    color: var(--md3-sys-color-primary);
    border: 1px solid var(--md3-sys-color-primary);
}

.btn-secondary:hover {
    background-color: var(--md3-sys-color-primary-container);
}

.select-field, .select-field:focus {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--md3-sys-color-surface-variant);
    background-color: var(--md3-sys-color-surface);
    color: var(--md3-sys-color-on-background);
    appearance: none;
    cursor: pointer;
    font-size: 0.9rem;
}

.settings-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 0.9rem;
}

.settings-group input[type="number"] {
    width: auto; /* Override default block behavior for number inputs */
    max-width: 200px;
}

/* --- Cards & Layout --- */
.card {
    background-color: var(--md3-sys-color-surface);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-elevation-3);
    transition: transform 0.5s ease-out, opacity 0.5s ease-out;
    opacity: 0;
    transform: translateY(20px);
}

.card.visible {
    opacity: 1;
    transform: translateY(0);
}

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

.main-content-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 24px;
}

.large-card { grid-column: span 8; }
.medium-card { grid-column: span 4; }
.small-card { grid-column: span 3; }

.summary-card {
    padding: 20px;
}

.summary-card .icon {
    font-size: 2rem;
    margin-bottom: 10px;
    display: block;
}

.summary-card .label {
    font-size: 0.85rem;
    opacity: 0.8;
    margin-bottom: 4px;
}

.summary-card .value {
    font-size: 1.8rem;
    font-weight: 500;
}

.primary-card {
    border-left: 4px solid var(--md3-sys-color-primary);
}

.mt-16 { margin-top: 16px; }
.mt-8 { margin-top: 8px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }

/* --- Typography & Page Headers --- */
h1, h2, h3 {
    margin-bottom: 16px;
    font-weight: 500;
}

h1 {
    font-size: 2rem;
    color: var(--md3-sys-color-on-surface);
}

h3 {
    font-size: 1.25rem;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.report-controls {
    display: flex;
    gap: 10px;
}

.text-link {
    display: inline-block;
    font-size: 0.9rem;
    font-weight: 500;
    margin-top: 16px;
}

/* --- Specific Features --- */

/* Charts */
.chart-container {
    height: 300px;
    width: 100%;
    position: relative;
}

.wide-chart {
    height: 400px;
}

/* Priority List (Dashboard) */
.priority-list {
    list-style: none;
    padding: 0;
}

.priority-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--md3-sys-color-surface-variant);
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.priority-item:hover {
    background-color: var(--md3-sys-color-surface-variant);
    transform: translateX(5px);
}

.priority-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.priority-tag {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    color: white;
}

.priority-tag.High { background-color: var(--md3-sys-color-error); }
.priority-tag.Medium { background-color: var(--md3-sys-color-tertiary); }
.priority-tag.Low { background-color: var(--md3-sys-color-secondary); }

/* Savings Widget */
.savings-widget {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.progress-bar-container {
    height: 10px;
    background-color: var(--md3-sys-color-surface-variant);
    border-radius: 5px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background-color: var(--md3-sys-color-primary);
    transition: width 0.8s ease-out;
}

.savings-goals-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.goal-card {
    border: 1px solid var(--md3-sys-color-surface-variant);
    padding: 20px;
    border-radius: 12px;
    transition: border-color 0.3s ease;
}

.goal-card:hover {
    border-color: var(--md3-sys-color-primary);
}

.goal-card h4 {
    margin-bottom: 10px;
}

.budget-overview {
    display: flex;
    gap: 20px;
}

.budget-item {
    flex-grow: 1;
}

.progress-bar-container.small-bar {
    height: 8px;
}

/* Tables (Payments/Reports) */
.table-wrapper {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table th,
.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--md3-sys-color-surface-variant);
}

.data-table th {
    font-weight: 500;
    color: var(--md3-sys-color-on-surface-variant);
    text-transform: uppercase;
    font-size: 0.8rem;
}

.data-table tbody tr:hover {
    background-color: var(--md3-sys-color-surface-variant);
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
}

.badge-priority { background-color: var(--md3-sys-color-primary-container); color: var(--md3-sys-color-on-primary-container); }
.badge-interest { background-color: var(--md3-sys-color-tertiary-container); color: var(--md3-sys-color-on-tertiary-container); }

.feature-row {
    display: flex;
    gap: 20px;
}

.feature-card {
    flex: 1;
    background-color: var(--md3-sys-color-surface-variant);
    padding: 16px;
    border-radius: 12px;
}

.feature-card h4 { margin-bottom: 6px; }

.small-text {
    font-size: 0.75rem;
    opacity: 0.6;
}

.error-text { color: var(--md3-sys-color-error); }
.success-text { color: #4CAF50; /* Green for success */ }
.warning-text { color: var(--md3-sys-color-tertiary); }

/* Currency List */
.currency-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.currency-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.95rem;
}
.currency-item .rate {
    font-weight: 500;
    color: var(--md3-sys-color-secondary);
}

/* Settings Page Specific Styles */
.settings-group {
    padding: 16px 0;
    border-bottom: 1px solid var(--md3-sys-color-surface-variant);
}
.settings-group:last-child {
    border-bottom: none;
}

.toggle-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Toggle Switch Styling (MD3 Look) */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 28px;
    background-color: var(--md3-sys-color-surface-variant);
    transition: background-color 0.4s;
    border-radius: 14px;
    cursor: pointer;
}

.toggle-switch.active {
    background-color: var(--md3-sys-color-primary);
}

.toggle-switch .slider {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: var(--md3-sys-color-on-background);
    transition: transform 0.4s;
    border-radius: 50%;
}

.toggle-switch.active .slider {
    transform: translateX(20px);
    background-color: var(--md3-sys-color-on-primary);
}

/* --- Debt Page Specific Styles --- */
.debt-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.debt-summary .summary-card {
    border-radius: 12px;
}

/* --- Responsive Layouts --- */

/* Tablet Layout */
@media (max-width: 1024px) {
    .large-card { grid-column: span 12; }
    .medium-card { grid-column: span 6; }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    .report-controls {
        width: 100%;
    }
    .budget-overview {
        flex-direction: column;
    }
    .debt-summary {
        grid-template-columns: 1fr 1fr;
    }
}

/* Mobile Layout */
@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        padding: 16px 5%;
    }
    .main-nav {
        margin-top: 12px;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }
    .nav-item {
        padding: 6px 10px;
        font-size: 0.85rem;
    }

    .container {
        width: 95%;
        margin: 16px auto;
    }

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

    .summary-card .value { font-size: 1.5rem; }

    .main-content-grid {
        grid-template-columns: 1fr;
    }

    .large-card, .medium-card, .small-card {
        grid-column: span 12;
    }

    .feature-row {
        flex-direction: column;
    }

    .data-table th,
    .data-table td {
        padding: 10px 8px;
        font-size: 0.8rem;
    }

    .page-header {
        margin-bottom: 20px;
    }

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

/* --- Animations (Scroll Triggered) --- */
.animate-in {
    transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1), transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    transform: translateY(20px);
}
.animate-in.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Animation Delay Helper Classes (Set in HTML data-delay) */
.animate-in[data-delay="0.1"] { transition-delay: 0.1s; }
.animate-in[data-delay="0.2"] { transition-delay: 0.2s; }
.animate-in[data-delay="0.3"] { transition-delay: 0.3s; }
.animate-in[data-delay="0.4"] { transition-delay: 0.4s; }
.animate-in[data-delay="0.5"] { transition-delay: 0.5s; }
.animate-in[data-delay="0.6"] { transition-delay: 0.6s; }
.animate-in[data-delay="0.7"] { transition-delay: 0.7s; }
.animate-in[data-delay="0.8"] { transition-delay: 0.8s; }


/* Karbon Sites Branding */

  #karbon-promo-banner {
      position: fixed;
      bottom: 10px;
      right: 10px;
      background-color: rgba(0, 0, 0, 0.8);
      color: white;
      padding: 8px 16px;
      border-radius: 8px;
      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
      font-size: 14px;
      z-index: 10000;
      display: flex;
      align-items: center;
      gap: 10px;
      text-decoration: none;
      box-shadow: 0 4px 6px rgba(0,0,0,0.1);
      transition: transform 0.2s ease-in-out;
  }
  #karbon-promo-banner:hover {
      transform: scale(1.05);
  }
