/* css/style.css */

/* Basic Styles */
html {
    position: relative;
    min-height: 100%;
}

html::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('../img/background.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    opacity: 0.1; /* Adjust transparency here */
    z-index: -1;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    background-color: #f8f9fa; /* Light grey background */
    color: #333;
}

.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 20px;
}

/* Header & Nav */
header {
    background: #ffffff;
    padding: 1rem 0;
    border-bottom: 1px solid #dee2e6;
    margin-bottom: 2rem;
}

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

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-button {
    padding: 0.75rem 1.25rem;
    text-decoration: none;
    background-color: transparent;
    color: #495057;
    border: 1px solid transparent;
    border-radius: 8px; /* Rounded corners */
    font-weight: 500;
    transition: all 0.2s ease-in-out;
}

.nav-button.active {
    background-color: #28a745;
    color: white;
}

.nav-button:hover:not(.active) {
    background-color: #e9ecef;
}

.header-title {
    font-size: 1.25rem;
    font-weight: bold;
    margin: 0;
}

#language-selector {
    padding: 0.5rem;
    border: 1px solid #ced4da;
    border-radius: 8px; /* Rounded corners */
    background-color: #fff;
}

/* Mode Selector */
.mode-selector {
    display: flex;
    border: 1px solid #dee2e6;
    border-radius: 8px; /* Rounded corners */
    overflow: hidden;
    margin-bottom: 1.5rem;
    background-color: #e9ecef;
}

.mode-button {
    flex: 1;
    padding: 0.75rem;
    font-size: 1rem;
    font-weight: 500;
    background-color: transparent;
    color: #495057;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    border-right: 1px solid #dee2e6;
}

.mode-button:last-child {
    border-right: none;
}

.mode-button.active {
    background-color: #28a745;
    color: white;
}

.mode-button:not(.active):hover {
    background-color: #f8f9fa;
}


/* Price Container */
.price-container {
    display: flex;
    justify-content: space-around;
    background: #ffffff;
    padding: 1rem;
    border-radius: 8px; /* Rounded corners */
    border: 1px solid #dee2e6;
    margin-bottom: 2rem;
}

.price-item {
    text-align: center;
}

.price-label {
    font-size: 0.875rem;
    color: #6c757d;
    display: block;
}

.price-value {
    font-size: 1.25rem;
    font-weight: bold;
    color: #343a40;
}


/* Calculator Card */
.calculator-card {
    background: #ffffff;
    padding: 2rem;
    border-radius: 8px; /* Rounded corners */
    border: 1px solid #dee2e6;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.form-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 0;
    border-bottom: 1px solid #f0f0f0;
}
.form-row:last-of-type {
    border-bottom: none;
}
.form-row label {
    font-weight: 500;
    color: #333;
    flex-basis: 20%;
}
.input-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-grow: 1;
    justify-content: flex-end;
}

.input-group-with-description {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    flex-grow: 1;
    gap: 0.25rem;
}

.field-description {
    font-size: 0.8rem;
    color: #6c757d;
    margin: 0;
    padding: 0;
    text-align: right;
}

.input-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-align: right;
}
.amount-input {
    border: none;
    font-size: 1.2rem;
    font-weight: bold;
    text-align: right;
    background-color: transparent;
    padding: 0;
    width: 150px; /* Adjust as needed */
}
.amount-input:focus {
    outline: none;
}

/* Segmented Controls */
.segmented-control {
    display: flex;
    border: 1px solid #28a745;
    border-radius: 8px;
    overflow: hidden;
}
.sc-button {
    background-color: #fff;
    border: none;
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    color: #28a745;
    font-size: 0.9rem;
    font-weight: 500;
}
.sc-button:not(:last-child) {
    border-right: 1px solid #28a745;
}
.sc-button.active {
    background-color: #28a745;
    color: white;
}

.tax-type-selector .sc-button {
    flex: 1;
}

.currency-selector {
    flex-grow: 1;
}

.currency-selector .sc-button {
    flex: 1;
    text-align: center;
}

#regular-compounding {
    flex-grow: 1;
}

#regular-compounding .sc-button {
    flex: 1;
    text-align: center;
}

