/* Mobile-First Responsive CSS */
/* Viewport meta tag should be added to HTML head:
   <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
*/

/* Base Styles - Mobile First */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent; /* Remove mobile tap highlight */
}

html {
    font-size: 14px; /* Base font size for mobile */
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    overflow-x: hidden; /* Prevent horizontal overflow */
    -webkit-font-smoothing: antialiased; /* Better font rendering on mobile */
    -moz-osx-font-smoothing: grayscale;
}

/* Touch-friendly minimum sizes */
button, 
input, 
select, 
textarea,
a {
    min-height: 44px; /* Minimum touch target size */
    min-width: 44px;
}

/* Navbar */
.navbar {
    background: linear-gradient(135deg, #1a2980 0%, #26d0ce 100%);
    color: white;
    padding: 0.75rem 0; /* Reduced padding for mobile */
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: relative;
}

.navbar-container {
    max-width: 100%; /* Full width on mobile */
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap; /* Allow wrapping on small screens */
}

.navbar-brand {
    color: white;
    text-decoration: none;
    font-size: 1.25rem; /* Smaller on mobile */
    font-weight: bold;
    padding: 0.5rem 0; /* Added padding for touch */
}

.navbar-brand span {
    color: #ffd700;
}

.mobile-menu-btn {
    display: block; /* Always show on mobile first */
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    z-index: 1000;
}

.navbar-menu {
    display: none; /* Hidden by default on mobile */
    position: fixed; /* Full screen overlay */
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #1a2980 0%, #26d0ce 100%);
    flex-direction: column;
    padding: 4rem 1rem 1rem;
    gap: 1rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    z-index: 999;
    overflow-y: auto; /* Scrollable if many items */
}

.navbar-menu.active {
    display: flex;
}

.navbar-menu a {
    color: white;
    text-decoration: none;
    transition: color 0.3s;
    font-size: 1.1rem;
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
    background: rgba(255, 255, 255, 0.1);
}

.navbar-menu a:hover,
.navbar-menu a:active {
    color: #ffd700;
    background: rgba(255, 255, 255, 0.2);
}

/* Calculator Container */
.calculator-container {
    max-width: 100%; /* Full width on mobile */
    margin: 1rem auto;
    padding: 0 1rem;
}

.calculator-header {
    text-align: center;
    margin-bottom: 1.5rem;
    padding: 1.5rem 1rem; /* Reduced padding */
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    overflow: hidden; /* Prevent content overflow */
}

.calculator-header h1 {
    color: #1a2980;
    margin-bottom: 0.5rem;
    font-size: 1.5rem; /* Smaller heading on mobile */
    line-height: 1.3;
}

.calculator-header p {
    color: #666;
    font-size: 1rem;
    line-height: 1.5;
}

/* Calculator Grid */
.calculator-grid {
    display: flex;
    flex-direction: column; /* Single column on mobile */
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    width: 100%;
}

/* Input Section */
.input-section {
    background: white;
    padding: 1.25rem; /* Reduced padding */
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    margin-bottom: 1rem;
    width: 100%;
}

.input-group {
    margin-bottom: 1.25rem;
    width: 100%;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #1a2980;
    font-size: 0.95rem;
}

.input-wrapper {
    position: relative;
    width: 100%;
}

.input-with-slider {
    display: flex;
    flex-direction: column;
    gap: 0.75rem; /* Increased gap for touch */
    width: 100%;
}

.input-with-slider input[type="number"] {
    width: 100%;
    padding: 0.875rem; /* Larger padding for touch */
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
    -webkit-appearance: none; /* Remove default iOS styling */
    appearance: none;
}

.input-with-slider input[type="number"]:focus {
    outline: none;
    border-color: #1a2980;
}

/* Touch-friendly range slider */
.input-with-slider input[type="range"] {
    width: 100%;
    height: 8px; /* Thicker for touch */
    -webkit-appearance: none;
    background: #e0e0e0;
    border-radius: 4px;
    outline: none;
    margin: 1rem 0;
}

.input-with-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 24px; /* Larger for touch */
    height: 24px;
    background: #1a2980;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.3s, transform 0.2s;
    border: 3px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.input-with-slider input[type="range"]::-webkit-slider-thumb:active {
    transform: scale(1.1);
    background: #26d0ce;
}

.pension-select {
    width: 100%;
    padding: 0.875rem; /* Larger padding for touch */
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s;
}

.pension-select:focus {
    outline: none;
    border-color: #1a2980;
}

.input-help {
    display: block;
    margin-top: 0.5rem;
    color: #666;
    font-size: 0.85rem;
    line-height: 1.4;
}

/* Results Section */
.results-section {
    background: white;
    padding: 1.25rem;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    margin-bottom: 1rem;
    width: 100%;
    overflow: hidden;
}

.results-grid {
    display: grid;
    grid-template-columns: 1fr; /* Single column on mobile */
    gap: 1rem;
}

.result-card {
    text-align: center;
    padding: 1rem;
    border-radius: 8px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    min-height: 100px; /* Fixed height for consistency */
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.result-card.contribution-emphasis {
    background: linear-gradient(135deg, #1a2980 0%, #26d0ce 100%);
    color: white;
}

.result-card h3 {
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    color: inherit;
    opacity: 0.9;
}

.result-value {
    font-size: 1.25rem; /* Smaller on mobile */
    font-weight: bold;
    margin-bottom: 0.25rem;
    color: inherit;
    word-break: break-word; /* Prevent overflow */
}

.result-note {
    font-size: 0.75rem;
    color: inherit;
    opacity: 0.8;
    line-height: 1.3;
}

/* Benefits Section */
.benefits-section {
    background: white;
    padding: 1.25rem;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    margin-bottom: 1.5rem;
    width: 100%;
}

.benefits-section h2 {
    color: #1a2980;
    margin-bottom: 1rem;
    text-align: center;
    font-size: 1.3rem;
}

.benefits-grid {
    display: grid;
    grid-template-columns: 1fr; /* Single column on mobile */
    gap: 1rem;
}

.benefit-card {
    text-align: center;
    padding: 1.25rem;
    border-radius: 8px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.benefit-card h3 {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.benefit-value {
    font-size: 1.5rem; /* Smaller on mobile */
    font-weight: bold;
    margin: 0.5rem 0;
}

.benefit-card p {
    font-size: 0.85rem;
    opacity: 0.9;
    line-height: 1.4;
}

/* Right Column Styles */
.right-column {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
}

/* Chart Section */
.chart-section {
    background: white;
    padding: 1.25rem;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    width: 100%;
    overflow: hidden; /* Prevent chart overflow */
}

.chart-section h2 {
    color: #1a2980;
    margin-bottom: 1rem;
    text-align: center;
    font-size: 1.3rem;
}

.chart-container {
    height: 250px; /* Reduced height for mobile */
    position: relative;
    width: 100%;
    max-width: 100%;
}

/* Contribution Table */
.contribution-section {
    background: white;
    padding: 1.25rem;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    width: 100%;
    overflow: hidden; /* Important for table scrolling */
}

.contribution-section h2 {
    color: #1a2980;
    margin-bottom: 1rem;
    text-align: center;
    font-size: 1.3rem;
}

.table-container {
    overflow-x: auto; /* Enable horizontal scrolling */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    width: 100%;
    margin: 0 -1.25rem; /* Negative margin for full-width scroll */
    padding: 0 1.25rem; /* Padding to compensate */
}

#contributionTable {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px; /* Minimum width before scrolling */
}

#contributionTable thead {
    background: linear-gradient(135deg, #1a2980 0%, #26d0ce 100%);
    color: white;
}

#contributionTable th {
    padding: 0.75rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
}

#contributionTable tbody tr {
    border-bottom: 1px solid #ddd;
}

#contributionTable tbody tr:nth-child(even) {
    background: #f8f9fa;
}

#contributionTable td {
    padding: 0.75rem;
    font-size: 0.9rem;
    white-space: nowrap;
}

