/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --accent-color: #e74c3c;
    --success-color: #27ae60;
    --light-bg: #ecf0f1;
    --dark-text: #2c3e50;
    --border-radius: 8px;
    --header-height: 70px;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--dark-text);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding-top: var(--header-height);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Navigation Styles */
.main-nav {
    background: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--header-height);
    z-index: 1000;
}

.main-nav .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
}

/* Logo */
.logo a {
    font-size: 1.8rem;
    font-weight: bold;
    text-decoration: none;
    color: var(--primary-color);
}

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

/* Desktop Navigation */
.nav-menu {
    display: flex;
    list-style: none;
    gap: 2rem;
    margin: 0;
    padding: 0;
}

.nav-item {
    position: relative;
}

.nav-link {
    text-decoration: none;
    color: var(--dark-text);
    font-weight: 500;
    transition: color 0.3s;
}

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

/* Dropdown */
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    min-width: 280px;
    border-radius: var(--border-radius);
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
    display: none;
    list-style: none;
    padding: 0.5rem 0;
    z-index: 1000;
}

.dropdown:hover .dropdown-menu {
    display: block;
}

.dropdown-menu li {
    padding: 0;
}

.dropdown-menu a {
    color: var(--dark-text);
    text-decoration: none;
    display: block;
    padding: 0.8rem 1.5rem;
    transition: background 0.3s;
}

.dropdown-menu a:hover {
    background: var(--light-bg);
    color: var(--secondary-color);
}

/* Mobile Menu Toggle - Hidden on desktop by default */
.mobile-menu-toggle {
    display: none;  /* Hidden on desktop */
    background: var(--secondary-color);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    cursor: pointer;
    color: white;
    font-size: 1.5rem;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.mobile-menu-toggle:hover {
    background: #2980b9;
}

/* Mobile Navigation Panel - Hidden by default */
.mobile-nav {
    position: fixed;
    top: 0;
    right: -100%;
    width: 100%;
    max-width: 350px;
    height: 100vh;
    background: white;
    z-index: 1001;
    transition: right 0.3s ease;
    box-shadow: -5px 0 20px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.mobile-nav.active {
    right: 0;
}

.mobile-nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--light-bg);
    height: var(--header-height);
}

.mobile-logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
}

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

.mobile-close-btn {
    background: none;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--dark-text);
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.mobile-close-btn:hover {
    background: var(--light-bg);
}

.mobile-nav-menu {
    list-style: none;
    padding: 1.5rem;
    flex: 1;
}

.mobile-nav-item {
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--light-bg);
}

.mobile-nav-link {
    text-decoration: none;
    color: var(--dark-text);
    display: block;
    padding: 1rem 0;
    font-weight: 500;
    transition: color 0.3s;
}

.mobile-nav-link:hover {
    color: var(--secondary-color);
}

.mobile-dropdown-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.mobile-dropdown-icon {
    transition: transform 0.3s;
    color: var(--secondary-color);
}

.mobile-dropdown.active .mobile-dropdown-icon {
    transform: rotate(180deg);
}

.mobile-dropdown-menu {
    list-style: none;
    padding-left: 1rem;
    display: none;
    margin-bottom: 1rem;
}

.mobile-dropdown.active .mobile-dropdown-menu {
    display: block;
}

.mobile-dropdown-menu li {
    margin: 0.5rem 0;
}

.mobile-dropdown-menu a {
    text-decoration: none;
    color: #666;
    display: block;
    padding: 0.8rem 1rem;
    border-radius: var(--border-radius);
    transition: all 0.3s;
    font-size: 0.95rem;
}

.mobile-dropdown-menu a:hover {
    background: var(--light-bg);
    color: var(--secondary-color);
    padding-left: 1.5rem;
}

.mobile-nav-footer {
    padding: 1.5rem;
    text-align: center;
    border-top: 1px solid var(--light-bg);
    color: #666;
    font-size: 0.9rem;
}

/* Overlay */
.mobile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
}

.mobile-overlay.active {
    display: block;
}

/* Main Content */
main {
    padding: 2rem 0;
    min-height: calc(100vh - var(--header-height));
}

