:root {
    --primary: #2c3e50;
    --secondary: #ff6b6b;
    --accent: #3d5a80;
    --light-bg: #f8f9fa;
    --teal: #4ecdc4;
    --border-color: #e0e0e0;
    --text-color: #000000;
    --text-light: #666;
    --chart-color1: #3d5a80;
    --chart-color2: #4ecdc4;
    --chart-color3: #ff6b6b;
    --chart-color4: #ffb74d;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Times New Roman', Times, serif;
}

body {
    font-size: 1rem;
    line-height: 1.6;
    color: #000;
    background-color: #f0f2f5;
    min-height: 100vh;
    overflow-x: hidden;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 15px;
}

.content-wrapper {
    display: grid;
    gap: 20px;
    margin: 0;
    padding: 0;
}

/* Main calculator styles */
.calculator-container {
    background: white;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    padding: 25px;
    margin-bottom: 20px;
    transition: all 0.4s ease;
}

h1 {
    font-size: 1.5rem;
    color: #000;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--teal);
    text-align: center;
}

h2 {
    font-size: 1.375rem;
    color: #ff6b6b;
    margin: 20px 0 15px;
}

h3 {
    font-size: 1.25rem;
    color: #000;
    margin: 15px 0 10px;
}

h4 {
    font-size: 1.125rem;
    color: #000;
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -10px;
}

.form-group {
    flex: 1 0 250px;
    padding: 0 10px;
    margin-bottom: 15px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #000;
}

input, select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    font-size: 1rem;
    color: #000;
    transition: border-color 0.3s;
}

input:focus, select:focus {
    border-color: var(--teal);
    outline: none;
    box-shadow: 0 0 0 2px rgba(78, 205, 196, 0.2);
}

.input-group {
    display: flex;
}

.input-group input {
    border-radius: 5px 0 0 5px;
}

.input-group .symbol {
    background: var(--light-bg);
    border: 1px solid var(--border-color);
    border-left: none;
    padding: 12px;
    border-radius: 0 5px 5px 0;
    color: #000;
}

.section-toggle {
    background: var(--light-bg);
    border: 1px solid var(--border-color);
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    margin: 15px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #000;
}

.section-toggle:hover {
    background: #e9ecef;
}

.advanced-options {
    display: none;
    border-left: 3px solid var(--teal);
    padding-left: 15px;
    margin-top: 10px;
}

.advanced-options.active {
    display: block;
}

.button-group {
    display: flex;
    gap: 15px;
    margin: 25px 0;
}

.btn {
    padding: 12px 25px;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: bold;
    color: #000;
}

.btn-primary {
    background: var(--teal);
    color: white;
    flex: 1;
}

.btn-primary:hover {
    background: #3dbfb6;
}

.btn-secondary {
    background: var(--secondary);
    color: white;
    flex: 1;
}

.btn-secondary:hover {
    background: #ff5252;
}

.results-container {
    margin-top: 30px;
    background: var(--light-bg);
    padding: 25px;
    border-radius: 10px;
    display: none;
}

.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.05);
    text-align: center;
}

.card-value {
    font-size: 1.25rem;
    font-weight: bold;
    color: #000;
    margin: 10px 0;
}

.card-label {
    color: #000;
    font-size: 1rem;
}

.charts-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin: 30px 0;
}

.chart-wrapper {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.05);
}

.chart-container {
    height: 250px;
    position: relative;
}

.export-options {
    display: flex;
    gap: 15px;
    margin-top: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.export-btn {
    background: white;
    border: 1px solid var(--border-color);
    padding: 10px 15px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.3s;
    min-width: 180px;
    justify-content: center;
    color: #000;
}

.export-btn:hover {
    background: var(--light-bg);
    border-color: var(--teal);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* Amortization Schedule */
.amortization-section {
    display: block;
}

.schedule-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin: 25px 0 15px;
}

.tab-btn {
    padding: 10px 20px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    position: relative;
    color: #000;
}

.tab-btn.active {
    color: #000;
    font-weight: bold;
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--teal);
}

.schedule-container {
    overflow-x: auto;
    max-height: 500px;
    overflow-y: auto;
}

.schedule-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.schedule-table th {
    background: var(--light-bg);
    padding: 12px 15px;
    text-align: left;
    border-bottom: 2px solid var(--border-color);
    position: sticky;
    top: 0;
    font-size: 1rem;
    color: #000;
}

.schedule-table td {
    padding: 10px 15px;
    border-bottom: 1px solid var(--border-color);
    color: #000;
    font-size: 1rem;
}

.schedule-table tr:nth-child(even) {
    background-color: rgba(248, 249, 250, 0.5);
}

.schedule-table tr:hover {
    background-color: rgba(78, 205, 196, 0.1);
}

