:root {
    --primary: #2c3e50;
    --secondary: #3498db;
    --accent: #e74c3c;
    --light: #ecf0f1;
    --dark: #2c3e50;
    --success: #27ae60;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --border-radius: 10px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

html {
    font-size: 16px;
}

body {
    background-color: #f8f9fa;
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
}

/* Header Styles */
header {
    background-color: var(--primary);
    color: white;
    padding: 1rem 0;
    box-shadow: var(--shadow);
    position: relative;
    z-index: 100;
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.logo-icon {
    font-size: 2rem;
    color: var(--secondary);
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.logo-text span {
    color: var(--secondary);
}

nav {
    width: 100%;
    flex: 1;
    min-width: 0;
}

nav ul {
    display: flex;
    list-style: none;
    gap: 15px;
    justify-content: flex-end;
    flex-wrap: wrap;
    padding: 0;
    margin: 0;
}

nav li {
    white-space: nowrap;
}

nav a {
    color: white;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

nav a:hover {
    color: var(--secondary);
}

nav i {
    font-size: 1rem;
}

/* Main Content */
main {
    flex: 1;
    padding: 1.5rem 0;
    width: 100%;
}

h1 {
    color: var(--primary);
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
    padding: 0 10px;
}

.calculator-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
    margin-bottom: 30px;
}

@media (max-width: 768px) {
    .calculator-container {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}

.calculator-card {
    background-color: white;
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.calculator-card h2 {
    color: var(--primary);
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--light);
    font-size: 1.4rem;
}

/* Input Section */
.input-group {
    margin-bottom: 18px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--dark);
    font-size: 1rem;
}

.input-with-unit {
    display: flex;
    border: 1px solid #ddd;
    border-radius: 5px;
    overflow: hidden;
    min-height: 48px;
}

.input-with-unit input {
    flex: 1;
    padding: 12px 15px;
    border: none;
    font-size: 1rem;
    min-width: 0;
    width: 100%;
}

.unit-selector {
    display: flex;
    background-color: #f1f1f1;
    flex-shrink: 0;
}

.unit-btn {
    padding: 12px 16px;
    border: none;
    background-color: transparent;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
    font-size: 0.95rem;
    white-space: nowrap;
}

.unit-btn.active {
    background-color: var(--secondary);
    color: white;
}

.ratio-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 8px;
}

@media (max-width: 480px) {
    .ratio-options {
        grid-template-columns: repeat(2, 1fr);
    }
}

.ratio-btn {
    padding: 12px 5px;
    background-color: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 5px;
    cursor: pointer;
    text-align: center;
    transition: all 0.3s;
    font-weight: 500;
    font-size: 0.95rem;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ratio-btn:hover {
    background-color: #e9ecef;
}

.ratio-btn.active {
    background-color: var(--secondary);
    color: white;
    border-color: var(--secondary);
}

.custom-ratio {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.custom-ratio span {
    font-size: 0.95rem;
}

.custom-ratio input {
    width: 70px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
    min-height: 44px;
}

.oil-density-info {
    font-size: 0.85rem;
    color: #666;
    margin-top: 5px;
    line-height: 1.4;
}

/* Results Section */
.results-card {
    background-color: white;
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.results-header h2 {
    color: var(--primary);
    margin-bottom: 0;
    border-bottom: none;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.reset-btn {
    background-color: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 10px 15px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
}

.reset-btn:hover {
    background-color: #e9ecef;
}

.reset-btn-full {
    width: 100%;
    margin-top: 20px;
    padding: 14px;
    justify-content: center;
}

.results-display {
    text-align: center;
    margin: 25px 0;
    padding: 25px 15px;
    background-color: #f8f9fa;
    border-radius: var(--border-radius);
}

.result-value {
    font-size: 2.8rem;
    font-weight: 700;
    color: var(--secondary);
    margin: 10px 0;
    line-height: 1.1;
}

@media (max-width: 480px) {
    .result-value {
        font-size: 2.5rem;
    }
}

.result-unit {
    font-size: 1.3rem;
    color: #666;
    margin-bottom: 8px;
}

.result-details {
    font-size: 1rem;
    color: #555;
    margin-top: 10px;
    line-height: 1.4;
}

.conversion-info {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    flex-wrap: wrap;
    gap: 12px;
}

@media (max-width: 480px) {
    .conversion-info {
        flex-direction: column;
    }
}

.conversion-box {
    text-align: center;
    padding: 15px 10px;
    background-color: #f8f9fa;
    border-radius: 5px;
    flex: 1;
    min-width: 0;
}

@media (max-width: 480px) {
    .conversion-box {
        width: 100%;
    }
}

.conversion-value {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--primary);
    margin-top: 5px;
    word-break: break-all;
}

.mixing-instructions-container {
    margin-top: 25px;
    padding: 15px;
    background-color: #f0f7ff;
    border-radius: 5px;
    border-left: 4px solid var(--secondary);
}

.mixing-instructions-text {
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
}

#mixingInstructions {
    font-size: 0.95rem;
    line-height: 1.5;
    color: #444;
}

/* Ads Section */
.ads-container {
    display: flex;
    justify-content: center;
    margin: 30px 0;
    width: 100%;
    overflow: hidden;
}

.ad-placeholder {
    width: 100%;
    max-width: 1200px;
    height: 90px;
    background-color: #f1f1f1;
    border: 1px dashed #ccc;
    border-radius: 5px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #888;
    font-size: 0.85rem;
    text-align: center;
    padding: 10px;
}

@media (max-width: 768px) {
    .ad-placeholder {
        height: 90px;
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .ad-placeholder {
        height: 75px;
        font-size: 0.8rem;
    }
}

.ad-placeholder-middle {
    height: 250px;
    max-width: 1200px;
}

@media (max-width: 768px) {
    .ad-placeholder-middle {
        height: 200px;
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .ad-placeholder-middle {
        height: 150px;
    }
}

/* Info Section */
.info-section {
    margin-top: 30px;
    width: 100%;
}

.info-section-title {
    color: var(--primary);
    margin-bottom: 20px;
    text-align: center;
    font-size: 1.5rem;
    padding: 0 10px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

@media (max-width: 480px) {
    .info-grid {
        grid-template-columns: 1fr;
    }
}

.info-card {
    background-color: white;
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow);
    height: 100%;
}

.info-card h3 {
    color: var(--primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.2rem;
}

.info-card i {
    color: var(--secondary);
    font-size: 1.1rem;
}

.info-card p {
    font-size: 0.95rem;
    line-height: 1.5;
    color: #444;
}

/* Footer */
footer {
    background-color: var(--primary);
    color: white;
    padding: 1.5rem 0;
    margin-top: 30px;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

@media (max-width: 768px) {
    .footer-content {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }
}

.copyright {
    opacity: 0.8;
    font-size: 0.9rem;
}

/* Additional Mobile Fixes */
@media (max-width: 768px) {
    .header-container {
        flex-direction: row;
        gap: 10px;
    }
    
    .logo-text {
        font-size: 1.3rem;
    }
    
    nav ul {
        justify-content: flex-end;
        gap: 12px;
    }
    
    nav a {
        font-size: 0.9rem;
    }
    
    .container {
        padding: 0 12px;
    }
    
    main {
        padding: 1rem 0;
    }
    
    .calculator-card,
    .results-card {
        padding: 18px;
    }
    
    h1 {
        font-size: 1.6rem;
        margin-bottom: 1rem;
    }
}

@media (max-width: 480px) {
    .header-container {
        flex-direction: column;
        text-align: center;
        gap: 12px;
    }
    
    .logo {
        justify-content: center;
        width: 100%;
    }
    
    nav {
        width: 100%;
    }
    
    nav ul {
        justify-content: center;
        gap: 10px;
    }
    
    nav a span {
        display: none;
    }
    
    nav i {
        font-size: 1.2rem;
    }
    
    .logo-text {
        font-size: 1.4rem;
    }
    
    .container {
        padding: 0 10px;
    }
    
    .calculator-card,
    .results-card {
        padding: 15px;
    }
    
    .input-with-unit {
        flex-direction: column;
        border: none;
    }
    
    .input-with-unit input {
        border: 1px solid #ddd;
        border-radius: 5px;
        margin-bottom: 8px;
    }
    
    .unit-selector {
        width: 100%;
        border-radius: 5px;
        overflow: hidden;
        border: 1px solid #ddd;
    }
    
    .unit-btn {
        flex: 1;
        text-align: center;
    }
    
    .custom-ratio {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .custom-ratio input {
        width: 100%;
    }
    
    .result-value {
        font-size: 2.2rem;
    }
    
    .result-unit {
        font-size: 1.1rem;
    }
}

/* Prevent horizontal scrolling */
body, html {
    max-width: 100%;
    overflow-x: hidden;
}

/* Improve touch targets on mobile */
button, 
input[type="number"], 
.ratio-btn, 
.unit-btn {
    touch-action: manipulation;
}

/* Better spacing for mobile */
@media (max-width: 768px) {
    .ads-container {
        margin: 20px 0;
    }
    
    .info-section {
        margin-top: 20px;
    }
    
    footer {
        margin-top: 20px;
        padding: 1rem 0;
    }
}

/* Fix for iOS zoom on input */
@media (max-width: 768px) {
    input, select, textarea {
        font-size: 16px !important;
    }
}