/* ===========================
   Settings Page Styles
=========================== */

/* ===========================
   AG Grid Theme Overrides
=========================== */

/* AG Grid Dark Theme Colors */
.ag-theme-alpine-dark {
    --ag-background-color: #2D3238;  /* Base charcoal */
    --ag-odd-row-background-color: #363C43;  /* Slightly lighter charcoal for alternating */
    --ag-header-background-color: #25292E;  /* Darker charcoal for header */
    --ag-row-hover-color: #3E444B;  /* Hover state */
    --ag-border-color: #404650;  /* Borders */
}

/* AG Grid Placeholder Text Auto-Selection */
.ag-theme-alpine .ag-cell-editing input,
.ag-theme-alpine .ag-cell-editing textarea {
    /* Auto-select all text when input is focused */
    user-select: all;
}

/* Style for placeholder cells - grey and italic */
.ag-cell.placeholder-cell {
    color: var(--gray-400);
    font-style: italic;
}

/* When editing a placeholder cell, still show grey until user types */
.ag-cell-editing.placeholder-cell input {
    color: var(--gray-400);
    font-style: italic;
}

/* Once user starts typing, text becomes normal */
.ag-cell-editing input:not(:placeholder-shown) {
    color: var(--text-primary);
    font-style: normal;
}

/* ===========================
   Budget Percentage Styles
=========================== */

/* Budget percentage display - purple text with smooth transitions */
.budget-percentage {
    color: #9333ea;
    font-size: 1.1rem;
    font-weight: 600;
    margin-left: 15px;
    min-width: 60px;
    text-align: right;
    padding-right: 10px;
    transition: all 0.2s ease-in-out;
}

/* Hover effect for budget percentage */
.budget-percentage:hover {
    color: #7c3aed;
    transform: scale(1.05);
}

/* Budget input styling adjustments */
.budget-input {
    transition: border-color 0.2s ease-in-out;
}

.budget-input:focus {
    border-color: #9333ea !important;
    box-shadow: 0 0 0 0.2rem rgba(147, 51, 234, 0.25) !important;
}

/* ===========================
   Income Row: Unbudgeted Display (Stacked)
=========================== */

/* Dollar amount display - color set dynamically by JavaScript */
.budget-unbudgeted-amount {
    font-size: 1.1rem;
    font-weight: 600;
    margin-left: 8px;
    transition: all 0.2s ease-in-out;
}

/* Percentage display - color set dynamically by JavaScript */
.budget-unbudgeted-percentage {
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.2s ease-in-out;
}

/* Hover effects */
.budget-unbudgeted-amount:hover,
.budget-unbudgeted-percentage:hover {
    opacity: 0.8;
}

/* Responsive adjustments for smaller screens */
@media (max-width: 768px) {
    .budget-percentage {
        font-size: 1rem;
        min-width: 50px;
        margin-left: 10px;
    }
    
    .budget-unbudgeted-amount {
        font-size: 1rem;
    }
    
    .budget-unbudgeted-percentage {
        font-size: 0.9rem;
    }
}

/* ===========================
   Budget Percentage Styles
=========================== */

/* Budget percentage display - purple text with smooth transitions */
.budget-percentage {
    color: #9333ea;
    font-size: 1.1rem;
    font-weight: 600;
    margin-left: 15px;
    min-width: 60px;
    text-align: right;
    padding-right: 10px;
    transition: all 0.2s ease-in-out;
}

/* Hover effect for budget percentage */
.budget-percentage:hover {
    color: #7c3aed;
    transform: scale(1.05);
}

/* Budget input styling adjustments */
.budget-input {
    transition: border-color 0.2s ease-in-out;
}

.budget-input:focus {
    border-color: #9333ea !important;
    box-shadow: 0 0 0 0.2rem rgba(147, 51, 234, 0.25) !important;
}

