/* CSS Variables for Theming */
:root {
    --primary: #2c3e50;
    --secondary: #ff6b6b;
    --accent: #3d5a80;
    --light-bg: #f8f9fa;
    --teal: #4ecdc4;
    --border-color: #e0e0e0;
    --text-color: #000000;
    --text-light: #666;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --radius: 8px;
}

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    font-family: 'Times New Roman', Times, serif;
    font-size: 1rem;
    line-height: 1.6;
    color: #000;
    background-color: var(--light-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Typography */
h1 {
    font-size: 1.5rem;
    color: #000;
    margin-bottom: 1rem;
    line-height: 1.3;
    text-align: center;
}

h2 {
    font-size: 1.375rem;
    color: #ff6b6b;
    margin-bottom: 0.75rem;
    line-height: 1.3;
}

h3 {
    font-size: 1.25rem;
    color: #000;
    margin-bottom: 0.5rem;
}

h4 {
    font-size: 1.125rem;
    color: #000;
    margin-bottom: 0.5rem;
}





/* Layout Container */
.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 10px;
}

.main-content {
    flex: 1;
    margin: 20px 0;
}

/* Main Layout */
.layout-grid {
    display: grid;
}

/* Calculator Container */
.calculator-container {
    background-color: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
}

/* Form Elements */
.form-group {
    margin-bottom: 1.25rem;
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 0.5rem;
}

.form-column {
    flex: 1 1 100%;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: bold;
    color: #000;
}

.input-with-unit {
    position: relative;
    display: flex;
}

input, select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 1rem;
    color: #000;
    background-color: white;
    transition: border-color 0.3s;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--accent);
}

.unit {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
}

/* Toggle Switch Styles */
.toggle-group {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
    margin-right: 10px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .3s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .toggle-slider {
    background-color: var(--teal);
}

input:checked + .toggle-slider:before {
    transform: translateX(26px);
}

/* Button Styles */
.button-group {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: 25px 0;
}

button {
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.3s;
    font-weight: bold;
    width: 100%;
}

.btn-calculate {
    background-color: var(--teal);
    color: white;
}

.btn-calculate:hover {
    background-color: #3db8af;
}

.btn-calculate:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

.btn-reset {
    background-color: var(--secondary);
    color: white;
}

.btn-reset:hover {
    background-color: #e05555;
}

/* Spinner Animation */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
    margin-right: 10px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Results Section */
.results-container {
    margin-top: 30px;
    padding: 20px;
    background-color: var(--light-bg);
    border-radius: var(--radius);
    border-left: 4px solid var(--teal);
    display: none;
}

.result-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px dashed var(--border-color);
    color: #000;
}

.result-value {
    font-weight: bold;
    font-size: 1.25rem;
    color: #000;
}

/* Pie Chart Container */
.pie-chart-container {
    margin-top: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.pie-chart-wrapper {
    position: relative;
    width: 200px;
    height: 200px;
}

.pie-chart {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    position: relative;
    overflow: hidden;
}

.pie-segment {
    position: absolute;
    width: 100%;
    height: 100%;
    clip-path: polygon(50% 50%, 50% 0%, 100% 0%, 100% 100%, 0% 100%, 0% 0%);
    transform-origin: 50% 50%;
    border-radius: 50%;
}

.pie-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    margin-top: 15px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.legend-item:hover {
    background-color: rgba(0,0,0,0.05);
}

.legend-color {
    width: 15px;
    height: 15px;
    border-radius: 3px;
}

.legend-text {
    font-size: 0.875rem;
    color: #000;
}

/* Export Options as Plain Text Links */
.export-links {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.export-link {
    color: white;
    text-decoration: none;
    font-size: 0.9375rem;
    padding: 8px 16px;
    border-radius: var(--radius);
    transition: all 0.2s;
    font-weight: bold;
    display: inline-block;
}

.export-link:hover {
    opacity: 0.9;
    color: white;
    transform: translateY(-2px);
}

#export-pdf-link {
    background-color: #e74c3c;
}

#export-image-link {
    background-color: #3498db;
}

#export-print-link {
    background-color: #2ecc71;
}

/* Ad Zones */
.ad-zone {
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    text-align: center;
    overflow: hidden;
}

.ad-label {
    background-color: var(--primary);
    color: white;
    width: 100%;
    padding: 8px;
    font-size: 0.875rem;
    text-align: center;
}

.ad-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
}

#ad-left {
    width: 100%;
    height: 250px;
}

