/* ========================================
   STABLE RESPONSIVE LAYOUT – PRODUCTION SAFE
   ======================================== */

/* ================= ROOT ================= */

:root {
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-text: #1f2937;
    --color-bg: #ffffff;
    --color-bg-alt: #f9fafb;
    --color-border: #e5e7eb;
    --color-header-bg: #1e293b;
    --color-header-text: #f8fafc;
    --color-footer-bg: #1e293b;
    --color-footer-text: #e2e8f0;

    --radius: 6px;
    --shadow: 0 2px 10px rgba(0,0,0,0.08);
}

/* ================= RESET ================= */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background: var(--color-bg-alt);
    color: var(--color-text);
    line-height: 1.5;
}

/* ================= OUTER LAYOUT ================= */

.outer-layout {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 20px;
    padding: 20px;
}

/* ================= CENTER WRAPPER ================= */

.site-wrapper {
    flex: 1;
    max-width: 1100px;
    min-width: 0;
    background: var(--color-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

/* ================= SKYSCRAPER ADS ================= */

.skyscraper {
    width: 162px;
    min-height: 602px;
    flex-shrink: 0;
    background: var(--color-bg-alt);
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/* Hide skyscrapers when screen too small */
@media (max-width: 1450px) {
    .skyscraper {
        display: none;
    }
}

/* ================= HEADER ================= */

.header {
    display: flex;
    flex-direction: column;
    width: 100%;
    background: var(--color-header-bg);
    color: var(--color-header-text);
}

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
}


.logo a {
    color: white;
    text-decoration: none;
    font-weight: 600;
    font-size: 1.2rem;
}

.main-nav a {
    color: #cbd5e1;
    text-decoration: none;
    margin-left: 15px;
}

/* ================= INNER LAYOUT ================= */

.inner-layout {
    display: flex;
    gap: 25px;
    padding: 25px;
}

.center-column {
    flex: 1;
    min-width: 0;
}

.right-sidebar {
    width: 280px;
    flex-shrink: 0;
}

/* Hide sidebar on tablet */
@media (max-width: 1024px) {
    .right-sidebar {
        display: none;
    }
}



/* ================= TWO COLUMN LAYOUT: FORM + CHARTS ================= */

.calculator-container {
    display: flex;
    flex-direction: row;
    gap: 20px;
    align-items: flex-start;
    border: 1px solid var(--color-border);
    padding: 15px;
    border-radius: var(--radius);
    margin-bottom: 20px;
}

/* LEFT: Compact Form Column */
.calculator-form-wrapper {
    flex: 0 0 280px;        /* Fixed width, doesn't grow */
    min-width: 0;
}

.calculator-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 0;
}

.form-group label {
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    margin: 0;
}

.form-group input,
.form-group select {
    padding: 4px 6px;
    font-size: 13px;
    height: 28px;           /* Fixed small height */
    border: 1px solid #ccc;
    border-radius: 3px;
}

/* Unit dropdown: input + select tight together */
.input-with-unit {
    display: flex;
    flex-direction: row;
    gap: 4px;
}

.input-with-unit input {
    flex: 1;
    min-width: 0;
}

.input-with-unit select {
    width: 60px;            /* Fixed small width */
    padding: 2px;
    font-size: 12px;
}

.form-group .hint {
    font-size: 10px;
    color: #666;
    line-height: 1.2;
}

/* Buttons */
.btn-group {
    display: flex;
    flex-direction: row;
    gap: 8px;
    margin-top: 10px;
}

.calculate-btn,
.reset-btn {
    flex: 1;
    padding: 6px 0;
    font-size: 12px;
    height: 32px;
}

/* Results below form */
.results-section {
    margin-top: 10px;
    font-size: 13px;
}

/* RIGHT: Charts Column (grows to fill space) */
.charts-wrapper {
    flex: 1;                /* Takes remaining space */
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Chart containers */
.chart-box {
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 10px;
    background: #fafafa;
}

.chart-box h4 {
    font-size: 13px;
    margin-bottom: 8px;
    color: #333;
}

.chart-canvas {
    width: 100%;
    height: 200px;
}

/* Mobile: Stack vertically */
@media (max-width: 768px) {
    .calculator-container {
        flex-direction: column;
    }
    
    .calculator-form-wrapper {
        flex: none;
        width: 100%;
    }
}






/* ================= FOOTER ================= */

.footer {
    background: var(--color-footer-bg);
    color: #ffffff;
    padding: 20px;
    text-align: center;
    font-weight: bold;
}

.footer a {
    color: #ffffff;
    font-weight: bold;
}

/* ================= MOBILE ================= */

@media (max-width: 768px) {

    .outer-layout {
        flex-direction: column;
        padding: 0;
        gap: 0;
    }

    .site-wrapper {
        width: 100%;
        border-radius: 0;
    }

    .inner-layout {
        flex-direction: column;
        padding: 20px;
    }

    .btn-group {
        flex-direction: column;
    }
}


/* ================= ads 302*250================= */


.ad-row {
    display: flex;
    gap: 15px;
    margin: 25px 0;
    flex-wrap: wrap;
}

.ad-placeholder {
    border: 2px dashed #3498db;
    padding: 20px;
    text-align: center;
    background: #f0f7ff;
}


.ad-row {
    display: flex;
    gap: 20px;
    margin: 30px 0;
    flex-wrap: wrap;
}

.ad-row > * {
    flex: 1;
    min-width: 280px;
}


.ad-row { 
    /* ... existing styles ... */
    background: rgba(255, 0, 0, 0.1); /* Temporary red tint to see space */
    min-height: 260px; /* Force height for 250px ads */
}





/* ========================================
   DEBUG MODE - VISUALIZE LAYOUT BOXES
   (Remove this section when done)
   ======================================== */

/* Outer Layout - BLUE */
.outer-layout {
    outline: 3px dashed #007bff !important;
    background: rgba(0, 123, 255, 0.05) !important;
}

/* Main Site Wrapper - GREEN */
.site-wrapper {
    outline: 3px dashed #28a745 !important;
    background: rgba(40, 167, 69, 0.05) !important;
}

/* Skyscrapers (Left/Right) - PURPLE */
.skyscraper {
    outline: 3px dashed #6f42c1 !important;
    background: rgba(111, 66, 193, 0.1) !important;
}

/* Inner Layout (Inside Wrapper) - ORANGE */
.inner-layout {
    outline: 3px dashed #fd7e14 !important;
    background: rgba(253, 126, 20, 0.05) !important;
}

/* Center Column - CYAN */
.center-column {
    outline: 2px solid #17a2b8 !important;
    background: rgba(23, 162, 184, 0.05) !important;
}

/* Right Sidebar - RED (Critical for your issue) */
.right-sidebar {
    outline: 3px dashed #dc3545 !important;
    background: rgba(220, 53, 69, 0.1) !important;
    min-height: 100px !important; /* Force visibility even if empty */
}

/* Ad Rows - PINK */
.ad-row {
    outline: 2px dashed #e83e8c !important;
    background: rgba(232, 62, 140, 0.05) !important;
}

/* Ad Placeholders - YELLOW */
.ad-placeholder {
    outline: 2px solid #ffc107 !important;
    background: rgba(255, 193, 7, 0.2) !important;
}

/* Header - DARK BLUE */
.header {
    outline: 2px solid #004085 !important;
}

/* Footer - DARK GREEN */
.footer {
    outline: 2px solid #155724 !important;
}


/* Results */

.results-wrapper {
  margin-top: 15px;
}

.copy-btn {
  margin-top: 10px;
  padding: 6px 12px;
  font-size: 14px;
  border: 1px solid #ddd;
  background: white;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.2s ease;
}

.copy-btn:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.recent-calculators {
  margin-top: 40px;
  padding: 20px;
  border-top: 1px solid #eee;
}

.recent-calculators ul {
  list-style: none;
  padding: 0;
}

.recent-calculators li {
  margin-bottom: 6px;
}

/* ==Sharing=== */

.action-buttons {
    margin-top: 10px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.copy-btn,
.share-btn {
    padding: 6px 12px;
    font-size: 14px;
    border: 1px solid #ddd;
    background: #f8f9fa;
    cursor: pointer;
    border-radius: 4px;
}

.copy-btn:hover,
.share-btn:hover {
    background: #e9ecef;
}





/* Fix unit dropdown size */
.input-unit-wrapper {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.input-unit-wrapper input {
  flex: 1;
  min-width: 0; /* Prevents overflow */
}

.input-unit-wrapper select {
  width: auto;
  min-width: 80px;
  padding: 8px 24px 8px 12px;
  font-size: 14px;
  height: auto;
}

/* Ensure form controls are sized properly */
.form-group input,
.form-group select {
  padding: 10px 12px;
  font-size: 16px;
  line-height: 1.4;
  border: 1px solid #ccc;
  border-radius: 4px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
}





/* ================= VERTICAL FORM LAYOUT ================= */

.calculator-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 500px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Unit dropdown stacks vertically */
.input-with-unit {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-with-unit input,
.input-with-unit select {
  width: 100%;
}

/* Ensure full width inputs */
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 16px;
}

/* Buttons stay horizontal but wrap */
.btn-group {
  display: flex;
  flex-direction: row;
  gap: 12px;
  flex-wrap: wrap;
}

.calculate-btn,
.reset-btn {
  flex: 1;
  min-width: 120px;
}

/* ================= TWO COLUMN: FORM + CHARTS ================= */

.calculator-container {
    display: flex;
    flex-direction: row;
    gap: 20px;
    align-items: flex-start;
    border: 1px solid var(--color-border);
    padding: 15px;
    border-radius: var(--radius);
    margin-bottom: 20px;
}

/* LEFT: Form Column - Fixed narrow width */
.calculator-form-wrapper {
    flex: 0 0 260px;
    min-width: 0;
}

.calculator-form {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 1px;
    margin: 0;
}

.form-group label {
    font-size: 11px;
    font-weight: 600;
    line-height: 1.1;
    margin: 0;
    color: var(--color-text);
}

.form-group input,
.form-group select {
    padding: 3px 5px;
    font-size: 12px;
    height: 24px;
    border: 1px solid #bbb;
    border-radius: 3px;
    width: 100%;
}

.input-with-unit {
    display: flex;
    flex-direction: row;
    gap: 4px;
}

.input-with-unit input {
    flex: 1;
    min-width: 0;
}

.input-with-unit select {
    width: 55px;
    padding: 2px;
    font-size: 11px;
    height: 24px;
}

.form-group .hint {
    font-size: 9px;
    color: #777;
    line-height: 1.1;
    margin-top: 1px;
}

.btn-group {
    display: flex;
    flex-direction: row;
    gap: 6px;
    margin-top: 8px;
}

.calculate-btn,
.reset-btn {
    flex: 1;
    padding: 5px 0;
    font-size: 11px;
    height: 28px;
    border-radius: 3px;
}

/* Results Section Container */
.results-section {
    margin-top: 15px;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

/* Individual Result Item */
.results {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    border-left: 4px solid #ffd700;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    animation: slideIn 0.3s ease-out;
}

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

/* Label styling */
.result-label {
    font-size: 16px;
    font-weight: 600;
    color: #4a5568;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Value styling */
.result-value {
    font-size: 28px;
    font-weight: 700;
    color: #2d3748;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.result-value.highlight {
    color: #667eea;
    text-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
}

/* Unit styling */
.result-unit {
    font-size: 18px;
    color: #718096;
    margin-left: 5px;
}

/* Multiple results grid */
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

/* Result meta info */
.result-meta {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid rgba(255,255,255,0.3);
    font-size: 14px;
    color: rgba(255,255,255,0.9);
}

/* Placeholder state */
.results-placeholder {
    text-align: center;
    padding: 40px 20px;
    color: #a0aec0;
    font-style: italic;
}

.example-hint {
    background: #fff3cd;
    color: #856404;
    padding: 12px;
    border-radius: 6px;
    border-left: 4px solid #ffc107;
    margin: 0;
}

.results-wrapper {
    margin-top: 20px;
}

.action-buttons {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.copy-btn, .share-btn {
    padding: 4px 8px;
    font-size: 11px;
}

/* RIGHT: Charts Column - Flexible width */
.charts-wrapper {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.chart-box {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 12px;
    background: #f8f9fa;
}

.chart-box h4 {
    font-size: 13px;
    margin-bottom: 10px;
    color: #333;
    font-weight: 600;
}

.chart-desc {
    font-size: 11px;
    color: #666;
    margin-bottom: 10px;
}

.chart-box canvas {
    width: 100%;
    height: 180px;
    display: block;
}

/* Mobile: Stack vertically */
@media (max-width: 768px) {
    .calculator-container {
        flex-direction: column;
    }
    
    .calculator-form-wrapper {
        flex: none;
        width: 100%;
    }
    
    .charts-wrapper {
        width: 100%;
    }
}


/* ================= DONUT CHART ================= */

.donut-chart-box {
  text-align: center;
  padding: 15px;
}

.donut-chart-box h4 {
  font-size: 14px;
  margin-bottom: 15px;
  color: #333;
}

#chart-donut {
  display: block;
  margin: 0 auto;
}

.donut-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 15px;
  font-size: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 2px;
}



/* Currency selector */
.currency-selector {
  margin-bottom: 15px;
  padding: 10px;
  background: #f8f9fa;
  border-radius: 4px;
}

.currency-selector label {
  font-size: 12px;
  font-weight: 600;
  margin-right: 8px;
}

.currency-selector select {
  padding: 4px 8px;
  font-size: 13px;
  border: 1px solid #ccc;
  border-radius: 3px;
}

/* Result display */
.result-value {
  font-size: 28px;
  font-weight: bold;
  color: #2563eb;
  display: block;
  margin-top: 8px;
}

/* Powered by */
.powered-by {
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid #e5e7eb;
  text-align: center;
  font-size: 12px;
}

.powered-by a {
  color: #6b7280;
  text-decoration: none;
}

.powered-by a:hover {
  color: #2563eb;
}

/* Calculator footer */
.calculator-footer {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 2px solid #e5e7eb;
  text-align: center;
}

.home-link {
  color: #2563eb;
  text-decoration: none;
  font-size: 14px;
}

.home-link:hover {
  text-decoration: underline;
}





/* ===============================
HEADER LAYOUT
================================ */

.logo a {
font-size: 22px;
font-weight: 700;
text-decoration: none;
}

.header-search {
display: flex;
gap: 6px;
}

#header-search-input {
padding: 6px 8px;
border: 1px solid #ccc;
border-radius: 4px;
}

#header-search-btn {
padding: 6px 10px;
cursor: pointer;
}

/* ===============================
CATEGORY NAVIGATION
================================ */

.category-nav {
    margin: 0;
    padding: 10px 20px;
    display: flex;
    gap: 20px;
}

.category-nav a {
    color: var(--color-header-text);
}


.category-nav a:hover {
    text-decoration: underline;
}


/* ===============================
HOMEPAGE SEARCH
================================ */

.homepage-search {
margin-top: 20px;
display: flex;
justify-content: center;
gap: 8px;
}

.homepage-search-input {
width: 320px;
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
}

.homepage-search-btn {
padding: 10px 14px;
cursor: pointer;
}

/* ===============================
CATEGORY SEARCH
================================ */

.category-search {
margin: 20px 0;
}

.category-search-input {
width: 100%;
max-width: 420px;
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
}

/* ===============================
CATEGORY GRID
================================ */

.categories-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
gap: 16px;
margin-top: 20px;
}

.category-card {
border: 1px solid #e5e5e5;
padding: 15px;
border-radius: 6px;
background: #fff;
}

.category-card h3 {
margin: 0 0 6px 0;
}

/* ===============================
CALCULATOR GRID
================================ */

.calculator-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
gap: 16px;
margin-top: 20px;
}

.calculator-card {
border: 1px solid #e5e5e5;
padding: 15px;
border-radius: 6px;
background: #fff;
}

.calculator-card h3 {
margin-top: 0;
}

.calculator-card a {
text-decoration: none;
color: #222;
}

.calculator-card a:hover {
text-decoration: underline;
}

/* ===============================
SEARCH RESULTS PANEL
================================ */

.search-results {
position: fixed;
top: 120px;
left: 50%;
transform: translateX(-50%);
width: 600px;
max-width: 90%;
background: white;
border: 1px solid #ccc;
border-radius: 6px;
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
z-index: 999;
padding: 15px;
}

.search-result-item {
padding: 10px 0;
border-bottom: 1px solid #eee;
}

.search-result-item a {
text-decoration: none;
color: #222;
}

.search-result-item strong {
display: block;
}

.no-results {
color: #888;
}



/* ===== MOBILE HEADER ===== */

.header {
  position: relative; /* needed for overlay menu */
}

.mobile-actions {
  display: none;
  gap: 10px;
}

.mobile-actions button {
  font-size: 18px;
  border: none;
  background: none;
  color: #ffffff !important;
}



/* ===== DESKTOP DEFAULT ===== */
.desktop-only {
  display: block;
}

/* ===== MOBILE BREAKPOINT ===== */
@media (max-width: 768px) {

  .desktop-only {
    display: none;
  }

 .mobile-actions {
    display: flex;
    gap: 10px;
  }

  .category-nav {
    display: none;
  }

}

.header,
.header-row,
.category-nav {
    background: var(--color-footer-bg) !important;
    color: var(--color-footer-text) !important;
}

.header a,
.category-nav a,
.logo a {
    color: var(--color-footer-text) !important;
    font-weight: 700;
}



/* ===== FINAL MOBILE MENU FIX ===== */

.mobile-menu {
    display: none;
}

.mobile-menu.active {
    display: block;
    position: absolute;
    top: 70px;   /* below header */
    left: 0;
    width: 50%;
    z-index: 9999;

    background: #1e293b; /* same as header/footer */
}

/* links */
.mobile-menu a {
    display: block;
    padding: 5px 5px;
    color: #ffffff;
    text-decoration: none;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}


.logo-wrap {
  text-decoration: none;
  flex-direction: row;
align-items: center;
gap: 2px;
}

.logo img {
  height: 25px;
  width: auto;
}

.site-name {
  font-size: 25px;
  font-weight: 700;
  color: var(--color-header-text);
  margin-top: 0px;
}




.header-search {
  display: flex;
  align-items: center;
  gap: 6px;
}

.lang-dropdown {
  padding: 4px 6px;
  border-radius: 0px;
  border: 1px solid #ccc;
  background: white;
  cursor: pointer;
}


.header-search {
  display: flex;
}

.header-lang {
  display: flex;
  align-items: center;
}

/* MOBILE */
@media (max-width: 768px) {

  .desktop-only {
    display: none !important;
  }

  .mobile-actions {
    display: flex;
    gap: 10px;
  }

}