/* Responsive adjustments for smaller screens */
@media (max-width: 768px) {
    .budget-percentage {
        font-size: 1rem;
        min-width: 50px;
        margin-left: 10px;
    }
}

/* ===========================
   Savings Goals Card Styles
   (Shadcn Design System - Minimal & Elegant)
=========================== */

/* Individual goal card styling - shadcn aesthetic */
.goal-card {
    transition: all 0.15s ease;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    background-color: var(--bg-primary) !important;
    border: 1px solid var(--border-ui) !important;
}

.goal-card:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.05) !important;
    border-color: var(--brand-purple) !important;
    background-color: var(--bg-secondary) !important;
}

/* Card body padding */
.goal-card .card-body {
    padding: 0.75rem !important;
}

/* Goal card inputs - shadcn clean styling */
.goal-card .form-control {
    transition: all 0.15s ease;
    padding: 0.375rem 0.75rem;
    height: auto;
    text-align: center;
}

/* Purple focus ring - brand consistency */
.goal-card .goal-name-input:focus,
.goal-card .goal-amount-input:focus {
    border-color: var(--brand-purple) !important;
    background-color: var(--bg-secondary) !important;
    box-shadow: 0 0 0 3px rgba(180, 100, 255, 0.15) !important;
    outline: none;
}

/* Placeholder styling for goal inputs - theme-aware */
.goal-card .goal-name-input::placeholder,
.goal-card .goal-amount-input::placeholder {
    color: var(--text-secondary) !important;
    opacity: 0.7;
}

/* Input group text focus handling */
.goal-card .input-group:focus-within .input-group-text {
    border-color: var(--brand-purple) !important;
    background-color: var(--bg-secondary) !important;
}

.goal-card .input-group-text {
    padding: 0.375rem 0.75rem;
    transition: all 0.15s ease;
}

/* Delete button styling - ghost with red hover */
.goal-card .delete-goal-btn {
    transition: all 0.15s ease;
}

.goal-card .delete-goal-btn:hover {
    background-color: var(--bg-hover) !important;
    color: var(--error-red) !important;
    border: none !important;
}

/* Add goal button - full brand purple */
#add-savings-goal-btn {
    transition: all 0.15s ease;
    padding: 0.5rem 1rem;
    margin-top: 0.5rem;
    background-color: var(--brand-purple) !important;
    border-color: var(--brand-purple) !important;
    color: white !important;
    font-weight: 500 !important;
}

#add-savings-goal-btn:hover {
    background-color: var(--brand-purple-dark) !important;
    border-color: var(--brand-purple-dark) !important;
    color: white !important;
    box-shadow: 0 4px 6px -1px rgba(180, 100, 255, 0.3), 0 2px 4px -1px rgba(180, 100, 255, 0.2);
    transform: translateY(-1px);
}

#add-savings-goal-btn:active {
    background-color: var(--brand-purple-active) !important;
    border-color: var(--brand-purple-active) !important;
    transform: translateY(0);
}

/* Empty state styling */
#savings-goals-container > .text-center {
    opacity: 0.9;
    transition: opacity 0.15s ease;
}

#savings-goals-container > .text-center:hover {
    opacity: 1;
}

/* Row spacing */
.goal-card .row {
    margin: 0;
}

.goal-card .row > div {
    padding-left: 0.25rem;
    padding-right: 0.25rem;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .goal-card {
        margin-bottom: 0.75rem;
    }
    
    .goal-card .card-body {
        padding: 0.625rem !important;
    }
    
    .goal-card .btn {
        font-size: 0.85rem;
    }
    
    .goal-card .form-control {
        font-size: 0.875rem;
        padding: 0.35rem 0.65rem;
    }
}

/* ===========================
   Checklist Task Card Styles
   (Shadcn Design System - Minimal & Elegant)
=========================== */

/* Individual checklist card styling - shadcn aesthetic */
.checklist-task-card {
    transition: all 0.15s ease;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    background-color: var(--bg-primary) !important;
    border: 1px solid var(--border-ui) !important;
}

