/* General styles */
body {
    font-family: Arial, sans-serif;
    padding: 0;
    margin: 0;
    color: #333;
    line-height: 1.6;
    background-color: #f5f5f5;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    color: #333;
    margin-top: 0;
}

h1 {
    font-size: 28px;
    margin-bottom: 15px;
}

h2 {
    font-size: 22px;
    margin: 30px 0 15px;
}

p {
    margin-bottom: 20px;
}

/* Header Styles */
.site-header {
    background-color: white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    padding: 15px 0;
    position: static;
    top: 0;
    z-index: 1000;
}

.site-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo img {
    height: 40px;
    width: auto;
}

.main-nav ul {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
}

.main-nav li {
    margin-left: 25px;
}

.main-nav a {
    color: #333;
    text-decoration: none;
    font-weight: 500;
    padding: 5px 0;
    position: relative;
    transition: color 0.3s;
}


.main-nav a.active {
    color: #007bff;
    font-weight: 700;
}

.main-nav a.active::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 2px;
    background-color: #000080;
    display: none;
    
}

.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 21px;
    cursor: pointer;
}

.mobile-menu-toggle span {
    display: block;
    height: 3px;
    width: 100%;
    background-color: #333;
    transition: transform 0.3s, opacity 0.3s;
}

.mobile-menu-toggle.active span:nth-child(1) {
    transform: translateY(9px) rotate(45deg);
}

.mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
    transform: translateY(-9px) rotate(-45deg);
}

/* Footer Styles */
.site-footer {
    background-color: #f5f5f5;
    padding: 40px 0;
    margin-top: 50px;
    border-top: 1px solid #e0e0e0;
}

.footer-nav ul {
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    margin: 0 0 20px;
    padding: 0;
    justify-content: center;
}

.footer-nav li {
    margin-right: 20px;
    margin-bottom: 10px;
}

.footer-nav a {
    color: #333;
    text-decoration: none;
    font-size: 14px;
}

.footer-nav a:hover {
    color: #007bff;
    text-decoration: underline;
}

.footer-content {
    border-top: 1px solid #e0e0e0;
    padding-top: 20px;
    text-align: center;
}

.site-description {
    color: #555;
    margin-bottom: 15px;
    font-size: 15px;
}

.copyright {
    color: #777;
    font-size: 14px;
}

/* Main content area */
.page-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px 15px;
}

/* Calculator styles */
.calculator-container {
    background-color: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin: 25px 0;
}

.calculator-header {
    display: grid;
    grid-template-columns: 40px 1.2fr 1.5fr 1fr 1fr 40px;
    gap: 2px;
    margin-bottom: 10px;
    font-weight: bold;
    color: #555;
}

.calculator-row {
    display: grid;
    grid-template-columns: 40px 1.2fr 1.5fr 1fr 1fr 40px;
    gap: 2px;
    margin-bottom: 10px;
    align-items: center;
    width: 100%;
    background-color: #f8fdfe;
    transition: background-color 0.2s ease;
}

.calculator-row.disabled {
    background-color: #f0f0f0; /* Lighter grey for disabled rows */
    opacity: 0.8;
}

.column {
    background-color: transparent;
    padding: 8px;
    display: flex;
    flex-direction: column;
    transition: opacity 0.2s ease;
}

.label-column {
    background-color: transparent;
    padding: 8px;
    border-radius: 6px 0 0 6px;
    transition: opacity 0.2s ease;
}

.calculator-row.disabled .column, 
.calculator-row.disabled .label-column {
    opacity: 0.7;
}

