/* 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;
    --transition: all 0.3s ease;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

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;
}

/* Typography - Mobile First */
h1 {
    font-size: 1.25rem;
    color: #000;
    margin-bottom: 0.5rem;
    text-align: center;
}

h2 {
    font-size: 1.125rem;
    color: #ff6b6b;
    margin-bottom: 1rem;
}

h3 {
    font-size: 1rem;
    color: #000;
    margin-bottom: 0.75rem;
}

h4 {
    font-size: 0.9375rem;
    color: #000;
    margin-bottom: 0.5rem;
}

p {
    margin-bottom: 1rem;
    color: #000;
}

small {
    font-size: 0.875rem;
    color: #000;
}

/* Layout Container */
.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0px 10px;
}

/* Main Content Layout - Mobile First (stacked) */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Calculator Styles */
#converter-tool {
    background-color: white;
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    width: 100%;
}

.calculator-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

label {
    font-weight: bold;
    color: #000;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
}

.tooltip-icon {
    color: #000;
    cursor: help;
    font-size: 1.125rem;
}

.input-with-unit {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

input, select, button {
    font-family: 'Times New Roman', Times, serif;
    font-size: 1rem;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    transition: var(--transition);
    color: #000;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(61, 90, 128, 0.2);
}

input[type="number"] {
    flex-grow: 1;
}

.unit-selector {
    min-width: 100px;
}

.currency-selector {
    min-width: 120px;
}

/* Configuration Options */
.config-options {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-top: 0.5rem;
}

/* Buttons */
.button-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
}

button {
    cursor: pointer;
    font-weight: bold;
    transition: var(--transition);
    width: 100%;
    font-size: 1rem;
}

.calculate-btn {
    background-color: #4ecdc4;
    color: white;
    border: none;
}

.calculate-btn:hover:not(:disabled) {
    background-color: #4ecdc4;
    transform: none;
}

.reset-btn {
    background-color: #ff6b6b;
    color: white;
    border: none;
}

.reset-btn:hover {
    background-color: #ff6b6b;
    transform: none;
}

/* 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: 8px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.calculate-btn .btn-text {
    display: inline-block;
}

.calculate-btn .spinner {
    display: none;
}

.calculate-btn.calculating .btn-text {
    display: none;
}

.calculate-btn.calculating .spinner {
    display: inline-block;
}

.calculate-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* Results Section */
.results-container {
    background-color: white;
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-top: 2rem;
    box-shadow: var(--shadow);
    border-left: 5px solid var(--teal);
}

.results-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-top: 1rem;
}

.result-item {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem;
    background-color: var(--light-bg);
    border-radius: var(--radius);
    color: #000;
}

.result-value {
    font-weight: bold;
    color: #000;
    font-size: 1.25rem;
}

.breakdown {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px dashed var(--border-color);
    color: #000;
}

/* Pie Chart */
.pie-chart-container {
    margin: 1.5rem 0;
    text-align: center;
}

.pie-chart-wrapper {
    position: relative;
    display: inline-block;
    margin: 1rem auto;
}

.pie-chart-canvas {
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.pie-chart-canvas:hover {
    transform: scale(1.05);
}

.pie-chart-legend {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s ease;
    color: #000;
    font-size: 1rem;
}

.legend-item:hover {
    background-color: var(--light-bg);
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
}

.chart-tooltip {
    position: absolute;
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.875rem;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 10;
}

/* Ad Zones */
.ad-zone {
    background-color: #f0f0f0;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
    font-style: italic;
    overflow: hidden;
    font-size: 1rem;
}

/* Related Tools */
#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;
    font-size: 1rem;
}

.tools-list li:last-child {
    border-bottom: none;
}

.tools-list a {
    color: #000;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
}

.tools-list a:hover {
    color: var(--teal);
}

/* Sidebars - Hidden on Mobile */
.sidebar {
    display: none;
}