/* Quick Add Buttons */
.quick-add-buttons {
    display: flex;
    gap: 0.5rem;
}
.quick-add-buttons .quick-add-btn,
.quick-add-buttons .quick-add-btn-period,
.quick-add-buttons .quick-add-btn-regular-start,
.quick-add-buttons .quick-add-btn-regular-monthly {
    background-color: #f1f1f1;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 0.4rem 0.8rem;
    font-size: 0.9rem;
    color: #555;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}
.quick-add-buttons .quick-add-btn:hover,
.quick-add-buttons .quick-add-btn-period:hover,
.quick-add-buttons .quick-add-btn-regular-start:hover,
.quick-add-buttons .quick-add-btn-regular-monthly:hover {
    background-color: #e0e0e0;
}

/* Form Buttons */
.form-group-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}
.form-group-buttons .calculate-btn,
.form-group-buttons .secondary-btn {
    flex: 1;
}
.secondary-btn {
    padding: 0.85rem;
    font-size: 1.1rem;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    background-color: #fff;
    color: #555;
    border: 1px solid #ddd;
}
.secondary-btn:hover {
    background-color: #f8f9fa;
}

/* Hide original form styles if they conflict */
.form-group, .input-group {
    display: none;
}
#basic-calculator .form-group-buttons .calculate-btn {
    width: auto;
}

.calculator-mode h2 {
    font-size: 1.5rem;
    font-weight: bold;
    margin-top: 0;
    margin-bottom: 1.5rem;
    text-align: left;
}

/* Form Styles */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-size: 1rem;
    font-weight: 500;
    color: #495057;
    margin-bottom: 0.5rem;
}

.input-group {
    display: flex;
}

.input-group input,
#basic-form input[type="number"],
#regular-form input[type="number"] {
    flex: 1;
    padding: 0.75rem;
    font-size: 1rem;
    border: 1px solid #ced4da;
    border-radius: 8px; /* Rounded corners */
    transition: border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.input-group input:focus,
#basic-form input[type="number"]:focus {
    outline: none;
    border-color: #28a745;
    box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, .25);
}

.input-group select {
    padding: 0.75rem;
    border: 1px solid #ced4da;
    border-left: none;
    border-radius: 0 8px 8px 0; /* Rounded corners */
    background-color: #e9ecef;
}
.input-group input {
    border-right: none;
    border-radius: 8px 0 0 8px; /* Rounded corners */
}

#regular-calculator .input-group select,
#regular-calculator #regular-compounding {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    border: 1px solid #ced4da;
    border-radius: 8px; /* Rounded corners */
    background-color: #fff;
}
#regular-calculator .input-group input {
    border-radius: 8px; /* Rounded corners */
}


/* Button */
.calculate-btn {
    width: 100%;
    padding: 0.85rem;
    font-size: 1.1rem;
    font-weight: bold;
    color: #fff;
    background-color: #28a745;
    border: 1px solid #28a745;
    border-radius: 8px; /* Rounded corners */
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
}

.calculate-btn:hover {
    background-color: #218838;
}

/* Results & Info Sections */
#results-container, .info-section {
    margin-top: 2rem;
    background: #ffffff;
    padding: 2rem;
    border-radius: 8px; /* Rounded corners */
    border: 1px solid #dee2e6;
}

#results-container h3 {
    margin-top: 0;
    font-size: 1.25rem;
    font-weight: bold;
    margin-bottom: 1rem;
}

.summary {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem;
    background-color: #f8f9fa;
    border-radius: 8px; /* Rounded corners */
    margin-bottom: 1.5rem;
}