.header-column, .header-label-column {
    padding: 8px;
    font-size: 13px;
    text-transform: uppercase;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.delete-column {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    padding: 0;
}

.column:nth-child(2) {
    border-radius: 0;
}

.column:nth-child(4) {
    border-radius: 0 6px 6px 0;
    padding: 8px;
}

.column:nth-child(4) .result-container {
    width: 100%;
}

.column:nth-child(4) .result-value {
    width: 100%;
    box-sizing: border-box;
}

.summary-row {
    display: flex;
    margin-bottom: 15px;
    align-items: center;
    background-color: #f8fdfe;
    padding: 12px 15px;
    border-radius: 6px;
    font-weight: bold;
    justify-content: space-between;
}

.summary-content {
    display: flex;
    align-items: center;
}

.summary-label {
    padding-right: 10px;
}

.summary-value {
    font-size: 18px;
    color: #007bff;
    min-width: 100px;
    text-align: right;
    position: relative;
    padding-left: 12px;
}

/* Add dollar sign to summary total value */
.summary-value::before {
    content: '$';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
}

.download-csv-btn {
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 15px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
}

.download-csv-btn:hover {
    background-color: #0066d4;
}

.input-group {
    display: flex;
    width: 100%;
}

input, select {
    padding: 6px 8px;
    border: 1px solid #ddd;
    font-size: 14px;
    height: 36px;
    box-sizing: border-box;
}

.label-input {
    width: 100%;
    border-radius: 4px;
}

/* Amount input with dollar sign */
.amount-input-container {
    position: relative;
    flex: 1;
}

.amount-input-container::before {
    content: '$';
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1;
    pointer-events: none;
}

.amount-input-container .amount-input {
    width: 100%;
    padding-left: 20px;
    border-radius: 4px 0 0 4px;
    -moz-appearance: textfield;
}

input[type="number"] {
    width: 150px;
    border-radius: 4px 0 0 4px;
    -moz-appearance: textfield;
}

input[type="number"]::-webkit-inner-spin-button, 
input[type="number"]::-webkit-outer-spin-button { 
    -webkit-appearance: none;
    margin: 0;
}

select {
    width: 110px;
    border-radius: 0 4px 4px 0;
    padding-right: 20px;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23008081%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 10px;
}

input:focus, select:focus {
    outline: none;
    border-color: #007bff;
    z-index: 1;
}

.toggle-container {
    display: flex;
    align-items: center;
    height: 36px;
}

.toggle-btn {
    flex: 1;
    padding: 8px 5px;
    height: 36px;
    text-align: center;
    background-color: white;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
    border: 1px solid #ddd;
    margin-right: -1px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.toggle-btn:first-child {
    border-radius: 4px 0 0 4px;
}

.toggle-expand {
    width: 36px;
    border-radius: 0 4px 4px 0;
    margin-right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #008081;
}

.toggle-btn.active {
    background-color: #008081;
    color: white;
    border-color: #008081;
    position: relative;
    z-index: 1;
}

.toggle-btn:hover:not(.active) {
    background-color: #f0f0f0;
}

.hidden-options {
    display: none;
    position: absolute;
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    z-index: 10;
    margin-top: 40px;
    width: auto;
    min-width: 120px;
}

.hidden-options .toggle-btn {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 15px;
    border: none;
    border-bottom: 1px solid #eee;
    border-radius: 0;
    margin: 0;
    justify-content: flex-start;
}

.hidden-options .toggle-btn:last-child {
    border-bottom: none;
}

.hidden-options .toggle-btn:first-child {
    border-radius: 4px 4px 0 0;
}

.hidden-options .toggle-btn:last-child {
    border-radius: 0 0 4px 4px;
}

.hidden-options .toggle-btn:hover {
    background-color: #f5f5f5;
}

/* Result container with dollar sign */
.result-container {
    display: flex;
    align-items: center;
    height: 36px;
    width: 100%;
    position: relative;
}

.result-container::before {
    content: '$';
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1;
    pointer-events: none;
}

.result-value {
    width: 100%;
    height: 36px;
    padding: 6px 8px 6px 20px;
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    text-align: right;
    box-sizing: border-box;
    box-shadow: none;
    -webkit-appearance: none;
    -moz-appearance: textfield;
    appearance: none;
    margin: 0;
}

.add-row-btn {
    display: block;
    width: 40%;
    padding: 10px;
    background-color: #0f4d4d;
    color: white;
    border: none;
    border-radius: 4px;
    margin-top: 15px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    text-align: center;
}

.add-row-btn-container {
    display: flex;
    justify-content: flex-start;
}

.add-row-btn:hover {
    background-color: #0a3d3d;
}

.delete-row {
    color: #dc3545;
    background: none;
    border: none;
    width: 24px;
    height: 24px;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    font-weight: bold;
}

.delete-row:hover {
    color: #c82333;
}

/* New styles for column edit functionality */
.edit-column-icon {
    font-size: 11px;
    margin-left: 5px;
    cursor: pointer;
    color: #008081;
}

.edit-column-icon:hover {
    color: #008081;
}

.column-edit-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    z-index: 20;
    min-width: 150px;
    margin-top: 5px;
}

.dropdown-title {
    padding: 8px 15px;
    font-weight: bold;
    border-bottom: 1px solid #eee;
    font-size: 13px;
    color: #555;
}

.dropdown-option {
    padding: 8px 15px;
    font-size: 13px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background-color 0.2s;
    font-weight: normal; /* Make dropdown options not bold */
}

.dropdown-option:last-child {
    border-bottom: none;
}

.dropdown-option:hover {
    background-color: #f5f5f5;
}

/* Mobile edit icons - hiding for mobile view */
.mobile-edit-icon {
    display: none;
}

/* Budget Rule Row Styles */
.budget-rule-row {
    display: flex;
    margin-bottom: 15px;
    align-items: center;
    background-color: #f8fdfe;
    padding: 12px 15px;
    border-radius: 6px;
    font-weight: bold;
    justify-content: space-between;
    margin-top: 10px;
}

.budget-rule-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    text-align: center;
    padding: 0 10px;
}