/* Mobile/Tablet Ads & Related Tools Container */
.mobile-tablet-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Tablet Layout (768px - 1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
    h1 { font-size: 1.25rem; }
    h2 { font-size: 1.25rem; }
    h3 { font-size: 1.125rem; }
    h4 { font-size: 1rem; }

    .config-options {
        grid-template-columns: 1fr 1fr;
    }

    .results-grid {
        grid-template-columns: 1fr 1fr;
    }

    .button-group {
        flex-direction: row;
    }

    button {
        width: auto;
        flex: 1;
    }

    #ad-tablet {
        display: block;
        width: 300px;
        height: 250px;
        margin: 20px auto 0;
    }

    #ad-mobile, #ad-left, #ad-right {
        display: none;
    }

    #related-tools {
        display: block;
        width: 100%;
        margin: 0 auto;
    }

    .mobile-tablet-content {
        align-items: center;
        gap: 20px;
    }
}

/* Desktop Layout (≥1025px) */
@media (min-width: 1025px) {
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.375rem; }
    h3 { font-size: 1.25rem; }
    h4 { font-size: 1.125rem; }

    .container {
        padding: 0px 10px;
    }

    .main-content {
        flex-direction: row;
    }

    /* Three-column layout */
    .sidebar {
        display: block;
        width: 300px;
        flex-shrink: 0;
    }

    .main-area {
        flex-grow: 1;
    }

    /* Sticky sidebars */
    .sidebar-left {
        position: sticky;
        top: 2rem;
        align-self: flex-start;
        display: flex;
        flex-direction: column;
        gap: 20px;
    }

    .sidebar-right {
        position: sticky;
        top: 2rem;
        align-self: flex-start;
    }

    #ad-left {
        width: 300px;
        height: 250px;
    }

    #ad-right {
        width: 300px;
        height: 600px;
    }

    #related-tools {
        display: block;
        width: 300px;
        height: auto;
    }

    .config-options {
        grid-template-columns: 1fr 1fr;
    }

    .results-grid {
        grid-template-columns: 1fr 1fr;
    }

    .button-group {
        flex-direction: row;
    }

    button {
        width: auto;
        flex: 1;
    }

    /* Hide mobile/tablet content on desktop */
    .mobile-tablet-content {
        display: none;
    }

    /* Hide tablet and mobile ads on desktop */
    #ad-tablet, #ad-mobile {
        display: none;
    }
}

/* Mobile Layout (≤767px) */
@media (max-width: 767px) {
    #ad-mobile {
        display: block;
        width: 100%;
        max-width: 320px;
        height: 100px;
        margin: 20px auto 0;
    }

    #ad-tablet, #ad-left, #ad-right {
        display: none;
    }

    #related-tools {
        display: block;
        width: 100%;
    }

    .button-group button {
        width: 100%;
    }

    .mobile-tablet-content {
        align-items: center;
        gap: 20px;
    }

    /* Add this new rule to make currency box width 100% */
    .currency-selector {
        width: 100%;
        min-width: 100% !important;
    }
    
    /* Also adjust the input-with-unit layout for better stacking */
    .input-with-unit {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .input-with-unit input[type="number"] {
        width: 100%;
    }
}

/* Accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

input:focus, button:focus, select:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Validation Styles */
input:invalid {
    border-color: #ff6b6b;
}

.error-message {
    color: #ff6b6b;
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: none;
}

input:invalid + .error-message {
    display: block;
}

/* Export Options */
.export-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px dashed var(--border-color);
}

.export-btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    background-color: var(--light-bg);
    color: #000;
    border: 1px solid var(--border-color);
    cursor: pointer;
}

.export-btn-small:hover {
    background-color: var(--teal);
    color: white;
    border-color: var(--teal);
}

/* 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;
    font-size: 1rem;
}

.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;
}

.mobile-table th {
    background-color: #4ecdc4;
    font-weight: bold;
    font-size: 1rem;
}

.mobile-table td {
    font-size: 1rem;
}

.mobile-table tr:nth-child(even) {
    background-color: #fafafa;
}