/* Calculator Card Styles */
.calculator-card {
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    padding: 2rem;
    max-width: 600px;
    margin: 0 auto;
}

.calculator-card h1 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 2rem;
    text-align: center;
}

.calculator-card .description {
    text-align: center;
    color: #666;
    margin-bottom: 2rem;
}

/* Calculator Form */
.calculator-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-group label {
    font-weight: 600;
    color: var(--primary-color);
}

.input-group input {
    padding: 1rem;
    border: 2px solid #e0e0e0;
    border-radius: var(--border-radius);
    font-size: 1.1rem;
    transition: border-color 0.3s;
}

.input-group input:focus {
    outline: none;
    border-color: var(--secondary-color);
}

.calculate-btn {
    background: var(--secondary-color);
    color: white;
    border: none;
    padding: 1rem;
    border-radius: var(--border-radius);
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.3s, transform 0.2s;
}

.calculate-btn:hover {
    background: #2980b9;
    transform: translateY(-2px);
}

.result-box {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--light-bg);
    border-radius: var(--border-radius);
    text-align: center;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--success-color);
}

.explanation-box {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: #f8f9fa;
    border-left: 4px solid var(--secondary-color);
    border-radius: var(--border-radius);
}

.explanation-box h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.explanation-box ol {
    margin-left: 1.5rem;
    color: #555;
}

.explanation-box li {
    margin-bottom: 0.5rem;
}

/* Content Sections */
.content-section {
    background: white;
    border-radius: 15px;
    padding: 2rem;
    margin-top: 3rem;
    box-shadow: 0 5px 20px rgba(0,0,0,0.05);
}

.content-section h2 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.content-section h3 {
    color: var(--secondary-color);
    margin: 1.5rem 0 1rem;
}

.content-section p {
    margin-bottom: 1rem;
    color: #555;
}

.examples {
    background: #f8f9fa;
    border-left: 4px solid var(--secondary-color);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    margin: 1.5rem 0;
}

.examples ul {
    list-style: none;
    padding-left: 1rem;
}

.examples li {
    margin-bottom: 0.5rem;
    position: relative;
    padding-left: 1.5rem;
}

.examples li:before {
    content: "✓";
    color: var(--success-color);
    position: absolute;
    left: 0;
}

/* FAQ Section */
.faq-item {
    border-bottom: 1px solid #e0e0e0;
    padding: 1rem 0;
}

.faq-question {
    font-weight: bold;
    color: var(--primary-color);
    cursor: pointer;
    padding: 0.5rem 0;
}

.faq-answer {
    color: #666;
    padding: 0.5rem 0 0 1rem;
    display: none;
}

.faq-item.active .faq-answer {
    display: block;
}

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

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-section h3 {
    margin-bottom: 1rem;
    color: var(--secondary-color);
}

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

.footer-section a {
    color: white;
    text-decoration: none;
    opacity: 0.8;
    transition: opacity 0.3s;
}

.footer-section a:hover {
    opacity: 1;
}

.footer-bottom {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}