.checklist-task-card:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.05) !important;
    background-color: var(--bg-secondary) !important;
    border-color: var(--brand-purple) !important;
    border-color: #cbd5e1 !important;
    background-color: rgba(180, 100, 255, 0.03) !important; /* Very subtle brand purple tint on hover */
}

/* Card body padding */
.checklist-task-card .card-body {
    padding: 0.75rem !important;
}

/* Task input - shadcn clean styling */
.checklist-task-card .form-control {
    transition: all 0.15s ease;
    padding: 0.375rem 0.75rem;
    height: auto;
    text-align: center;
}

/* Purple focus ring - brand consistency */
.checklist-task-card .task-name-input:focus {
    border-color: var(--brand-purple) !important;
    background-color: var(--bg-secondary) !important;
    box-shadow: 0 0 0 3px rgba(180, 100, 255, 0.15) !important;
    outline: none;
}

/* Placeholder styling for checklist task inputs - theme-aware */
.checklist-task-card .task-name-input::placeholder {
    color: var(--text-secondary) !important;
    opacity: 0.7;
}

/* Delete button styling - ghost with red hover */
.checklist-task-card .delete-task-btn {
    transition: all 0.15s ease;
}

.checklist-task-card .delete-task-btn:hover {
    background-color: var(--bg-hover) !important;
    color: var(--error-red) !important;
    border: none !important;
}

/* Add task button - full brand purple (matching Add Savings Goal) */
#add-checklist-task-btn {
    transition: all 0.15s ease;
    padding: 0.5rem 1rem;
    margin-top: 0.5rem;
    background-color: var(--brand-purple) !important;
    border-color: var(--brand-purple) !important;
    color: white !important;
    font-weight: 500 !important;
}

#add-checklist-task-btn:hover {
    background-color: var(--brand-purple-dark) !important;
    border-color: var(--brand-purple-dark) !important;
    color: white !important;
    box-shadow: 0 4px 6px -1px rgba(180, 100, 255, 0.3), 0 2px 4px -1px rgba(180, 100, 255, 0.2);
    transform: translateY(-1px);
}

#add-checklist-task-btn:active {
    background-color: var(--brand-purple-active) !important;
    border-color: var(--brand-purple-active) !important;
    transform: translateY(0);
}

/* Empty state styling */
#checklist-tasks-container > .text-center {
    opacity: 0.9;
    transition: opacity 0.15s ease;
}

#checklist-tasks-container > .text-center:hover {
    opacity: 1;
}

/* Row spacing */
.checklist-task-card .row {
    margin: 0;
}

.checklist-task-card .row > div {
    padding-left: 0.25rem;
    padding-right: 0.25rem;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .checklist-task-card {
        margin-bottom: 0.75rem;
    }
    
    .checklist-task-card .card-body {
        padding: 0.625rem !important;
    }
    
    .checklist-task-card .btn {
        font-size: 0.85rem;
    }
    
    .checklist-task-card .form-control {
        font-size: 0.875rem;
        padding: 0.35rem 0.65rem;
    }
}

/* ===========================
   Budget Card Styles
   (Shadcn Design System - Minimal & Elegant)
=========================== */

/* Special Income card styling */
.income-card {
    transition: all 0.15s ease;
    border-radius: 8px;
    margin-bottom: 1rem;
    background-color: var(--bg-primary) !important;
    border: 1px solid var(--border-ui) !important;
}

.income-card:hover {
    background-color: var(--bg-secondary) !important;
    border-color: var(--brand-purple) !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.05) !important;
    border-color: #a7f3d0 !important; /* Slightly darker green on hover */
    background-color: rgba(16, 185, 129, 0.02) !important; /* Very subtle green tint */
}

/* Income card body padding */
.income-card .card-body {
    padding: 1rem !important;
}

/* Individual budget category card styling */
.budget-category-card {
    transition: all 0.15s ease;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    background-color: var(--bg-primary) !important;
    border: 1px solid var(--border-ui) !important;
}