#ad-right {
    width: 100%;
    height: 600px;
}

#ad-tablet {
    width: 300px;
    height: 250px;
    margin: 10px auto 0;
}

#ad-mobile {
    width: 100%;
    max-width: 320px;
    height: 100px;
    margin: 0 auto 20px;
}

/* Related Tools */
#related-tools {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.05);
    margin-top: 20px;
}

.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);
}

/* Related Tools for Tablet and Mobile */
#related-tools-mobile-tablet {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.05);
    margin-top: 20px;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.sticky {
    position: sticky;
    top: 20px;
}

.center {
    text-align: center;
}

/* Mobile Layout (default) */
.layout-grid {
    grid-template-columns: 1fr;
}

#related-tools {
    display: none;
}

#related-tools-mobile-tablet {
    display: block;
}

/* Breadcrumb Styles */
.breadcrumb {
    padding: 0px 10px;
    color: #000;
    margin-bottom: 0px;
    font-size: 1rem;
}

.breadcrumb a {
    color: #000;
    text-decoration: none;
    transition: color 0.3s;
}

.breadcrumb a:hover {
    color: var(--secondary);
    text-decoration: underline;
}

/* Tablet Layout (768px–1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
    .main-content {
        margin: 0;
    }
    
    .calculator-container {
        margin-top: 0px;
    }
    
    h1 { 
        font-size: 1.5rem;
    }
    
    h2 { 
        font-size: 1.25rem;
        color: #ff6b6b;
    }
    
    h3 { 
        font-size: 1.125rem;
    }
    
    h4 { 
        font-size: 1rem;
    }
    
    .form-column {
        flex: 1 1 calc(50% - 15px);
    }
    
    .button-group {
        flex-direction: row;
    }
    
    button {
        flex: 1;
        width: auto;
    }
    
    .layout-grid {
        grid-template-columns: 1fr;
    }
    
    #ad-tablet,
    #related-tools-mobile-tablet {
        display: block;
    }
    
    #ad-left,
    #ad-right,
    #ad-mobile,
    #related-tools {
        display: none;
    }
}

/* Desktop Layout (≥1025px) */
@media (min-width: 1025px) {
    h1 { 
        font-size: 1.5rem;
    }
    
    h2 { 
        font-size: 1.375rem;
        color: #ff6b6b;
    }
    
    h3 { 
        font-size: 1.25rem;
    }
    
    h4 { 
        font-size: 1.125rem;
    }
    
    .main-content {
        margin-top: 0px;
    }
    
    .layout-grid {
        grid-template-columns: 300px 1fr 300px;
        gap: 0 20px;
    }
    
    .form-column {
        flex: 1 1 calc(50% - 15px);
    }
    
    .button-group {
        flex-direction: row;
    }
    
    button {
        flex: 1;
        width: auto;
    }
    
    #ad-left,
    #ad-right,
    #related-tools {
        display: block;
    }
    
    #ad-mobile,
    #ad-tablet,
    #related-tools-mobile-tablet {
        display: none;
    }
    
    .sidebar-left {
        position: relative;
    }
    
    .sticky-container {
        position: sticky;
        top: 20px;
    }
}

/* Mobile adjustments for very small screens */
@media (max-width: 767px) {
    .main-content {
        margin: 0;
    }
    
    .calculator-container {
        padding: 15px;
        margin-top: 0px;
    }
    
    h1 { 
        font-size: 1.25rem;
    }
    
    h2 { 
        font-size: 1.125rem;
        color: #ff6b6b;
    }
    
    h3 { 
        font-size: 1rem;
    }
    
    h4 { 
        font-size: 0.9375rem;
    }
    
    #ad-mobile,
    #related-tools-mobile-tablet {
        display: block;
    }
    
    #ad-left,
    #ad-right,
    #ad-tablet,
    #related-tools {
        display: none;
    }
    
    .export-links {
        flex-direction: column;
        align-items: center;
    }
    
    .export-link {
        width: 200px;
        text-align: center;
    }
}

/* Accessibility Improvements */
input:focus, select:focus, button:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* High contrast support */
@media (prefers-contrast: high) {
    :root {
        --text-color: #000000;
        --border-color: #000000;
    }
    
    .calculator-container {
        border: 2px solid #000000;
    }
}
    .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;
    }
    .mobile-table th {
        background-color: #4ecdc4;
        font-weight: bold;
    }
    .mobile-table tr:nth-child(even) {
        background-color: #fafafa;
    }