/* All CSS styles from the original <style> tag */
:root {
    --primary: #2c3e50;
    --secondary: #ff6b6b;
    --accent: #3d5a80;
    --light-bg: #f8f9fa;
    --teal: #4ecdc4;
    --border-color: #e0e0e0;
    --text-color: #000000;
    --text-light: #666;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Times New Roman', Times, serif;
    font-size: 1rem;
    line-height: 1.6;
    color: #000;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--light-bg);
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 15px;
    flex: 1;
}

/* Main grid layout */
.content-grid {
    display: grid;
    grid-template-columns: 1fr;
}

/* Calculator styling */
#converter-tool {
    background: white;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
    padding: 30px;
}

.calculator-header {
    text-align: center;
}

h1 {
    font-size: 1.5rem;
    color: #000;
    margin-bottom: 15px;
    font-weight: bold;
    position: relative;
    padding-bottom: 10px;
}

h1:after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: var(--teal);
    border-radius: 3px;
}

h2 {
    font-size: 1.375rem;
    color: #ff6b6b;
    margin: 20px 0 15px;
}

h3 {
    font-size: 1.25rem;
    color: #000;
    margin: 15px 0 10px;
}

.calculator-description {
    color: #000;
    max-width: 700px;
    margin: 0 auto;
    line-height: 1.7;
}

.input-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #000;
}

input, select {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: 'Times New Roman', Times, serif;
    transition: all 0.3s ease;
}

input:focus, select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(61, 90, 128, 0.1);
    outline: none;
}

.radio-group {
    display: flex;
    gap: 15px;
    margin: 10px 0;
    flex-wrap: wrap;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: #000;
}

.radio-option input {
    width: auto;
}

.method-selector {
    margin: 25px 0;
    padding: 20px;
    background: var(--light-bg);
    border-radius: 10px;
}

.method-content {
    display: none;
    padding: 18px 0;
}

.method-content.active {
    display: block;
}

.skin-fold-inputs {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}

.btn-group {
    display: flex;
    gap: 15px;
    margin: 30px 0;
}

button {
    padding: 14px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: all 0.3s ease;
    font-family: 'Times New Roman', Times, serif;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #000;
}

.btn-calculate, .btn-reset {
    flex: 1;
}

.btn-calculate {
    background: #4ecdc4;
    color: white;
    box-shadow: 0 4px 6px rgba(61, 90, 128, 0.2);
}

.btn-calculate:hover {
    background: #4ecdc4;
    transform: translateY(-2px);
    box-shadow: 0 6px 8px rgba(44, 62, 80, 0.25);
}

.btn-reset {
    background: var(--secondary);
    color: white;
    box-shadow: 0 4px 6px rgba(255, 107, 107, 0.2);
}

.btn-reset:hover {
    background: #e55c5c;
    transform: translateY(-2px);
    box-shadow: 0 6px 8px rgba(229, 92, 92, 0.25);
}

/* Modern unit toggle */
.unit-toggle-container {
    margin: 20px 0 30px;
}

.unit-toggle-label {
    display: block;
    margin-bottom: 12px;
    font-weight: bold;
    color: #000;
}

.unit-toggle {
    display: inline-flex;
    background: var(--light-bg);
    border-radius: 50px;
    padding: 4px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

.toggle-option {
    padding: 10px 24px;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    border: 1px solid transparent;
    color: #000;
}

.toggle-option.active {
    background: white;
    color: var(--accent);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    border-color: var(--border-color);
}

/* Imperial height inputs */
.imperial-height-group {
    display: flex;
    gap: 12px;
}

.imperial-height-group > div {
    flex: 1;
}

/* Results styling */
.results-section {
    display: none;
    margin-top: 35px;
    padding: 30px;
    background: var(--light-bg);
    border-radius: 12px;
    border-left: 5px solid var(--teal);
}

.results-header {
    margin-bottom: 20px;
}

.results-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 25px;
}