/* ========== MOBILE RESPONSIVE STYLES ========== */
@media (max-width: 768px) {
    /* Hide desktop menu on mobile */
    .nav-menu {
        display: none;
    }
    
    /* Show mobile menu toggle on mobile */
    .mobile-menu-toggle {
        display: flex;
    }
    
    /* Adjust header padding */
    .main-nav .container {
        padding: 0 15px;
    }
    
    /* Smaller logo on mobile */
    .logo a {
        font-size: 1.5rem;
    }
    
    /* Calculator card adjustments */
    .calculator-card {
        padding: 1.5rem;
        margin: 0 10px;
    }
    
    .calculator-card h1 {
        font-size: 1.8rem;
    }
    
    /* Better touch targets */
    button, 
    .btn,
    .nav-link,
    .dropdown-menu a,
    .mobile-menu-toggle,
    .mobile-close-btn,
    .calculate-btn,
    .btn-submit {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Improved form inputs on mobile */
    input[type="number"],
    input[type="text"],
    input[type="email"],
    select,
    textarea {
        font-size: 16px;
        padding: 12px;
    }
    
    /* Content adjustments */
    .content-section {
        padding: 1.5rem;
    }
    
    .footer-content {
        grid-template-columns: 1fr;
        text-align: center;
    }
    
    /* Result box */
    .result-box {
        padding: 1rem;
        font-size: 1.2rem;
    }
    
    .explanation-box {
        padding: 1rem;
    }
    
    /* Fraction input */
    .fraction-input {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
}

/* ========== DESKTOP STYLES (ensure mobile menu is hidden) ========== */
@media (min-width: 769px) {
    /* Ensure desktop menu is visible */
    .nav-menu {
        display: flex !important;
    }
    
    /* Ensure mobile toggle is hidden on desktop */
    .mobile-menu-toggle {
        display: none !important;
    }
    
    /* Ensure mobile nav panel is hidden on desktop */
    .mobile-nav {
        display: none !important;
    }
    
    /* Ensure overlay is hidden on desktop */
    .mobile-overlay {
        display: none !important;
    }
}

/* Small Mobile Devices */
@media (max-width: 480px) {
    .mobile-nav {
        max-width: 100%;
    }
    
    .mobile-nav-header {
        padding: 1rem;
    }
    
    .mobile-nav-menu {
        padding: 1rem;
    }
    
    .calculator-card {
        padding: 1rem;
    }
    
    .calculator-card h1 {
        font-size: 1.5rem;
    }
    
    .input-group input {
        padding: 0.8rem;
    }
}

/* iOS Specific */
@supports (-webkit-touch-callout: none) {
    .mobile-nav {
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .main-nav {
        padding-top: env(safe-area-inset-top);
    }
}

/* Prevent body scroll when menu open */
body.menu-open {
    overflow: hidden;
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .nav-link,
    .dropdown-menu a,
    .mobile-menu-toggle,
    .mobile-close-btn,
    .calculate-btn {
        padding: 0.8rem 0;
        min-height: 44px;
    }
}

/* Landscape Mode */
@media (max-width: 768px) and (orientation: landscape) {
    .mobile-nav {
        padding-top: 20px;
    }
    
    .mobile-nav-menu {
        padding: 0.5rem;
    }
    
    .mobile-nav-item {
        margin-bottom: 0.2rem;
    }
    
    .mobile-nav-link {
        padding: 0.5rem 0;
    }
}

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

/* Calculator Specific Styles */
.percentage-add .input-group,
.percentage-difference .input-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.fraction-input {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 0.5rem;
}

.fraction-input input {
    text-align: center;
}

.fraction-input span {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--primary-color);
}

/* About Page Styles */
.about-content {
    max-width: 1000px;
    margin: 0 auto;
}

.about-header {
    text-align: center;
    color: white;
    padding: 3rem 0;
}

.about-header h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.about-header .subtitle {
    font-size: 1.3rem;
    opacity: 0.9;
}

.about-section {
    background: white;
    border-radius: 15px;
    padding: 2.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

/* Contact Page Styles */
.contact-content {
    max-width: 1200px;
    margin: 0 auto;
}

.contact-header {
    text-align: center;
    color: white;
    padding: 3rem 0;
}

.contact-header h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.contact-header .subtitle {
    font-size: 1.3rem;
    opacity: 0.9;
}

.contact-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 3rem;
}

.contact-info-section,
.contact-form-section {
    background: white;
    border-radius: 15px;
    padding: 2.5rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

/* Legal Pages Styles */
.legal-content {
    background: white;
    border-radius: 15px;
    padding: 3rem;
    max-width: 900px;
    margin: 0 auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.legal-content h1 {
    color: var(--primary-color);
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.last-updated {
    color: #666;
    font-style: italic;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--light-bg);
}

/* Responsive adjustments for all pages */
@media (max-width: 768px) {
    .about-header h1,
    .contact-header h1 {
        font-size: 2.2rem;
    }
    
    .about-section,
    .contact-info-section,
    .contact-form-section,
    .legal-content {
        padding: 1.5rem;
    }
    
    .contact-grid {
        grid-template-columns: 1fr;
    }
}