.budget-rule-label {
    color: #555;
    font-size: 14px;
    margin-bottom: 5px;
}

.budget-rule-value {
    font-size: 18px;
    color: #007bff;
    position: relative;
    padding-left: 12px;
}

/* Add dollar sign to budget rule values */
.budget-rule-value::before {
    content: '$';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
}

/* Visibility toggle checkbox styles */
.visibility-column {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    font-size: 13px;
}

.visibility-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    margin: 0;
    accent-color: #008081;
}

/* Mobile responsive styles */
@media (max-width: 768px) {
    .calculator-container {
        padding: 15px;
    }
    .calculator-header {
        display: none; /* Hide headers on mobile */
    }
    .calculator-row {
        display: flex;
        flex-direction: column;
        gap: 8px;
        margin-bottom: 20px;
        border: 1px solid #ddd;
        border-radius: 6px;
        padding: 15px 15px 10px;
        position: relative;
        width: auto;
    }
    .column, .label-column {
        width: 100%;
        padding: 8px;
        border-radius: 0;
        border: none;
        background-color: transparent;
        margin-bottom: 10px;
    }
    .column:last-child {
        margin-bottom: 0;
    }
    .delete-column {
        position: absolute;
        top: 10px;
        right: 10px;
        background-color: transparent;
        border: none;
        width: auto;
        height: auto;
        padding: 0;
        margin: 0;
    }
    .visibility-column {
        position: absolute;
        top: 10px;
        left: 10px;
        z-index: 5;
    }
    
    .label-column:before, 
    .column[data-label]:before {
        content: attr(data-label);
        display: block;
        font-weight: bold;
        margin-bottom: 5px;
        font-size: 12px;
        text-transform: uppercase;
        color: #555;
    }
    
    /* Hide mobile edit dropdowns */
    .column-edit-dropdown.frequency-mobile-dropdown,
    .column-edit-dropdown.period-mobile-dropdown {
        display: none !important;
    }
    
    .hidden-options {
        width: 80%;
        left: 10%;
        margin-top: 60px;
        z-index: 100;
    }
    .add-row-btn {
        width: 100%;
    }
    /* Keep the summary row horizontal on mobile */
    .summary-row {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        flex-wrap: nowrap;
    }
    .download-csv-btn {
        margin-bottom: 0;
        width: auto;
        white-space: nowrap;
    }
    .summary-content {
        flex-shrink: 0;
        width: auto;
        justify-content: flex-end;
    }
    .input-group {
        width: 100%;
    }
    .result-container {
        width: 100% !important;
    }
    .result-value {
        width: 100% !important;
    }
    .toggle-container {
        width: 100%;
    }
    
    /* Mobile menu */
    .mobile-menu-toggle {
        display: flex;
    }
    
    .main-nav {
        position: absolute;
        top: 70px;
        left: 0;
        right: 0;
        background-color: white;
        box-shadow: 0 5px 5px rgba(0,0,0,0.1);
        padding: 0;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease-out;
    }
    
    .main-nav.active {
        max-height: 300px;
    }
    
    .main-nav ul {
        flex-direction: column;
        padding: 10px 0;
    }
    
    .main-nav li {
        margin: 0;
    }
    
    .main-nav a {
        display: block;
        padding: 10px 15px;
    }
    
    .main-nav a.active::after {
        display: none;
    }
    
    .main-nav a.active {
        background-color: #f5f5f5;
    }
    
    .footer-nav ul {
        flex-direction: column;
        align-items: center;
    }
    
    .footer-nav li {
        margin-right: 0;
    }
    
    .budget-rule-row {
        flex-direction: column;
        gap: 10px;
    }
    
    .budget-rule-item {
        width: 100%;
        flex-direction: row;
        justify-content: space-between;
    }
    
    .budget-rule-label {
        margin-bottom: 0;
    }
}