/* Info Section */
.info-section {
    background: white;
    padding: 1.5rem 1rem;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    margin-bottom: 1.5rem;
    width: 100%;
}

.info-section h2 {
    color: #1a2980;
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
}

.info-grid {
    display: flex;
    flex-direction: column; /* Single column on mobile */
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.info-card {
    background: #f8f9fa;
    padding: 1.25rem;
    border-radius: 8px;
    border-left: 4px solid #1a2980;
}

.info-card h3 {
    color: #1a2980;
    margin-bottom: 0.75rem;
    font-size: 1rem;
}

.info-card p {
    line-height: 1.6;
    font-size: 0.9rem;
}

/* FAQ Section */
.faq-section {
    margin-top: 2rem;
    width: 100%;
}

.faq-section h2 {
    color: #1a2980;
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
}

.faq-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

details {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1rem;
    border-left: 4px solid #26d0ce;
}

summary {
    font-weight: 600;
    color: #1a2980;
    cursor: pointer;
    padding: 0.5rem 0;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95rem;
    min-height: 44px; /* Touch friendly */
}

summary::after {
    content: "➕";
    font-size: 1rem;
    transition: transform 0.3s;
}

details[open] summary::after {
    content: "➖";
}

details[open] summary {
    margin-bottom: 1rem;
}

details p {
    color: #666;
    line-height: 1.6;
    padding-left: 0.5rem;
    font-size: 0.9rem;
}

/* Footer */
.footer {
    background: linear-gradient(135deg, #1a2980 0%, #26d0ce 100%);
    color: white;
    padding: 1.5rem 0 0;
    width: 100%;
    overflow: hidden;
}

.footer-container {
    max-width: 100%;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    flex-direction: column; /* Single column on mobile */
    gap: 1.5rem;
}

.footer-section h3 {
    color: #ffd700;
    margin-bottom: 0.75rem;
    font-size: 1rem;
}

.footer-section ul {
    list-style: none;
}

.footer-section ul li {
    margin-bottom: 0.5rem;
}

.footer-section a {
    color: white;
    text-decoration: none;
    transition: color 0.3s;
    font-size: 0.9rem;
    padding: 0.25rem 0;
    display: inline-block;
}

.footer-section a:hover,
.footer-section a:active {
    color: #ffd700;
}

.footer-bottom {
    max-width: 100%;
    margin: 1.5rem auto 0;
    padding: 1rem;
    text-align: center;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 0.85rem;
}

.footer-links {
    margin-top: 0.5rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
}

.footer-links a {
    color: white;
    text-decoration: none;
    margin: 0 0.25rem;
    transition: color 0.3s;
    font-size: 0.85rem;
}

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

/* Ads */
.adsbygoogle {
    margin: 1rem 0;
    border-radius: 8px;
    overflow: hidden;
    max-width: 100%; /* Prevent ad overflow */
}

/* Color Formation Improvements for Mobile */
/* Better contrast for mobile viewing */
.result-card.contribution-emphasis {
    background: linear-gradient(135deg, #0d1a6b 0%, #1bb8b6 100%);
}

.benefit-card {
    background: linear-gradient(135deg, #e069f9 0%, #e2445a 100%);
}

/* Tablet and Larger Screens */
@media (min-width: 768px) {
    html {
        font-size: 16px; /* Larger base font size */
    }
    
    .navbar {
        padding: 1rem 0;
    }
    
    .mobile-menu-btn {
        display: none;
    }
    
    .navbar-menu {
        display: flex;
        position: static;
        background: none;
        padding: 0;
        flex-direction: row;
        gap: 2rem;
    }
    
    .navbar-menu a {
        padding: 0.5rem 0;
        background: none;
    }
    
    .calculator-container {
        max-width: 1200px;
        margin: 2rem auto;
    }
    
    .calculator-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 2rem;
    }
    
    .results-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .benefits-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .info-grid {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    }
    
    .footer-container {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
}

/* Large Mobile and Small Tablets */
@media (min-width: 480px) and (max-width: 767px) {
    .results-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .benefits-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .calculator-header h1 {
        font-size: 1.75rem;
    }
}

/* Very Small Phones */
@media (max-width: 360px) {
    html {
        font-size: 13px;
    }
    
    .calculator-container,
    .navbar-container,
    .footer-container {
        padding: 0 0.75rem;
    }
    
    .calculator-header,
    .input-section,
    .results-section,
    .benefits-section,
    .chart-section,
    .contribution-section,
    .info-section {
        padding: 1rem;
    }
    
    .result-value {
        font-size: 1.1rem;
    }
    
    .benefit-value {
        font-size: 1.3rem;
    }
}

/* Landscape Mode Optimization */
@media (max-height: 500px) and (orientation: landscape) {
    .navbar {
        position: sticky;
        top: 0;
        z-index: 1000;
    }
    
    .calculator-header {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .chart-container {
        height: 200px;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .result-card.contribution-emphasis,
    .benefit-card {
        border: 2px solid #000;
    }
    
    input, select, button {
        border: 2px solid #000;
    }
}

/* Reduce Motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}