.result-box {
    text-align: center;
    padding: 20px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.05);
    transition: transform 0.3s ease;
}

.result-box:hover {
    transform: translateY(-5px);
}

.result-value {
    font-size: 1.25rem;
    font-weight: bold;
    color: #000;
    margin: 15px 0;
    font-family: 'Times New Roman', Times, serif;
}

.result-label {
    font-size: 1rem;
    color: #000;
}

.category-box {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.05);
    margin-top: 20px;
}

.category-indicator {
    height: 14px;
    background: #e0e0e0;
    border-radius: 7px;
    margin: 18px 0;
    position: relative;
    overflow: hidden;
}

.category-fill {
    height: 100%;
    background: var(--teal);
    border-radius: 7px;
    width: 55%;
}

.category-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    color: #000;
}

.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);
    color: #000;
}

.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);
}

/* Ad zones styling */
.ad-zone {
    background: var(--light-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    text-align: center;
    color: #000;
    font-family: 'Times New Roman', Times, serif;
    font-size: 1rem;
}

#ad-left, #ad-right {
    display: none;
}

#ad-tablet, #ad-mobile {
    display: none;
}

/* Modern Barometer */
.barometer-container {
    width: 200px;
    height: 200px;
    margin: 0 auto;
    position: relative;
}

.barometer-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.barometer-circle {
    fill: none;
    stroke: #e0e0e0;
    stroke-width: 15;
    stroke-linecap: round;
}

.barometer-progress {
    fill: none;
    stroke: var(--teal);
    stroke-width: 15;
    stroke-linecap: round;
    stroke-dasharray: 565;
    stroke-dashoffset: 565;
    transition: stroke-dashoffset 1s ease;
}

.barometer-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.barometer-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #000;
    font-family: 'Times New Roman', Times, serif;
}

.barometer-label {
    font-size: 1rem;
    color: #000;
    margin-top: 5px;
}

/* Export buttons */
.export-buttons {
    display: flex;
    gap: 15px;
    margin-top: 25px;
    flex-wrap: wrap;
}

.btn-export {
    background: #3d5a80;
    color: white;
    padding: 10px 15px;
    border-radius: 5px;
    border: none;
    cursor: pointer;
    transition: background 0.3s;
    flex: 1;
    min-width: 120px;
    font-size: 1rem;
}

.btn-export:hover {
    background: #2c3e50;
}

@media print {
    body * {
        visibility: hidden;
    }
    #converter-tool, #converter-tool * {
        visibility: visible;
    }
    #converter-tool {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        padding: 0;
        margin: 0;
        box-shadow: none;
        background: white; /* ensures no grey background in print */
    }

    /* Force results to show */
    .results-section {
        display: block !important;
        width: 100%;
        padding: 20px;
        margin: 0;
        box-shadow: none;
        border: none;
    }

    /* Hide unnecessary UI */
    .calculator-header,
    #body-fat-form,
    .btn-group,
    .sidebar,
    .ad-zone,
    .method-selector,
    .export-buttons,
    .related-tools,
    #ad-tablet,
    #ad-mobile {
        display: none !important;
    }

    /* Avoid splitting results into two pages */
    .results-content,
    .result-box,
    .category-box,
    .barometer-container {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    /* If you want each major block on its own page */
    .category-box {
        page-break-before: always;
    }

    svg, canvas, img {
        max-width: 100%;
        page-break-inside: avoid;
    }

    /* Scale down charts so they don’t overflow page width */
    .barometer-container {
        transform: scale(0.85);
        transform-origin: center;
        margin: 0 auto;
    }
}