/* Ad styles */
.ad-container {
    background: var(--light-bg);
    border: 1px dashed var(--border-color);
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
    margin-bottom: 20px;
    overflow: hidden;
}

.ad-label {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(0, 0, 0, 0.3);
    color: white;
    padding: 2px 8px;
    font-size: 0.7rem;
    border-radius: 3px;
}

#ad-left, #ad-right, #ad-tablet, #ad-mobile {
    position: relative;
}

#ad-left {
    width: 300px;
    height: 250px;
}

#ad-right {
    width: 300px;
    height: 600px;
}

#ad-tablet {
    width: 300px;
    height: 250px;
}

#ad-mobile {
    width: 320px;
    height: 100px;
}

#related-tools {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.05);
}

.tools-list {
    list-style: none;
}

.tools-list li {
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

.tools-list li:last-child {
    border-bottom: none;
}

.tools-list a {
    color: #000;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

.tools-list a:hover {
    color: var(--teal);
}

/* Replace the existing desktop media query with this corrected version */
@media (min-width: 1025px) {
    .content-wrapper {
        grid-template-columns: 300px 1fr 300px;
    }
    
    .sidebar {
        position: sticky;
        top: 20px;
        height: fit-content;
    }
    
    /* Remove individual sticky positioning - let the sidebar handle it */
    #ad-left {
        margin-bottom: 20px; /* Add space between ad and related tools */
    }
    
    #ad-right {
        position: sticky;
        top: 20px;
    }
    
    /* Related tools will stick with the sidebar container */
    #related-tools {
        position: relative; /* Remove sticky, let it flow with sidebar */
    }
    
    #ad-tablet, #ad-mobile, #related-tools-mobile {
        display: none;
    }
    
    .tab-btn {
        font-size: 1rem;
    }
}

@media (max-width: 1024px) and (min-width: 768px) {
    .content-wrapper {
        grid-template-columns: 1fr;
        gap: 0;
        margin: 0;
        padding: 0;
    }
    
    .container {
        padding: 0 15px;
        margin: 0 auto;
    }
    
    .calculator-container {
        margin: 0 !important;
        padding: 15px;
    }
    
    h1 {
        font-size: 1.5rem;
        color: #000;
    }
    
    h2 {
        font-size: 1.25rem;
        color: #ff6b6b;
    }
    
    h3 {
        font-size: 1.125rem;
        color: #000;
    }
    
    h4 {
        font-size: 1rem;
        color: #000;
    }
    
    .ad-tablet-container {
        display: flex;
        flex-direction: column;
        align-items: center;
        margin-top: 20px;
    }
    
    #ad-tablet {
        margin-top: 20px;
    }
    
    #ad-left, #ad-right, #ad-mobile, #related-tools {
        display: none;
    }
    
    #related-tools-mobile {
        margin-top: 20px;
        background: white;
        padding: 20px;
        border-radius: 8px;
        box-shadow: 0 3px 10px rgba(0, 0, 0, 0.05);
    }
    
    .tab-btn {
        font-size: 0.875rem;
    }
}

