/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-weight: 300;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #333;
}

.container {
    background: white;
    border-radius: 8px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    padding: 32px;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    box-sizing: border-box;
}

header {
    text-align: center;
    margin-bottom: 32px;
}

.logo-container {
    margin-bottom: 15px;
}

.logo {
    height: 60px;
    width: auto;
    max-width: 100%;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 300;
    color: #2c3e50;
    margin-bottom: 10px;
}

header p {
    color: #7f8c8d;
    font-size: 1.1rem;
    font-weight: 300;
}

/* Introduction Section Styling */
.intro-section {
    max-width: 800px;
    margin: 2rem auto 3rem;
    padding: 2rem 1rem;
    background: #f8fafc;
    border: 1px solid #e1e8ed;
    border-radius: 8px;
    text-align: center;
}

.intro-section p {
    color: #34495e;
    line-height: 1.6;
    margin: 0;
    font-size: 1rem;
    text-align: center;
}

.converter-main {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 2rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 0;
}

.input-group label {
    font-weight: 400;
    color: #555;
    font-size: 16px;
    margin-bottom: 4px;
}



.input-field {
    padding: 12px 16px;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 300;
    background: #fafbfc;
    transition: all 0.3s ease;
    outline: none;
    box-sizing: border-box;
    width: 100%;
}

.input-field:hover {
    border-color: #bdc3c7;
}

.input-field:focus {
    border-color: #3498db;
    background: white;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}



.input-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
    align-items: end;
}

.unit-conversion-row {
    display: flex;
    gap: 12px;
    align-items: end;
}

.unit-conversion-row .input-group {
    flex: 1;
}

.swap-button {
    background: #3498db;
    border: none;
    border-radius: 8px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: white;
    box-shadow: 0 2px 4px rgba(52, 152, 219, 0.2);
}

.swap-button:hover {
    background: #2980b9;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(52, 152, 219, 0.3);
}

.swap-button:active {
    transform: translateY(0);
}

.swap-button svg {
    width: 20px;
    height: 20px;
}