/* Mobile Accordion Styles */
@media (max-width: 768px) {
    /* Row styling for accordion */
    .calculator-row {
        display: flex;
        flex-direction: column;
        margin-bottom: 10px;
        border: 1px solid #ddd;
        border-radius: 6px;
        overflow: visible !important; /* Allow dropdowns to show outside */
        padding: 0;
        position: relative;
        width: auto;
    }
    
    /* Accordion header */
    .accordion-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 12px 15px;
        background-color: #f8fdfe;
        cursor: pointer;
        width: 100%;
        box-sizing: border-box;
    }
    
    /* Apply disabled styling to accordion header */
    .calculator-row.disabled .accordion-header {
        background-color: #f0f0f0;
        opacity: 0.8;
    }
    
    /* Left side of header with checkbox and label */
    .accordion-header-left {
        display: flex;
        align-items: center;
        flex: 1;
        overflow: hidden;
    }
    
    /* Style for the item name in header */
    .accordion-item-name {
        margin-left: 10px;
        font-weight: 500;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    /* Accordion content (the expanded part) */
    .accordion-content {
        display: none;
        padding: 15px;
        border-top: 1px solid #eee;
        position: relative;
        overflow: visible !important; /* Allow dropdowns to show outside */
    }
    
    /* When accordion is expanded */
    .calculator-row.expanded .accordion-content {
        display: block;
    }
    
    /* Accordion toggle arrow */
    .accordion-toggle {
        width: 20px;
        height: 20px;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: transform 0.3s;
        margin-left: 10px; /* Added space between delete button and arrow */
    }
    
    /* Rotate arrow when expanded */
    .calculator-row.expanded .accordion-toggle {
        transform: rotate(180deg);
    }
    
    /* Move delete button to header for mobile */
    .delete-column {
        position: static;
        margin-left: 10px;
        background: none;
        width: auto;
        height: auto;
    }
    
    /* Keep visibility checkbox in header */
    .visibility-column {
        position: static;
    }
    
    /* Row content styling */
    .column, .label-column {
        width: 100%;
        padding: 8px 0;
        margin-bottom: 15px;
        position: relative;
    }
    
    /* Input label styling */
    .column:before, 
    .label-column:before,
    .column[data-label]:before {
        content: attr(data-label);
        display: block;
        font-weight: bold;
        margin-bottom: 8px;
        font-size: 12px;
        text-transform: uppercase;
        color: #555;
    }
    
    /* Make sure label column is visible in expanded content */
    .accordion-content .label-column {
        display: block;
    }
    
    /* Full-width inputs */
    .input-group,
    .toggle-container,
    .result-container {
        width: 100%;
    }
    
    /* Fix for duplicate rows in collapsed view */
    .calculator-row > .visibility-column,
    .calculator-row > .column,
    .calculator-row > .label-column,
    .calculator-row > .delete-column {
        display: none !important;
    }
    
    /* Fix for dropdown positioning in accordion */
    .accordion-content .toggle-container {
        position: relative;
        overflow: visible;
    }
    
    .accordion-content .hidden-options {
        position: absolute;
        z-index: 1000;
        background-color: white;
        border: 1px solid #ddd;
        border-radius: 4px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        min-width: 120px;
        width: 100%;
        left: 0;
        top: 40px; /* Position below the toggle buttons */
    }
}