.summary-left {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.summary-right {
    align-self: flex-end;
}

.summary span {
    font-size: 1rem;
}

.summary strong {
    color: #495057;
}

.number {
    font-weight: bold;
}

.text-green {
    color: #28a745;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    font-size: 0.9em;
}

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

thead th {
    background-color: #f8f9fa;
    font-weight: 500;
    color: #495057;
}

tbody tr:nth-child(even) {
    background-color: #f8f9fa;
}

.info-section h2 {
    margin-top: 0;
}

/* Ad container styles */
.ad-container {
    text-align: center;
    margin-top: 2rem;
}

.top-ad-container {
    position: sticky;
    top: 0;
    width: 100%;
    z-index: 1000;
    background-color: #fff;
    text-align: center;
    padding: 5px 0;
    border-bottom: 1px solid #ddd;
}

.ad-disclosure {
    font-size: 12px;
    color: #6c757d;
    margin: 5px 0 0;
}

/* Responsive Styles */
@media (max-width: 768px) {
    .top-ad-container {
        position: sticky;
        top: 0;
        z-index: 1000;
    }

    body {
        font-size: 14px; /* Adjust base font size for mobile */
        padding-top: 0; /* Adjust if header becomes fixed */
    }

    header {
        /* position: sticky; - Removed to allow header to scroll */
        /* top: 185px; */
        /* z-index: 1000; */
        background-color: #ffffff; /* Or match the body background */
        box-shadow: 0 2px 4px rgba(0,0,0,0.1); /* Optional: add shadow for better separation */
    }

    .container {
        padding: 0 15px;
    }
    
    header .container {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    .header-left {
        order: 2;
        width: 100%;
        display: flex;
        flex-wrap: wrap; /* Allow buttons to wrap */
        gap: 0.5rem; /* Adjust gap for mobile */
        justify-content: center;
    }
    .nav-button {
        padding: 0.6rem 0.5rem; /* Adjust padding */
        font-size: 0.8rem; /* Adjust font size */
        flex-grow: 1; /* Allow buttons to grow and fill space */
        text-align: center;
    }

    /* New rules for single-line form rows on mobile */
    .form-row-inline {
        flex-direction: row;
        align-items: center;
        gap: 10px;
    }

    .form-row-inline > .input-wrapper {
        flex-direction: row;
        flex-grow: 1;
        justify-content: flex-end;
    }

    .form-row-inline .amount-input {
        width: 80px; /* Adjust input width to fit */
    }

    .form-row-inline .input-display {
        flex-direction: row;
        align-items: center;
    }
    
    .form-row-inline > label {
        margin-bottom: 0;
    }

    #regular-period-unit .sc-button,
    #regular-interest-unit .sc-button {
        padding: 0.5rem 0.8rem; /* Adjust padding for smaller buttons */
        font-size: 0.8rem; /* Adjust font size */
    }

    .controls {
        order: 1;
        width: 100%;
        align-self: flex-end; /* Align language selector to the right */
    }

    #regular-compounding {
        flex-wrap: wrap; /* Allow buttons to wrap */
        -ms-overflow-style: none;  /* IE and Edge */
        scrollbar-width: none;  /* Firefox */
    }

    .flex-break {
        flex-basis: 100%;
        height: 0;
    }

    #regular-compounding::-webkit-scrollbar {
        display: none; /* Hide scrollbar for Chrome, Safari and Opera */
    }
    
    #regular-compounding .sc-button {
        font-size: 0.96rem; /* Increase font size by 20% */
        white-space: nowrap; /* Prevent text from wrapping */
        flex-basis: auto; /* Allow buttons to have natural width */
    }

    .mode-selector {
        flex-direction: column;
    }

    .price-container {
        flex-direction: column;
        align-items: flex-start;
    }

    .price-item {
        margin-bottom: 8px;
    }

    .price-label {
        display: inline;
        margin-right: 8px;
    }

    .calculator-card {
        padding: 15px;
    }

    .form-row, .input-wrapper, .input-display {
        flex-direction: column;
        align-items: stretch;
    }

    .form-row label {
        margin-bottom: 8px;
        text-align: left;
    }

    .quick-add-buttons, .segmented-control {
        margin-bottom: 10px;
        justify-content: flex-start;
    }
    
    .quick-add-btn, .sc-button {
        padding: 8px 10px;
        font-size: 0.85rem;
    }

    .input-wrapper .input-display {
        flex-direction: row; /* Keep input and currency/symbol together */
        align-items: center;
    }

    .amount-input {
        width: 100%;
    }

    .form-group-buttons {
        flex-direction: column;
    }

    .calculate-btn, .secondary-btn {
        width: 100%;
        margin-bottom: 10px;
    }

    .secondary-btn {
        margin-right: 0;
    }

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

    .summary-left, .summary-right {
        margin-bottom: 10px;
    }

    table {
        font-size: 0.8em; /* Reduce font size for mobile */
    }

    th, td {
        padding: 6px;
        text-align: center;
        white-space: nowrap;
    }
} 

.table-container {
    overflow-x: auto;
    width: 100%;
}
/* Scroll to Top Button */
#scrollTopBtn {
    display: none; /* Hidden by default */
    position: fixed;
    bottom: 20px;
    right: 30px;
    z-index: 99;
    font-size: 18px;
    border: none;
    outline: none;
    background-color: #28a745;
    color: white;
    cursor: pointer;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1.2;
    font-size: 14px;
    text-align: center;
}

#scrollTopBtn:hover {
    background-color: #218838;
} 