/* MOBILE FIXES START HERE */
@media (max-width: 767px) {
    body {
        overflow-x: hidden;
    }
    
    h1 {
        font-size: 1.25rem;
        color: #000;
    }
    
    h2 {
        font-size: 1.125rem;
        color: #ff6b6b;
    }
    
    h3 {
        font-size: 1rem;
        color: #000;
    }
    
    h4 {
        font-size: 0.9375rem;
        color: #000;
    }
    
    .container {
        padding: 0 5px;
        max-width: 100vw;
        overflow-x: hidden;
        margin: 0 auto;
    }
    
    .content-wrapper {
        grid-template-columns: 1fr;
        margin: 0;
        padding: 0;
        gap: 0;
    }
    
    .calculator-container {
        padding: 15px;
        margin: 0 !important;
        width: 100%;
        max-width: 100vw;
        box-sizing: border-box;
        border-radius: 8px;
    }
    
    .calculator-container.expanded {
        width: 100% !important;
        max-width: 100vw !important;
        box-sizing: border-box;
        overflow-x: hidden;
    }
    
    .results-container {
        padding: 15px;
        margin-top: 20px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }
    
    .form-group {
        flex: 1 0 100% !important;
        padding: 0 !important;
        margin-bottom: 12px;
    }
    
    .form-row {
        margin: 0;
    }
    
    /* Input group fixes */
    .input-group {
        flex-wrap: wrap;
        width: 100%;
    }
    
    .input-group input {
        width: 100%;
        border-radius: 5px !important;
        min-height: 44px;
    }
    
    .input-group .symbol {
        display: none; /* Hide on mobile */
    }
    
    input[type="date"] {
        min-height: 44px;
    }
    
    .summary-cards {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .card {
        padding: 15px;
        word-wrap: break-word;
    }
    
    .charts-container {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .chart-wrapper {
        padding: 15px;
        overflow: hidden;
    }
    
    .chart-container {
        height: 200px;
        width: 100%;
        max-width: 100%;
    }
    
    .ad-mobile-container {
        display: flex;
        justify-content: center;
        margin-top: 20px;
    }
    
    #ad-mobile {
        margin-top: 20px;
        max-width: calc(100vw - 40px);
        height: 100px;
    }
    
    #ad-left, #ad-right, #ad-tablet, #related-tools {
        display: none;
    }
    
    .button-group {
        flex-direction: column;
        gap: 10px;
        margin: 20px 0;
    }
    
    .btn {
        width: 100%;
        margin-bottom: 0;
    }
    
    #related-tools-mobile {
        margin-top: 20px;
        background: white;
        padding: 15px;
        border-radius: 8px;
        box-shadow: 0 3px 10px rgba(0, 0, 0, 0.05);
        max-width: calc(100vw - 20px);
        box-sizing: border-box;
    }
    
    .export-options {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
    
    .export-btn {
        width: 100%;
        max-width: 280px;
        min-width: auto;
    }
    
    /* Table fixes */
    .schedule-container {
        max-height: 300px;
        overflow-x: auto;
        width: 100%;
        max-width: 100vw;
    }
    
    .schedule-table {
        min-width: 600px;
        font-size: 0.9rem;
    }
    
    .schedule-table th,
    .schedule-table td {
        padding: 8px 10px;
        white-space: nowrap;
    }
    
    .card-value {
        font-size: 1.25rem;
        word-break: break-word;
    }
    
    .advanced-options {
        padding-left: 10px;
        overflow: hidden;
    }
    
    .calculator-container *,
    .results-container * {
        max-width: 100%;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    .tab-btn {
        font-size: 0.875rem;
    }
}

/* Print-specific styles */
@media print {
    body {
        background: white;
        padding: 20px;
        font-size: 0.75rem;
    }
    
    .container {
        max-width: 100%;
        padding: 0;
    }
    
    .sidebar, .ad-container, .button-group, 
    .section-toggle, .export-options, .schedule-tabs {
        display: none !important;
    }
    
    .calculator-container, .results-container {
        box-shadow: none;
        padding: 10px;
        margin: 0;
        width: 100%;
    }
    
    .results-container {
        display: block !important;
    }
    
    .summary-cards {
        grid-template-columns: repeat(4, 1fr);
        gap: 10px;
    }
    
    .charts-container {
        display: none !important;
    }
    
    #monthly-schedule, #yearly-schedule {
        display: block !important;
        page-break-inside: avoid;
    }
    
    .schedule-container {
        max-height: none !important;
        overflow: visible !important;
    }
    
    .schedule-table {
        font-size: 0.625rem;
    }
    
    .schedule-table th, .schedule-table td {
        padding: 5px 8px;
    }
    
    h1, h2, h3 {
        page-break-after: avoid;
    }
}

/* PDF Summary Styles */
.pdf-summary {
    display: none;
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.pdf-summary h2 {
    border-bottom: 2px solid var(--teal);
    padding-bottom: 10px;
    margin-bottom: 15px;
    color: #ff6b6b;
}

.pdf-summary-row {
    display: flex;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.pdf-summary-label {
    font-weight: bold;
    width: 180px;
    color: #000;
}

.pdf-summary-value {
    flex: 1;
    color: #000;
}

.pdf-summary-card {
    background: var(--light-bg);
    border-radius: 6px;
    padding: 15px;
    text-align: center;
    margin: 10px 0;
}

/* Expanded container */
.expanded {
    width: 100%;
    max-width: 100%;
    transition: all 0.3s ease;
}

/* Loading spinner for PDF generation */
.pdf-loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    display: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: var(--teal);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
    

/* Add breadcrumb styles */
.breadcrumb {
    padding: 0px 10px;
    color: #000;
    margin-bottom: 5px;
    font-size: 1rem;
}

.breadcrumb a {
    color: #000;
    text-decoration: none;
    transition: color 0.3s;
}

.breadcrumb a:hover {
    color: var(--secondary);
    text-decoration: underline;
}


.mobile-table {
    overflow-x: auto;
    margin: 20px 0;
    border: 1px solid #eee;
    border-radius: 8px;
}

.mobile-table table {
    width: 100%;
    min-width: 600px;
    border-collapse: collapse;
}

.mobile-table th, .mobile-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
    color: #000;
    font-size: 1rem;
}

.mobile-table th {
    background-color: #4ecdc4;
    font-weight: bold;
    color: #000;
}

.mobile-table tr:nth-child(even) {
    background-color: #fafafa;
}