.budget-category-card:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.05) !important;
    background-color: var(--bg-secondary) !important;
    border-color: var(--brand-purple) !important;
    border-color: #cbd5e1 !important;
    background-color: rgba(180, 100, 255, 0.03) !important; /* Very subtle brand purple tint on hover */
}

/* Budget card body padding */
.budget-category-card .card-body {
    padding: 0.75rem !important;
}

/* Budget card inputs - shadcn clean styling */
.budget-category-card .form-control,
.income-card .form-control {
    transition: all 0.15s ease;
    padding: 0.375rem 0.75rem;
    height: auto;
    text-align: center;
}

/* Purple focus ring - brand consistency */
.budget-category-card .form-control:focus,
.income-card .form-control:focus {
    border-color: var(--brand-purple) !important;
    background-color: var(--bg-secondary) !important;
    box-shadow: 0 0 0 3px rgba(180, 100, 255, 0.15) !important;
    outline: none;
}

/* Input group text focus handling */
.budget-category-card .input-group:focus-within .input-group-text,
.income-card .input-group:focus-within .input-group-text {
    border-color: var(--brand-purple) !important;
    background-color: var(--bg-secondary) !important;
}

.budget-category-card .input-group-text,
.income-card .input-group-text {
    padding: 0.375rem 0.75rem;
    transition: all 0.15s ease;
}

/* Single-column grid for budget category cards - always stack vertically */
.budget-category-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

/* Shadcn-style reusable components */
.shadcn-card {
    transition: all 0.15s ease;
    border-radius: 8px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-ui);
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.shadcn-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.04);
    border-color: var(--brand-purple);
}

.shadcn-card-body {
    padding: 0.75rem !important;
}

/* Inputs within Shadcn cards */
.shadcn-input {
    border: 1px solid var(--border-ui) !important;
    background-color: var(--bg-tertiary) !important;
    border-radius: 6px !important;
    font-size: 0.9rem !important;
    padding: 0.375rem 0.75rem !important;
    height: auto !important;
    color: var(--text-primary) !important;
    text-align: center !important;
}

.shadcn-input:focus {
    border-color: var(--brand-purple) !important;
    box-shadow: 0 0 0 3px rgba(180, 100, 255, 0.15) !important;
    background-color: var(--bg-secondary) !important;
}

.shadcn-input-group-text {
    border: 1px solid var(--border-ui) !important;
    background-color: var(--bg-tertiary) !important;
    border-right: none !important;
    border-radius: 6px 0 0 6px !important;
    font-size: 0.85rem !important;
    padding: 0.375rem 0.75rem !important;
    color: var(--text-secondary) !important;
}

.shadcn-input-right {
    border-left: none !important;
    border-radius: 0 6px 6px 0 !important;
}

.shadcn-input-group {
    transition: all 0.15s ease;
}

/* Tablet responsive - stack to single column on smaller tablets */
@media (max-width: 991px) {
    .budget-category-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
}

/* Mobile responsive */
@media (max-width: 768px) {
    /* Stack budget cards to single column on mobile */
    .budget-category-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .income-card {
        margin-bottom: 0.75rem;
    }
    
    .income-card .card-body {
        padding: 0.75rem !important;
    }
    
    .budget-category-card {
        margin-bottom: 0;
    }
    
    .budget-category-card .card-body {
        padding: 0.625rem !important;
    }
    
    .budget-category-card .form-control,
    .income-card .form-control {
        font-size: 0.875rem;
        padding: 0.35rem 0.65rem;
    }
}