.conversion-section {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.result-section {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 24px;
    margin-top: 20px;
    animation: slideUp 0.4s ease;
    box-sizing: border-box;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.result-display {
    text-align: center;
    margin-bottom: 25px;
}

.result-value {
    font-size: 2.5rem;
    font-weight: 200;
    color: #2c3e50;
    margin-bottom: 5px;
}

.result-label {
    color: #7f8c8d;
    font-size: 1rem;
    font-weight: 300;
}

.context-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    padding: 20px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    text-align: center;
}

.context-icon {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #ecf0f1;
    max-width: 100%;
    height: auto;
}

.context-icon svg {
    width: 30px;
    height: 30px;
    fill: #3498db;
    max-width: 100%;
    height: auto;
}

.context-text {
    text-align: center;
    color: #555;
    font-size: 1rem;
    font-weight: 300;
    line-height: 1.5;
    max-width: 100%;
}

/* AdSense Container Styling */
.ad-container {
    margin-top: 16px;
    padding: 8px;
    text-align: center;
}

.ad-container .adsbygoogle {
    display: block !important;
}

/* Legacy placeholder (hidden when ads show) */
.ad-placeholder {
    background: #e9ecef;
    border: 2px dashed #bdc3c7;
    border-radius: 8px;
    padding: 24px;
    text-align: center;
    color: #7f8c8d;
    font-size: 16px;
    font-weight: 300;
    margin-top: 16px;
}

/* Percentage calculator styles */
.percentage-calculator {
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    margin: 15px 0;
}

.percentage-question {
    font-size: 1.2em;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
}

.percentage-question span {
    color: #495057;
    font-weight: 500;
}

.inline-input {
    width: 80px;
    padding: 8px 12px;
    border: 2px solid #dee2e6;
    border-radius: 4px;
    font-size: 1.1em;
    text-align: center;
    background: white;
    transition: border-color 0.3s ease;
}

.inline-input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

/* Mobile responsive styles */
@media (max-width: 600px) {
    .container {
        padding: 24px 16px;
        margin: 10px;
        border-radius: 8px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    header p {
        font-size: 1rem;
    }
    
    .input-row {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .unit-conversion-row {
        flex-direction: column;
        gap: 16px;
    }
    
    .swap-button {
        align-self: center;
        width: 40px;
        height: 40px;
    }
    
    .result-value {
        font-size: 2rem;
    }
    
    .context-section {
        padding: 16px;
    }
}

@media (max-width: 400px) {
    .container {
        padding: 20px 15px;
    }
    
    .input-field {
        padding: 12px 15px;
        font-size: 0.95rem;
    }
    
    .result-value {
        font-size: 1.8rem;
    }
}

/* Loading and transition states */
.input-field:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.result-section.updating {
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

/* Focus states for accessibility */
.input-field:focus-visible {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

.input-field:focus {
    border-color: #3498db;
    background: white;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.swap-button:focus-visible {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

select.input-field {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 40px;
    appearance: none;
}

/* Improved spacing and layout consistency */

/* Footer Styling */
.site-footer {
    margin-top: 3rem;
    padding: 2rem 1rem 1rem;
    border-top: 1px solid #e1e8ed;
    background: #f8fafc;
    color: #64748b;
    font-size: 14px;
}

.footer-content {
    max-width: 400px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.footer-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.footer-links a {
    color: #64748b;
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer-links a:hover {
    color: #3498db;
}

.cookie-settings-btn {
    background: none;
    border: none;
    color: #64748b;
    font-size: 14px;
    cursor: pointer;
    text-decoration: underline;
    transition: color 0.2s ease;
}

.cookie-settings-btn:hover {
    color: #3498db;
}

/* Header Navigation */
.header-nav {
    margin-top: 1rem;
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.header-nav a {
    color: #64748b;
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s ease;
}

.header-nav a:hover {
    color: #3498db;
}

/* Converter Links Section */
.converter-links {
    max-width: 1200px;
    margin: 3rem auto 2rem;
    padding: 2rem 1rem;
}

.converter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.converter-card {
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid #e1e8ed;
    padding: 1.5rem;
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.converter-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.1);
}

.converter-card h3 {
    color: #2c3e50;
    margin-bottom: 0.5rem;
    font-size: 1.2rem;
}

.converter-card p {
    color: #64748b;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.learn-more-btn {
    display: inline-block;
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    text-decoration: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 500;
    transition: background 0.2s ease;
}

.learn-more-btn:hover {
    background: linear-gradient(135deg, #2980b9, #1e5f8e);
}

/* Content Page Styles */
.content {
    max-width: 820px;
    margin: 2rem auto;
    line-height: 1.7;
    padding: 0 1rem;
}

.content h2,
.faqs h2 {
    margin-top: 2rem;
    color: #2c3e50;
    border-bottom: 2px solid #3498db;
    padding-bottom: 0.5rem;
}

.content h3 {
    color: #34495e;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
}

.content ul {
    margin: 1rem 0;
    padding-left: 1.5rem;
}

.content li {
    margin-bottom: 0.5rem;
}

.faqs {
    max-width: 820px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.faqs details {
    margin: 0.5rem 0;
    border: 1px solid #e1e8ed;
    border-radius: 8px;
    overflow: hidden;
}

.faqs summary {
    background: #ffffff;
    padding: 1rem;
    cursor: pointer;
    font-weight: 500;
    color: #2c3e50;
    transition: background-color 0.2s ease;
}

.faqs summary:hover {
    background: #f1f5f9;
}

.faqs details[open] summary {
    background: #e3f2fd;
    border-bottom: 1px solid #e1e8ed;
}

.faqs details p {
    padding: 1rem;
    margin: 0;
    background: #ffffff;
    color: #34495e;
}

/* Ad Container Styles */
.ads-inline,
.ads-footer {
    margin: 1.5rem auto;
    max-width: 820px;
    text-align: center;
}

/* Tool Section for Individual Pages */
.tool {
    max-width: 820px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.tool h1 {
    color: #2c3e50;
    margin-bottom: 1.5rem;
    text-align: center;
}

.converter-info h2 {
    color: #2c3e50;
    margin-bottom: 1rem;
    font-size: 1.5rem;
    border-bottom: 2px solid #3498db;
    padding-bottom: 0.5rem;
}

.converter-info ul {
    margin: 1rem 0;
    padding-left: 1.5rem;
}

.converter-info ul li {
    margin-bottom: 0.5rem;
}

.converter-info strong {
    color: #34495e;
}

.converter-info em {
    color: #7f8c8d;
    font-style: italic;
}

/* FAQ Styling */
.faq {
    margin-top: 2rem;
    border-top: 1px solid #e1e8ed;
    padding-top: 1.5rem;
}

.faq h3 {
    color: #34495e;
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.faq details {
    margin-bottom: 1rem;
    border: 1px solid #e1e8ed;
    border-radius: 8px;
    overflow: hidden;
}

.faq summary {
    background: #ffffff;
    padding: 1rem;
    cursor: pointer;
    font-weight: 500;
    color: #2c3e50;
    transition: background-color 0.2s ease;
}

.faq summary:hover {
    background: #f1f5f9;
}

.faq details[open] summary {
    background: #e3f2fd;
    border-bottom: 1px solid #e1e8ed;
}

.faq details p {
    padding: 1rem;
    margin: 0;
    background: #ffffff;
    color: #34495e;
}

/* Legal Content Styling */
.legal-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1rem;
    line-height: 1.6;
    color: #2c3e50;
}

.legal-content h1 {
    color: #2c3e50;
    margin-bottom: 1.5rem;
    font-size: 2rem;
}

.legal-content h2 {
    color: #34495e;
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-size: 1.3rem;
    border-bottom: 1px solid #e1e8ed;
    padding-bottom: 0.5rem;
}

.legal-content p {
    margin-bottom: 1rem;
}

.legal-content ul {
    margin: 1rem 0;
    padding-left: 2rem;
}

.legal-content li {
    margin-bottom: 0.5rem;
}

.legal-content strong {
    color: #2c3e50;
}

/* Cookie Banner Styling */
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #2c3e50;
    color: white;
    z-index: 1000;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
    border-top: 3px solid #3498db;
}

.cookie-banner-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.cookie-banner h3 {
    margin: 0;
    font-size: 1.2rem;
    color: #ecf0f1;
}

.cookie-banner p {
    margin: 0;
    line-height: 1.5;
    color: #bdc3c7;
}

.cookie-privacy-link {
    color: #3498db;
    text-decoration: underline;
}

.cookie-privacy-link:hover {
    color: #5dade2;
}

.cookie-banner-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.cookie-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cookie-btn-primary {
    background: #3498db;
    color: white;
}

.cookie-btn-primary:hover {
    background: #2980b9;
}

.cookie-btn-secondary {
    background: transparent;
    color: #bdc3c7;
    border: 1px solid #7f8c8d;
}

.cookie-btn-secondary:hover {
    background: #34495e;
    color: white;
}

.cookie-btn:focus-visible {
    outline: 2px solid #5dade2;
    outline-offset: 2px;
}

/* ===== MOBILE STYLES ===== */
@media screen and (max-width: 768px) {
    /* Base containers */
    body {
        font-size: 14px !important;
    }
    
    .container {
        padding: 8px !important;
        margin: 0 !important;
        max-width: 100% !important;
    }
    
    /* Main sections */
    .tool {
        padding: 0 8px !important;
        margin: 0.5rem auto !important;
        max-width: 100% !important;
    }
    
    .tool h1 {
        font-size: 1.4rem !important;
        margin-bottom: 0.8rem !important;
        text-align: center !important;
    }
    
    /* Content sections */
    .content {
        padding: 0 8px !important;
        margin: 1rem auto !important;
        max-width: 100% !important;
        font-size: 14px !important;
    }
    
    .content h2 {
        font-size: 1.2rem !important;
        margin-bottom: 0.6rem !important;
    }
    
    .content h3 {
        font-size: 1rem !important;
        margin-bottom: 0.4rem !important;
        margin-top: 1rem !important;
    }
    
    .content p {
        font-size: 14px !important;
        line-height: 1.5 !important;
        margin-bottom: 0.8rem !important;
    }
    
    .content li {
        font-size: 14px !important;
        line-height: 1.4 !important;
        margin-bottom: 0.3rem !important;
    }
    
    .content ul {
        padding-left: 1.2rem;
    }
    
    .content li {
        font-size: 0.9rem;
        line-height: 1.5;
        margin-bottom: 0.5rem;
    }
    
    /* FAQ section */
    .faqs {
        padding: 0 0.5rem;
        margin: 1.5rem auto;
    }
    
    .faqs h2 {
        font-size: 1.3rem;
        margin-bottom: 1rem;
    }
    
    .faqs summary {
        padding: 0.8rem;
        font-size: 0.95rem;
        line-height: 1.4;
    }
    
    .faqs details p {
        padding: 0.8rem;
        font-size: 0.85rem;
        line-height: 1.5;
    }
    
    /* Converter grid */
    .converter-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 0 0.5rem;
    }
    
    .converter-card {
        padding: 1rem;
    }
    
    .converter-card h3 {
        font-size: 1.1rem;
    }
    
    .converter-card p {
        font-size: 0.85rem;
    }
    
    /* Header navigation */
    .header-nav {
        gap: 1rem;
        margin-top: 0.8rem;
    }
    
    .header-nav a {
        font-size: 0.85rem;
    }
    
    /* Cookie banner */
    .cookie-banner-content {
        padding: 1rem;
    }
    
    .cookie-banner-buttons {
        justify-content: center;
    }
    
    .cookie-btn {
        flex: 1;
        min-width: 120px;
    }
    
    /* FAQ section */
    .faqs {
        padding: 0 8px !important;
        margin: 1rem auto !important;
        max-width: 100% !important;
    }
    
    .faqs h2 {
        font-size: 1.2rem !important;
        margin-bottom: 0.8rem !important;
    }
    
    .faqs summary {
        padding: 0.6rem !important;
        font-size: 14px !important;
        line-height: 1.3 !important;
    }
    
    .faqs details p {
        padding: 0.6rem !important;
        font-size: 13px !important;
        line-height: 1.4 !important;
    }
    
    /* Form elements */
    .converter-main {
        padding: 0 8px !important;
        margin: 0.5rem auto !important;
    }
    
    .converter-main .input-field {
        font-size: 14px !important;
        padding: 8px !important;
    }
    
    .converter-main label {
        font-size: 13px !important;
    }
    
    /* Navigation */
    .header-nav {
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
        justify-content: center !important;
    }
    
    .header-nav a {
        font-size: 13px !important;
        padding: 4px 8px !important;
    }
}

/* Small mobile screens */
@media screen and (max-width: 480px) {
    body {
        font-size: 13px !important;
    }
    
    .container {
        padding: 5px !important;
    }
    
    .tool {
        padding: 0 5px !important;
    }
    
    .content {
        padding: 0 5px !important;
        font-size: 13px !important;
    }
    
    .content h2 {
        font-size: 1.1rem !important;
    }
    
    .content p, .content li {
        font-size: 13px !important;
    }
    
    .faqs {
        padding: 0 5px !important;
    }
    
    .faqs summary {
        font-size: 13px !important;
        padding: 0.5rem !important;
    }
    
    .faqs details p {
        font-size: 12px !important;
        padding: 0.5rem !important;
    }
}

/* Desktop layout for cookie banner */
@media (min-width: 769px) {
    .cookie-banner-content {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
    
    .cookie-banner-buttons {
        flex-shrink: 0;
        margin-left: 2rem;
    }
}

/* ----- Mobile-first stacking order so converter appears first ----- */
@media (max-width: 899px) {
  .page {
    display: flex;
    flex-direction: column;
  }
  .tool        { order: 1; }
  .ads-inline  { order: 2; }
  .content     { order: 3; }
  .faqs        { order: 4; }
  .ads-footer  { order: 5; }
}

/* Keep desktop layout unchanged; if a grid/flex is used on desktop, it will still apply above 900px */

/* Optional: make the converter stand out on phones */
@media (max-width: 899px) {
  .tool { margin-top: 12px; }
}

/* Ensure headings and text remain readable on phones (if not already added) */
:root {
  --fs-base: clamp(0.95rem, 0.9vw + 0.6rem, 1.0625rem);
  --fs-h1:   clamp(1.6rem, 4vw + 0.6rem, 2.4rem);
  --fs-h2:   clamp(1.25rem, 3vw + 0.5rem, 1.8rem);
  --fs-h3:   clamp(1.1rem, 2vw + 0.4rem, 1.3rem);
}
body { font-size: var(--fs-base); line-height: 1.6; }

/* Prevent fixed widths breaking mobile */
.tool, .content, .faqs, .ads-inline, .ads-footer { max-width: 100%; }

/* Inputs at 16px to avoid iOS zoom-on-focus */
input, select, textarea, button { font-size: 16px; }

@media (max-width: 899px) {
  main.page { display:flex !important; flex-direction:column !important; }
  main.page > .tool       { order:1 !important; }
  main.page > .ads-inline { order:2 !important; }
  main.page > .content    { order:3 !important; }
  main.page > .faqs       { order:4 !important; }
  main.page > .ads-footer { order:5 !important; }
}

/* New Layout Structure CSS Rules */

/* Desktop 2-column layout */
@media (min-width: 900px) {
  .layout {
    display: flex;
    gap: 3rem;
    align-items: flex-start;
  }
  
  .layout .tool {
    flex: 1;
    max-width: 500px;
  }
  
  .layout .article {
    flex: 1;
    max-width: 600px;
  }
}

/* Mobile single-column layout with converter-first ordering */
@media (max-width: 899px) {
  .layout {
    display: flex !important;
    flex-direction: column !important;
  }
  
  .layout .tool {
    order: 1 !important;
  }
  
  .layout .article {
    order: 2 !important;
    display: flex !important;
    flex-direction: column !important;
  }
  
  .layout .article .ads-inline {
    order: 1 !important;
  }
  
  .layout .article .content {
    order: 2 !important;
  }
  
  .layout .article .faqs {
    order: 3 !important;
  }
  
  /* Ensure converter tool stands out on mobile */
  .layout .tool {
    margin-bottom: 1.5rem !important;
    padding: 1rem !important;
    background: rgba(255, 255, 255, 0.9) !important;
    border-radius: 8px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
  }
}

/* Ensure proper spacing and max-widths */
.layout .tool,
.layout .article,
.layout .article .content,
.layout .article .faqs,
.layout .article .ads-inline {
  max-width: 100%;
}

/* Fine-tune desktop layout */
@media (min-width: 900px) {
  .layout .article .content {
    margin-bottom: 2rem;
  }
  
  .layout .article .faqs {
    margin-bottom: 1rem;
  }
}