/* Desktop layout */
@media (min-width: 1025px) {
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.375rem; }
    h3 { font-size: 1.25rem; }
    
    .content-grid {
        grid-template-columns: 300px 1fr 300px;
        gap: 30px;
    }
    
    .sidebar {
        position: sticky;
        top: 30px;
        height: fit-content;
    }
    
    #ad-left, #ad-right {
        display: flex;
        margin-bottom: 25px;
    }
    
    #ad-left {
        height: 250px;
        width: 300px;
    }
    
    #ad-right {
        height: 600px;
        width: 300px;
    }
    
    #ad-tablet, #ad-mobile {
        display: none;
    }
    
    /* Desktop related tools position */
    .desktop-related-tools {
        display: block;
    }
    .mobile-related-tools {
        display: none;
    }
}

/* Tablet layout */
@media (min-width: 768px) and (max-width: 1024px) {
    h1 { font-size: 1.25rem; }
    h2 { font-size: 1.25rem; }
    h3 { font-size: 1.125rem; }
    
    .content-grid {
        grid-template-columns: 1fr;
    }
    
    #ad-tablet {
        display: flex;
        height: 250px;
        max-width: 300px;
        margin: 20px auto 0;
    }
    
    #ad-left, #ad-right, #ad-mobile {
        display: none;
    }
    
    /* Tablet related tools position */
    .desktop-related-tools {
        display: none;
    }
    .mobile-related-tools {
        display: block;
        width: 100%; /* to take full width */
        max-width: none; /* override the max-width */
        margin: 30px 0 0; /* adjust margin: top only, left and right auto removed */
    }
}

/* Mobile layout - ONLY OVERFLOW FIXES ADDED HERE */
@media (max-width: 767px) {
    h1 { font-size: 1.25rem; }
    h2 { font-size: 1.125rem; }
    h3 { font-size: 1rem; }
    
    /* OVERFLOW FIXES START */
    html {
        overflow-x: hidden;
    }
    
    body {
        overflow-x: hidden;
        max-width: 100vw;
    }
    
    .container {
        padding: 0 10px;
        max-width: 100vw;
        overflow-x: hidden;
    }
    
    #converter-tool {
        padding: 15px;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .method-selector {
        padding: 15px;
        box-sizing: border-box;
    }
    
    .results-section {
        padding: 15px;
        box-sizing: border-box;
    }
    
    input, select {
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .skin-fold-inputs {
        grid-template-columns: 1fr 1fr;
    }
    
    .imperial-height-group {
        flex-direction: column;
        gap: 8px;
    }
    
    .unit-toggle {
        width: 100%;
        justify-content: center;
    }
    
    .toggle-option {
        flex: 1;
        text-align: center;
        padding: 8px 12px;
        font-size: 0.875rem;
    }
    
    .barometer-container {
        width: 150px;
        height: 150px;
    }
    
    .barometer-value {
        font-size: 1.5rem;
    }
    /* OVERFLOW FIXES END */
    
    .content-grid {
        grid-template-columns: 1fr;
    }
    
    #ad-mobile {
        display: flex;
        height: 100px;
        width: 320px;
        margin: 20px auto 0;
    }
    
    #ad-left, #ad-right, #ad-tablet {
        display: none;
    }
    
    .btn-group {
        flex-direction: column;
    }
    
    /* Mobile related tools position */
    .desktop-related-tools {
        display: none;
    }
    .mobile-related-tools {
        display: block;
        margin-top: 20px;
    }
    
    /* Fix for mobile layout overflow */
    .results-content {
        grid-template-columns: 1fr;
    }
    .result-box {
        padding: 15px;
    }
    .result-value {
        font-size: 1.25rem;
    }

    .export-buttons {
        flex-direction: column;
    }
}

/* Add breadcrumb styles */
.breadcrumb {
    padding: 0px 10px;
    color: #000;
    font-size: 1rem;
}

.breadcrumb a {
    color: #000;
    text-decoration: none;
    transition: color 0.3s;
}

.breadcrumb a:hover {
    color: var(--secondary);
    text-decoration: underline;
}

input:disabled {
    background-color: #f5f5f5;
    opacity: 0.7;
    cursor: not-allowed;
}

.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;
}

.mobile-table tr:nth-child(even) {
    background-color: #fafafa;
}