/* ===========================
   Desktop Layout Reordering (992px+)
=========================== */
@media (min-width: 992px) {
    /* Use CSS Grid for precise 2-column layout */
    .settings-sections-row {
        display: grid;
        grid-template-columns: 1fr 1fr; /* Two equal columns */
        grid-template-rows: auto auto auto; /* Three rows */
        column-gap: 1.5rem; /* Horizontal spacing between columns (24px) - matches expenses page */
        row-gap: 0; /* Vertical spacing handled by margin-bottom on cards */
    }
    
    /* Both columns need to allow their children to be positioned in the grid */
    #settings-left-col,
    #settings-right-col {
        display: contents; /* Makes the column wrappers "disappear" */
    }
    
    /* Position each section in the grid with Bootstrap-style margins (matching expenses page) */
    .settings-bank-section {
        grid-column: 1; /* Left column */
        grid-row: 1; /* First row */
        margin-bottom: 1.5rem; /* Bootstrap mb-4 equivalent (24px) - matches expenses page */
    }
    
    .settings-budget-section {
        grid-column: 2; /* Right column */
        grid-row: 1 / 4; /* Span all 3 rows (full height) */
        margin-bottom: 0; /* No bottom margin for full-height card */
    }
    
    .settings-savings-section {
        grid-column: 1; /* Left column */
        grid-row: 2; /* Second row */
        margin-bottom: 1.5rem; /* Bootstrap mb-4 equivalent (24px) - matches expenses page */
    }
    
    .settings-checklist-section {
        grid-column: 1; /* Left column */
        grid-row: 3; /* Third row */
        margin-bottom: 0; /* No bottom margin for last card */
    }
}

/* ===========================
   Settings Header Mobile/Tablet Layout (max-width: 991px)
=========================== */
@media (max-width: 991px) {
    /* Use flexbox for proper card ordering on mobile/tablet */
    .settings-sections-row {
        display: flex;
        flex-direction: column;
    }
    
    /* Make column wrappers transparent so cards can be reordered */
    #settings-left-col,
    #settings-right-col {
        display: contents;
    }
    
    /* Reorder cards to show: 1 (Bank), 2 (Budget), 3 (Savings), 4 (Checklist) */
    .settings-bank-section { order: 1; }
    .settings-budget-section { order: 2; }
    .settings-savings-section { order: 3; }
    .settings-checklist-section { order: 4; }
    
    /* Add Bootstrap-style margins for mobile/tablet (matching expenses page mb-3) */
    .settings-bank-section,
    .settings-budget-section,
    .settings-savings-section {
        margin-bottom: 1rem; /* Bootstrap mb-3 equivalent (16px) for mobile */
    }
    
    .settings-checklist-section {
        margin-bottom: 0; /* No bottom margin for last card */
    }
    
    /* Settings header row reorganization */
    .settings-header-row {
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }
    
    /* Header and hint take full width */
    .settings-header-col {
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
        margin-bottom: 0.5rem;
    }
    
    /* Manage subscription and theme toggle row */
    .settings-controls-col {
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
        order: 2;
    }
    
    /* Date range selector takes full width in its own row */
    .settings-date-range-col {
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
        order: 3;
    }
    
    /* Make manage subscription button and theme toggle horizontal */
    .settings-controls-col > div {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 1rem;
    }
    
    /* Manage subscription button takes up more space */
    .settings-controls-col .mb-2 {
        flex: 1;
        margin-bottom: 0 !important;
        min-width: 0;
    }
    
    /* Theme toggle container */
    .settings-controls-col > div > div:last-child {
        flex-shrink: 0;
        padding: 0 !important;
    }
}

/* Additional mobile optimizations for smaller screens */
@media (max-width: 576px) {
    /* Stack manage subscription and theme toggle on very small screens if needed */
    .settings-controls-col > div {
        gap: 0.75rem;
    }
    
    /* Make settings hint more compact */
    #settings-hint {
        font-size: 0.85rem !important;
        padding: 8px !important;
    }
    
    /* Ensure date dropdowns stack properly */
    .settings-date-range-col .row {
        margin-left: 0;
        margin-right: 0;
    }
    
    .settings-date-range-col .row > div {
        padding-left: 8px;
        padding-right: 8px;
    }
}

