/* ===== GLOBAL RESET & BASE STYLES ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ------------------------------ */
/* SCROLLBAR STYLES */
/* ------------------------------ */
html::-webkit-scrollbar {
    width: 1rem;
}

html::-webkit-scrollbar-track {
    background: linear-gradient(to bottom right, #F8F9FA, #E1F5C4);
}

html::-webkit-scrollbar-thumb {
    background: #426589;
    border-radius: 10px;
    /* rounded edges */
    border: 2px solid transparent;
    /* space around thumb */

}

html::-webkit-scrollbar-thumb:hover {
    background: #2e4663;
    /* darker on hover */
}

:root {
    --primary-color: #3a7bd5;
    --secondary-color: #00d2ff;
    --accent-color: #ff6b6b;
    --success-color: #4CAF50;
    --warning-color: #ff9f43;
    --dark-color: #2c3e50;
    --light-color: #f8f9fa;
    --text-color: #2d3436;
    --text-light: #ffffff;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

body {
    font-family: 'Montserrat';

    min-height: 100vh;
    margin: 0;
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    line-height: 1.6;
}

header h1 {
    font-size: clamp(2rem, 5vw, 3rem);
    margin-bottom: 0.5rem;
    font-weight: 700;
    position: relative;
    animation: fadeInDown 1s ease;
}

header p {
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    opacity: 0.9;
    position: relative;
    animation: fadeInUp 1s ease 0.3s both;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== LOGO STYLES ===== */
.header-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    position: relative;
}

.logo {
    height: 120px;
    width: auto;
    max-width: 400px;
    object-fit: contain;
    filter: drop-shadow(2px 2px 8px rgba(229, 229, 229, 0.3));
    transition: transform 0.5s ease, filter 0.3s ease;
    cursor: pointer;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

.logo:hover {
    transform: scale(1.1) rotate(5deg);
    filter: drop-shadow(2px 2px 12px rgba(0, 0, 0, 0.4));
    animation: none;
}

.header-text {
    text-align: center;
}

.header-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.logo-inline {
    height: 50px;
    width: auto;
    max-width: 200px;
    object-fit: contain;
    filter: drop-shadow(2px 2px 6px rgba(0, 0, 0, 0.3));
    transition: var(--transition);
}

.logo-inline:hover {
    transform: scale(1.1);
}

.brand-title {
    margin: 0;
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    font-weight: 700;
    color: var(--text-light);
    text-shadow: 2px 2px 6px rgba(0, 0, 0, 0.3);
}

.header-subtitle {
    text-align: center;
    margin: 0;
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    opacity: 0.9;
}

.header-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.logo-center {
    height: 100px;
    width: auto;
    max-width: 250px;
    object-fit: contain;
    filter: drop-shadow(2px 2px 6px rgba(0, 0, 0, 0.3));
    transition: var(--transition);
}

.logo-center:hover {
    transform: scale(1.08) rotate(2deg);
}

.nav-logo {
    height: 30px;
    width: auto;
    margin-right: 0.5rem;
    filter: drop-shadow(1px 1px 3px rgba(0, 0, 0, 0.3));
    transition: var(--transition);
}

.nav-logo:hover {
    transform: scale(1.1);
}

/* ===== ENHANCED DESKTOP NAVIGATION ===== */
.calculator-nav-container {
    background-image: url(/logo/chat.png);
    position: relative;
    margin-bottom: 2rem;
    animation: slideInDown 0.8s ease;
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.calculator-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.8rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.15));
    backdrop-filter: blur(20px);
    margin: 25px auto 2.5rem;
    border-radius: 20px;
    max-width: 1243px;
    flex-direction: row;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.25);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
}

.calculator-nav::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
}

.calculator-nav:hover {
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.3);
    transform: translateY(-5px);
}

/* Navigation buttons with enhanced animations */
.nav-btn {
    padding: 1rem 1.8rem;
    background: linear-gradient(135deg, rgba(149, 149, 149, 0.3), rgba(255, 255, 255, 0.2));
    color: var(--dark-color);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-weight: 600;
    backdrop-filter: blur(10px);
    font-size: 1rem;
    text-align: center;
    white-space: nowrap;
    min-width: fit-content;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.3);
    position: relative;
    overflow: hidden;
    transform-style: preserve-3d;
    perspective: 1000px;
    opacity: 0;
    animation: fadeInUp 0.6s ease forwards;
}

.nav-btn:nth-child(1) {
    animation-delay: 0.1s;
}

.nav-btn:nth-child(2) {
    animation-delay: 0.2s;
}

.nav-btn:nth-child(3) {
    animation-delay: 0.3s;
}

.nav-btn:nth-child(4) {
    animation-delay: 0.4s;
}

.nav-btn:nth-child(5) {
    animation-delay: 0.5s;
}

.nav-btn:nth-child(6) {
    animation-delay: 0.6s;
}

.nav-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(76, 112, 184, 0.5), transparent);
    transition: left 0.7s ease;
    z-index: 1;
}

.nav-btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #b5d2f0, #34495e);
    opacity: 0;
    transition: opacity 0.4s ease;
    z-index: -1;
    border-radius: 50px;
}

.nav-btn:hover::before {
    left: 100%;
}

.nav-btn:hover {
    background: transparent;
    color: var(--text-light);
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15), 0 0 0 2px rgba(255, 255, 255, 0.2);
}

.nav-btn:hover::after {
    opacity: 1;
}

.nav-btn:active {
    transform: translateY(2px) scale(0.98);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.nav-btn.active {
    background: linear-gradient(135deg, #b5d2f0, #34495e);
    color: var(--text-light);
    box-shadow: 0 5px 20px rgba(255, 255, 255, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

@keyframes pulseActive {
    0% {
        box-shadow: 0 5px 20px rgba(58, 123, 213, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.3);
    }

    50% {
        box-shadow: 0 5px 25px rgba(58, 123, 213, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.4);
    }

    100% {
        box-shadow: 0 5px 20px rgba(58, 123, 213, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.3);
    }
}

/* Navigation icons with animation */
.nav-icon {
    font-size: 1.1rem;
    display: inline-block;
    width: 22px;
    text-align: center;
    transition: transform 0.3s ease;
}

.nav-btn:hover .nav-icon {
    transform: scale(1.2) rotate(5deg);
}

.nav-btn.active .nav-icon {
    animation: bounce 0.8s ease;
}

@keyframes bounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-8px);
    }

    60% {
        transform: translateY(-4px);
    }
}

/* Navigation text with subtle animation */
.nav-text {
    font-size: 0.95rem;
    white-space: nowrap;
    position: relative;
    transition: all 0.3s ease;
}

.nav-btn:hover .nav-text {
    letter-spacing: 0.5px;
}

/* Hover effect for the entire nav */
.calculator-nav:hover .nav-btn:not(:hover) {
    transform: scale(0.95);
    opacity: 0.8;
}

/* ===== MOBILE NAVIGATION FIX ===== */
.hamburger-btn {
    display: none;
    padding: 0;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    padding: 0.6rem;
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition);
    backdrop-filter: blur(10px);
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 101;
    width: 44px;
    height: 44px;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    box-shadow: var(--shadow);
}

.hamburger-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.hamburger-btn:active {
    transform: scale(0.95);
}

.hamburger-line {
    width: 24px;
    height: 3px;
    background: var(--dark-color);
    margin: 3px 0;
    transition: var(--transition);
    border-radius: 2px;
    display: block;
}

.hamburger-btn.active .hamburger-line:nth-child(1) {
    transform: rotate(-45deg) translate(-6px, 6px);
    background: white;
}

.hamburger-btn.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.hamburger-btn.active .hamburger-line:nth-child(3) {
    transform: rotate(45deg) translate(-6px, -6px);
    background: white;
}

.nav-header {
    display: none;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
}

.nav-header h3 {
    color: var(--text-light);
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: var(--text-light);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1) rotate(90deg);
}

.nav-content {
    display: contents;
}

.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Mobile Hamburger Button */
.hamburger-btn {
    display: none;
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.hamburger-line {
    width: 24px;
    height: 3px;
    background: #2c3e50;
    margin: 3px 0;
    transition: all 0.3s ease;
    border-radius: 2px;
}

.hamburger-btn.active .hamburger-line:nth-child(1) {
    transform: rotate(-45deg) translate(-5px, 6px);
}

.hamburger-btn.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.hamburger-btn.active .hamburger-line:nth-child(3) {
    transform: rotate(45deg) translate(-5px, -6px);
}

/* ===== Finance Heading Section ===== */
.finance-heading {
    text-align: center;
    margin-top: clamp(2rem, 6vw, 4rem);
    padding: 0 1rem;
    animation: fadeIn 1s ease-in-out;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

/* Main Title */
.finance-title {
    font-size: clamp(1.6rem, 4vw, 3rem);
    font-weight: 700;

    background: linear-gradient(90deg, #0d1b2a, #1e3a8a, #2563eb);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 1.2px;
    display: inline-block;
    position: relative;
    animation: slideDown 1s ease-out;
    text-align: center;
    line-height: 1.3;
    word-break: break-word;
}

/* Underline below title */
.finance-title::after {
    content: "";
    display: block;
    width: clamp(50px, 10vw, 100px);
    height: 4px;
    background: #1e3a8a;
    margin: 0.7rem auto 0;
    border-radius: 2px;
    animation: growLine 1.2s ease-out;
}

/* Tagline */
.finance-tagline {
    font-size: clamp(1rem, 1.2rem + 0.5vw, 1.4rem);

    font-weight: 500;
    color: #555;
    margin-top: 0.8rem;
    animation: fadeInUp 1.4s ease-in-out;
    line-height: 1.6;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
    padding: 0 1rem;
    text-align: center;
    word-break: break-word;
}

/* Small hint message */
.menu-hint {
    display: none;
    color: #020a63;
    font-size: clamp(0.9rem, 1.5vw, 1rem);
    animation: pulse 1s infinite;
    margin-top: 2rem;
}

/* Category container */
.nav-category {
    position: relative;
    margin-bottom: 0.5rem;
}

/* Category button styled like nav-btn */
.category-btn {
    width: 100%;
    padding: 1rem 1.8rem;
    background: linear-gradient(135deg, rgba(149, 149, 149, 0.3), rgba(255, 255, 255, 0.2));
    border: none;
    border-radius: 17px;
    cursor: pointer;
    font-weight: 700;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    transition: all 0.4s ease;
    color: #000000c4;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.category-btn:hover {
    background: linear-gradient(135deg, rgba(149, 149, 149, 0.4), rgba(255, 255, 255, 0.3));
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* Submenu hidden state */
.submenu {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.4s ease, opacity 0.3s ease;
    padding-left: 1.5rem;
}

/* Submenu open state */
.submenu.open {
    max-height: 500px;
    opacity: 1;
}

/* Arrow rotation */
.category-btn .arrow {
    margin-left: auto;
    transition: transform 0.3s ease;
}

.category-btn.open .arrow {
    transform: rotate(180deg);
}

/* Submenu buttons */
.submenu .nav-btn {
    width: 100%;
    padding: 0.8rem 1.5rem;
    background: transparent;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    transition: all 0.3s ease;
    color: #2c3e50;
    margin: 0.2rem 0;
    text-align: left;
}

.submenu .nav-btn:hover {
    background: rgba(74, 108, 247, 0.1);
}

.submenu .nav-btn.active {
    background: rgba(74, 108, 247, 0.2);
    color: #3a7bd5;
    font-weight: 600;
}

.nav-icon {
    width: 20px;
    text-align: center;
}

/* Remove hover effect that conflicts with click */
.nav-category:hover .submenu:not(.open) {
    max-height: 0;
    opacity: 0;
}

.nav-category:hover .arrow:not(.open) {
    transform: rotate(0deg);
}

/* ===== MAIN LAYOUT ===== */
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem 2rem;
    flex: 1;
}

.calculator-section {
    display: none;
    background: rgb(255 255 255 / 0%);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: clamp(1.5rem, 3vw, 2.5rem);
    margin-bottom: 2rem;
    box-shadow: -17px -20px 20px 8px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 100%;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.calculator-section.active {
    display: block;
}

.calculator-section h2 {
    color: var(--dark-color);
    margin-bottom: 1.5rem;
    text-align: center;
    font-size: clamp(1.5rem, 4vw, 2rem);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
    position: relative;
    padding-bottom: 0.5rem;
}

.calculator-section h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    border-radius: 3px;
}

.calculator-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

/* ===== TOGGLE SWITCH ===== */
.toggle-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--dark-color);
    font-weight: 500;
    font-size: clamp(0.9rem, 2vw, 1rem);
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: clamp(50px, 8vw, 60px);
    height: clamp(25px, 4vw, 30px);
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.2);
    transition: var(--transition);
    border-radius: 30px;
}

.slider:before {
    position: absolute;
    content: "";
    height: calc(100% - 8px);
    aspect-ratio: 1;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: var(--transition);
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

input:checked+.slider {
    background-color: var(--success-color);
}

input:checked+.slider:before {
    transform: translateX(clamp(20px, 4vw, 30px));
}

/* ===== FIXED CALCULATOR LAYOUT STYLES ===== */
.calculator-wrapper {
    display: flex;
    justify-content: center;
    width: 100%;
    padding: 0 1rem;
}

.calculator {
    background: rgba(2, 48, 111, 0.72);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: 2rem;
    border: 1px solid rgb(0 0 0 / 25%);
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    box-sizing: border-box;
    transition: var(--transition);
    transform-style: preserve-3d;
    perspective: 1000px;
}

.calculator:hover {
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.15);
}

/* Display Screen */
.display {
    margin-bottom: 2rem;
    position: relative;
    transform: translateZ(20px);
}

.display-input {
    width: 100%;
    height: 100px;
    font-size: 2.5rem;
    text-align: right;
    padding: 0 1rem;
    border: none;
    border-radius: 16px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.8));
    color: #00ff88;
    box-shadow: inset 0 4px 25px rgba(0, 0, 0, 0.6), 0 5px 10px rgba(0, 0, 0, 0.2);
    font-weight: 800;
    letter-spacing: 1px;
    box-sizing: border-box;
    font-family: 'Courier New', monospace;
    transition: var(--transition);
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

.display-input:focus {
    outline: none;
    box-shadow: inset 0 4px 25px rgba(0, 0, 0, 0.6), 0 0 0 3px rgba(0, 255, 136, 0.4);
}

.display-history {
    position: absolute;
    top: 0.8rem;
    right: 1.5rem;
    font-size: 0.9rem;
    color: white;
    font-weight: 400;
}

/* Button Container */
.buttons-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
}

.buttons-container.advanced-container {
    gap: 0.8rem;
}

/* Button Rows */
.button-row {
    display: flex;
    gap: 0.8rem;
    flex-wrap: nowrap;
    flex-direction: row;
    justify-content: center;
}

.advanced-container .button-row {
    gap: 0.7rem;
}

/* Individual Button Styles */
.calc-btn {
    flex: 1;
    height: 70px;
    font-size: 1.4rem;
    border: none;
    border-radius: 18px;
    cursor: pointer;
    transition: all 0.2s ease, transform 0.1s ease;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(5px);
    user-select: none;
    touch-action: manipulation;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    transform: translateZ(0);
}

.calc-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(rgba(255, 255, 255, 0.2), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.calc-btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.1);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.calc-btn:hover::before {
    opacity: 1;
}

.calc-btn:hover::after {
    opacity: 1;
}

.calc-btn:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.25);
}

.calc-btn:active {
    transform: translateY(2px) scale(0.98);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

/* Number Buttons */
.calc-btn.number-btn {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(240, 245, 250, 0.95) 100%);
    color: var(--dark-color);
    font-weight: 700;
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15);
}

.calc-btn.number-btn:hover {
    background: linear-gradient(135deg, rgba(255, 255, 255, 1) 0%, rgba(250, 255, 255, 1) 100%);
    color: #1a252f;
}

/* Zero Button (wider in basic mode) */
.calc-btn.zero-btn {
    flex: 2;
}

.calc-btn.zero-btn-advanced {
    flex: 1;
}

/* Operator Buttons */
.calc-btn.operator-btn {
    background: linear-gradient(135deg, var(--accent-color) 0%, #ee5a52 100%);
    color: white;
    font-size: 1.5rem;
    font-weight: 700;
    border: 1px solid rgba(255, 107, 107, 0.4);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3);
}

.calc-btn.operator-btn:hover {
    background: linear-gradient(135deg, #ee5a52 0%, #e74c3c 100%);
}

/* Equals Button */
.calc-btn.equals-btn {
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--primary-color) 100%);
    color: white;
    font-size: 1.7rem;
    font-weight: 700;
    border: 1px solid rgba(0, 210, 255, 0.4);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3);
}

.calc-btn.equals-btn:hover {
    background: linear-gradient(135deg, var(--primary-color) 0%, #2980b9 100%);
}

/* Clear Buttons */
.calc-btn.clear-btn {
    background: linear-gradient(135deg, var(--warning-color) 0%, #ff9f43 100%);
    color: white;
    font-weight: 700;
    border: 1px solid rgba(254, 202, 87, 0.4);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3);
}

.calc-btn.clear-btn:hover {
    background: linear-gradient(135deg, #ff9f43 0%, #f39c12 100%);
}

/* Scientific Function Buttons */
.calc-btn.scientific-btn {
    background: linear-gradient(135deg, #a55eea 0%, #8b5cf6 100%);
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    border: 1px solid rgba(165, 94, 234, 0.4);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3);
}

.calc-btn.scientific-btn:hover {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
}

/* Memory Buttons */
.calc-btn.memory-btn {
    background: linear-gradient(135deg, #fd79a8 0%, #e84393 100%);
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    border: 1px solid rgba(253, 121, 168, 0.4);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3);
}

.calc-btn.memory-btn:hover {
    background: linear-gradient(135deg, #e84393 0%, #d63031 100%);
}

/* Calculator header */
.calculator-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    color: white;
}

.calculator-header h2 {
    font-size: 1.8rem;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Toggle switch */
.toggle-container {
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgb(0, 0, 0);
    font-weight: 500;
}

.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 30px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    transition: .4s;
    border-radius: 34px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background: linear-gradient(135deg, var(--accent-color) 0%, #ee5a52 100%);
}

input:checked+.slider:before {
    transform: translateX(30px);
}

/* Animation for button press */
@keyframes buttonPress {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(0.95);
    }

    100% {
        transform: scale(1);
    }
}

.button-press {
    animation: buttonPress 0.2s ease;
}

/* Floating animation */
@keyframes float {
    0% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-10px);
    }

    100% {
        transform: translateY(0px);
    }
}



/* Animation for calculator buttons */
@keyframes buttonPress {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(0.95);
    }

    100% {
        transform: scale(1);
    }
}

.calc-btn:active {
    animation: buttonPress 0.2s ease;
}

/* Improved focus styles for accessibility */
.calc-btn:focus-visible,
.nav-btn:focus-visible,
.toggle-switch:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .calculator {
        border: 2px solid var(--dark-color);
    }

    .calc-btn {
        border: 1px solid var(--dark-color);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Touch device improvements */
@media (hover: none) {
    .calc-btn:hover {
        transform: none;
    }

    .calc-btn:active {
        transform: scale(0.95);
        transition: transform 0.1s ease;
    }

    .nav-btn:hover {
        transform: none;
        background: rgba(255, 255, 255, 0.05) !important;
    }
}

/* Focus states for accessibility */
.calc-btn:focus-visible,
.nav-btn:focus-visible,
.toggle-switch:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Button press animation */
@keyframes buttonPress {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(0.95);
    }

    100% {
        transform: scale(1);
    }
}

.calc-btn:active {
    animation: buttonPress 0.1s ease;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .calculator-nav {
        transition: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .calculator {
        border: 2px solid var(--dark-color);
    }

    .calc-btn {
        border: 1px solid var(--dark-color);
    }

    .nav-btn {
        border: 1px solid white;
    }
}

/* Print styles */
@media print {

    .calculator-nav-container,
    .hamburger-btn,
    .toggle-container,
    button {
        display: none !important;
    }

    .calculator-section {
        background: white !important;
        backdrop-filter: none !important;
        box-shadow: none !important;
        border: 1px solid #ccc !important;
        page-break-inside: avoid;
    }

    .calculator {
        box-shadow: none !important;
        border: 1px solid #999 !important;
    }
}


/* Fix for scientific buttons wrapping */
.advanced-container .button-row {
    flex-wrap: nowrap;
    overflow-x: visible;
}

/* Ensure calculator doesn't overflow on mobile */
.calculator-wrapper {
    max-width: 100%;
    overflow: hidden;
}

/* Preloader overlay */
.preloaderBg {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: linear-gradient(135deg, #439af6, #8fb4da);
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.8s ease, visibility 0.8s ease;
    overflow: hidden;
}

/* Loader wrapper */
.loader {
    width: clamp(100px, 30vw, 200px);
    height: clamp(100px, 30vw, 200px);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* Logo (centered inside loader) */
.preloader {
    background: url("https://test2.calcapp.in/logo/logo.png") no-repeat center;
    background-size: contain;
    width: 60%;
    height: 60%;
    position: absolute;
    animation: pulse 1s ease-in-out infinite;
}

/* Spinner (circle around logo) */
.preloader2 {
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-top: 5px solid #000;
    border-radius: 50%;
    width: 100%;
    height: 100%;
    animation: spin 1s linear infinite;
    position: absolute;
}

/* Spin animation */
@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Pulse animation for logo */
@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

/* Hidden state (fade out) */
.preloaderBg.hide {
    opacity: 0;
    visibility: hidden;
}

/* ===== RESPONSIVE MEDIA QUERIES ===== */

/* Mobile navigation styles */
@media (max-width: 768px) {
    .calculator-nav {
        flex-direction: column;
        position: fixed;
        top: 0;
        right: -100%;
        width: 280px;
        height: 100vh;
        z-index: 100;
        margin: 0;
        border-radius: 0;
        padding: 5rem 0 2rem 0;
        justify-content: flex-start;
        gap: 0;
        transition: right 0.4s cubic-bezier(0.23, 1, 0.32, 1);
        box-shadow: -5px 0 25px rgba(0, 0, 0, 0.3);
        overflow-y: auto;
        height: 100%;
        background: linear-gradient(135deg, #3c4a59, #34495e);
        backdrop-filter: blur(20px);
        display: flex;
        flex-direction: column;
    }

    .menu-hint {
        display: block;
    }

    .calculator-nav.active {
        right: 0;
    }

    .nav-header {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 102;
        border-radius: 0;
        background: rgba(52, 73, 94, 0.95);
        padding: 1rem 1.5rem;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    }

    .nav-header h3 {
        color: var(--text-light);
        margin: 0;
        font-size: 1.3rem;
        font-weight: 600;
    }

    .close-btn {
        background: rgba(255, 255, 255, 0.2);
        border: none;
        color: var(--text-light);
        font-size: 1.5rem;
        cursor: pointer;
        padding: 0.5rem;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        transition: var(--transition);
    }

    .close-btn:hover {
        background: rgba(255, 255, 255, 0.3);
        transform: rotate(90deg);
    }

    .nav-content {
        display: flex;
        flex-direction: column;
        width: 100%;
        padding: 0;
        gap: 0;
    }

    .nav-btn {
        width: 100%;
        justify-content: flex-start;
        padding: 1.2rem 1.8rem;
        border-radius: 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        background: transparent !important;
        margin: 0;
        font-size: 1.1rem;
        color: var(--text-light);
        box-shadow: none;
        min-width: auto;
        transition: all 0.3s ease;
        position: relative;
        overflow: hidden;
        opacity: 1;
        animation: slideInRight 0.5s ease forwards;
    }

    .category-btn {
        width: 100%;
        background: none;
        border: none;
        color: white;
        font-size: 1rem;
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 15px;
        cursor: pointer;
        transition: all 0.3s ease;
    }

    .calculator-nav.active .nav-btn:nth-child(1) {
        animation-delay: 0.1s;
    }

    .calculator-nav.active .nav-btn:nth-child(2) {
        animation-delay: 0.15s;
    }

    .calculator-nav.active .nav-btn:nth-child(3) {
        animation-delay: 0.2s;
    }

    .calculator-nav.active .nav-btn:nth-child(4) {
        animation-delay: 0.25s;
    }

    .calculator-nav.active .nav-btn:nth-child(5) {
        animation-delay: 0.3s;
    }

    .calculator-nav.active .nav-btn:nth-child(6) {
        animation-delay: 0.35s;
    }

    @keyframes slideInRight {
        from {
            opacity: 0;
            transform: translateX(30px);
        }

        to {
            opacity: 1;
            transform: translateX(0);
        }
    }

    .nav-btn::before {
        content: '';
        position: absolute;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100%;
        background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
        transition: left 0.7s ease;
    }

    .nav-btn:hover::before {
        left: 100%;
    }

    .nav-btn:hover {
        background: none;
        border: none;
        text-align: left;
        color: #ddd;
        padding: 12px 20px 12px 50px;
        cursor: pointer;
        font-size: 0.9rem;
        transition: all 0.2s ease;
        display: flex;
        align-items: center;
        width: 100%;
    }

    .nav-btn.active {
        background: rgba(255, 255, 255, 0.15) !important;
        box-shadow: inset 4px 0 0 var(--primary-color);
        color: var(--text-light);
        animation: none;
    }

    .nav-icon {
        font-size: 1.2rem;
        width: 25px;
        text-align: center;
        color: var(--text-light);
    }

    .nav-text {
        font-size: 1rem;
        color: var(--text-light);
    }

    /* Mobile overlay background */
    .mobile-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        background: rgba(0, 0, 0, 0.7);
        z-index: 99;
        opacity: 0;
        transition: opacity 0.3s ease;
        backdrop-filter: blur(5px);
    }

    .mobile-overlay.active {
        display: block;
        opacity: 1;
    }

    /* Hamburger button adjustments */
    .hamburger-btn {
        display: flex;
        position: absolute;
        top: 1.2rem;
        right: 1.2rem;
        z-index: 101;
        background: rgba(52, 73, 94, 0.9);
        border: 1px solid rgba(255, 255, 255, 0.2);
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    }

    .hamburger-btn:hover {
        background: rgba(52, 73, 94, 1);
        transform: scale(1.05);
    }

    .hamburger-line {
        background: var(--text-light);
    }

    .calculator {
        padding: 1.5rem;
        border-radius: 20px;
        max-width: 90%;
    }

    .display-input {
        font-size: 1.8rem;
        height: 70px;
        padding: 0 1rem;
    }

    .button-row {
        gap: 0.6rem;
    }

    .calc-btn {
        height: 55px;
        font-size: 1.05rem;
    }

    .calc-btn.operator-btn {
        font-size: 1.2rem;
    }

    .calc-btn.equals-btn {
        font-size: 1.4rem;
    }

    .header-brand {
        flex-direction: column;
        gap: 0.5rem;
    }

    .logo,
    .logo-inline,
    .logo-center {
        height: 85px;
        max-width: 200px;
    }

    .brand-title {
        font-size: 1.6rem;
        text-align: center;
    }

    .finance-title {
        line-height: 1.4;
        font-size: 1.2rem;
    }



    .calculator-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

}

/* Small mobile devices (480px and below) */
@media (max-width: 480px) {

    .calculator-nav {
        width: 280px;
        right: -280px;
        padding: 78px 5px 1px 10px;
    }

    .nav-btn {
        padding: 1.1rem 1.5rem;
        font-size: 1rem;
    }

    .nav-icon {
        font-size: 1.1rem;
        width: 22px;
    }

    .nav-text {
        font-size: 0.9rem;
        color: var(--text-light);
    }

    .hamburger-btn {
        top: 1rem;
        right: 1rem;
        width: 42px;
        height: 42px;
    }

    header {
        padding: 1.2rem 0.5rem;
        display: none;
    }

    header h1 {
        font-size: 1.7rem;
    }

    header p {
        font-size: 0.95rem;
    }

    .calculator {
        padding: 1rem;
        border-radius: 16px;
    }

    .display-input {
        height: 60px;
        font-size: 1.6rem;
        padding: 0 0.8rem;
    }

    .buttons-container {
        gap: 0.5rem;
    }

    .button-row {
        gap: 0.5rem;
    }

    .calc-btn {
        height: 48px;
        font-size: 0.95rem;
        border-radius: 10px;
        min-width: 0;
        flex: 1 1 20%;
    }

    .category-btn {
        padding: 12px;
    }

    .calc-btn.scientific-btn,
    .calc-btn.memory-btn {
        font-size: 0.8rem;
        padding: 0.3rem;
    }

    .calc-btn.equals-btn {
        font-size: 1.2rem;
    }

    .calc-btn.operator-btn {
        font-size: 1.1rem;
    }

    .calc-btn.zero-btn {
        flex: 1 1 42%;
    }

    .calc-btn.zero-btn-advanced {
        flex: 1;
    }

    .display-history {
        font-size: 0.8rem;
        top: 0.5rem;
        right: 0.8rem;
    }

    .calculator-section {
        padding: 1rem;
        border-radius: 14px;
    }

    .calculator-section h2 {
        font-size: 1.4rem;
        margin-top: 2rem;
    }

    .calculator-nav {
        width: 280px;
        right: -280px;
        padding: 78px 5px 1px 10px;
    }

    .logo,
    .logo-inline,
    .logo-center {
        height: 65px;
        max-width: 180px;
    }

    /* Footer adjustments */
    footer {
        padding: 14px 8px;
        font-size: 12px;
        line-height: 1.4;
    }

    main {
        max-width: 1200px;
        margin: 0 auto;
        padding: 0px 5px 2rem;
        flex: 1;
    }

    .finance-tagline {
        font-size: 0.75rem;
    }

    .category-btn:hover {
        background: rgba(255, 255, 255, 0.1);
    }
}

/* Medium-large screens (1024px to 1199px) */
@media (max-width: 1199px) {
    .calculator {
        max-width: 380px;
    }

    .display-input {
        font-size: 2.1rem;
    }
}

/* Tablets and small laptops (768px to 1023px) */
@media (max-width: 1023px) {
    .calculator-nav {
        max-width: 90%;
        gap: 0.8rem;
    }

    .nav-btn {
        padding: 0.7rem 1.3rem;
        font-size: 0.92rem;
    }

    .logo {
        height: 100px;
    }
}

/* Medium mobile devices (481px to 767px) */
@media (max-width: 767px) {
    .calculator-wrapper {
        padding: 0 0.5rem;
    }

    .calculator {
        max-width: 100%;
        padding: 1.2rem;
    }

    .display-input {
        height: 65px;
        font-size: 1.7rem;
    }

    .buttons-container {
        gap: 0.6rem;
    }

    .calc-btn {
        height: 52px;
        font-size: 1rem;
        border-radius: 12px;
    }

    .calc-btn.scientific-btn,
    .calc-btn.memory-btn {
        font-size: 0.85rem;
    }

    .logo,
    .logo-inline,
    .logo-center {
        height: 75px;
    }
}

/* Very small mobile devices (400px and below) */
@media (max-width: 400px) {
    .button-row {
        flex-wrap: wrap;
        gap: 0.4rem;
    }

    .calc-btn {
        flex: 1 1 20%;
        min-width: 45px;
        height: 45px;
        font-size: 0.9rem;
    }

    .calc-btn.zero-btn,
    .calc-btn.zero-btn-advanced {
        flex: 1 1 42%;
    }

    .buttons-container.advanced-container {
        gap: 0.4rem;
    }

    .calculator-nav {
        width: 280px;
        right: -280px;
        padding: 78px 5px 1px 10px;
    }

    .nav-btn {
        padding: 0.8rem 1rem !important;
    }

    .logo,
    .logo-inline,
    .logo-center {
        height: 60px;
        max-width: 160px;
    }

    header h1 {
        font-size: 1.6rem;
    }

    .hamburger-btn {
        top: 1rem;
        right: 1rem;
        width: 42px;
        height: 42px;
        position: fixed;
    }
}

/* Ultra-small devices (300px and below) */
@media (max-width: 300px) {
    .button-row {
        gap: 0.3rem;
    }

    .buttons-container.advanced-container {
        gap: 0.3rem;
    }

    .calc-btn {
        flex: 1 1 20%;
        min-width: 40px;
        height: 40px;
        font-size: 0.8rem;
        border-radius: 8px;
    }

    .calc-btn.zero-btn,
    .calc-btn.zero-btn-advanced {
        flex: 1 1 42%;
    }

    .calculator {
        padding: 0.8rem;
    }

    .display-input {
        height: 73px;
        font-size: 2rem;
        padding: 0px 0.7rem;
    }

    .nav-btn {
        padding: 0.7rem 0.9rem !important;
        font-size: 0.85rem !important;
    }

    .logo,
    .logo-inline,
    .logo-center {
        height: 50px;
        max-width: 140px;
    }

    header h1 {
        font-size: 1.4rem;
    }

    header p {
        font-size: 0.85rem;
    }

}

/* Landscape orientation for mobile devices */
@media (max-width: 767px) and (orientation: landscape) {
    .calculator {
        max-width: 500px;
        padding: 1rem;
    }

    .calc-btn {
        height: 45px;
        font-size: 0.9rem;
    }

    .display-input {
        height: 55px;
        font-size: 1.5rem;
    }

    .buttons-container {
        gap: 0.4rem;
    }

    .button-row {
        gap: 0.4rem;
    }

    .calculator-nav {
        width: 60% !important;
    }
}

/* ===== ADVANCED CALCULATOR MOBILE FIX ===== */

/* General mobile improvements */
@media (max-width: 768px) {
    .calculator.advanced {
        max-width: 100%;
        padding: 1rem;
        margin: 0.5rem;
        overflow: hidden;
    }

    .advanced-container {
        gap: 0.5rem !important;
    }

    .advanced-container .button-row {
        gap: 0.4rem !important;
        margin-bottom: 0.4rem;
    }

    .calc-btn {
        height: 50px;
        font-size: 1rem;
        border-radius: 12px;
        min-width: 0;
        flex: 1;
        padding: 0.3rem;
    }

    .calc-btn.scientific-btn,
    .calc-btn.memory-btn {
        font-size: 0.85rem;
        padding: 0.2rem;
    }

    /* Scientific buttons grid layout for mobile */
    .scientific-buttons {
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        gap: 0.4rem;
        margin-top: 0.5rem;
    }

    /* Make display more compact */
    .display {
        margin-bottom: 1.2rem;
    }

    .display-input {
        height: 65px;
        font-size: 1.7rem;
        padding: 0 1rem;
    }
}

/* Small mobile devices (480px and below) */
@media (max-width: 480px) {
    .calculator.advanced {
        padding: 0.8rem;
        border-radius: 16px;
    }

    .advanced-container {
        gap: 0.4rem !important;
    }

    .advanced-container .button-row {
        gap: 0.3rem !important;
        margin-bottom: 0.3rem;
    }

    .calc-btn {
        height: 45px;
        font-size: 0.9rem;
        border-radius: 10px;
    }

    .calc-btn.scientific-btn,
    .calc-btn.memory-btn {
        font-size: 0.75rem;
        padding: 0.1rem;
    }

    .scientific-buttons {
        grid-template-columns: repeat(5, 1fr);
        gap: 0.3rem;
    }

    .display-input {
        height: 73px;
        font-size: 2rem;
        padding: 0px 0.7rem;
    }

    /* Adjust operator buttons */
    .calc-btn.operator-btn {
        font-size: 1rem;
    }

    .calc-btn.equals-btn {
        font-size: 1.1rem;
    }

    .toggle-container {
        flex-direction: row;
        align-items: flex-start;
        gap: 1.5rem;
    }

    .calculator-section {
        padding: 0rem;
        border-radius: 14px;
    }

    .hamburger-btn {
        top: -6rem;
        right: 1rem;
        width: 43px;
        height: 45px;
        position: absolute;
    }

    .buttons-container {
        gap: 1.5rem;
    }
}

/* Very small devices (360px and below) */
@media (max-width: 360px) {
    .calculator.advanced {
        padding: 0.6rem;
    }

    .calc-btn {
        height: 40px;
        font-size: 0.85rem;
        border-radius: 8px;
    }

    .calc-btn.scientific-btn,
    .calc-btn.memory-btn {
        font-size: 0.7rem;
    }

    .scientific-buttons {
        grid-template-columns: repeat(5, 1fr);
        gap: 0.25rem;
    }

    .display-input {
        height: 83px;
        font-size: 2rem;
        padding: 0px 0.7rem;
        font-weight: 900;
    }

    /* Two-line layout for scientific functions */
    .scientific-row {
        display: flex;
        flex-direction: column;
        gap: 0.3rem;
    }

    .scientific-group {
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        gap: 0.3rem;
    }
}

/* Landscape orientation fixes */
@media (max-width: 768px) and (orientation: landscape) {
    .calculator.advanced {
        max-width: 90%;
        margin: 0.5rem auto;
    }

    .advanced-container {
        display: grid;
        grid-template-columns: 3fr 2fr;
        gap: 0.8rem;
    }

    .basic-buttons {
        grid-column: 1;
    }

    .scientific-buttons {
        grid-column: 2;
        grid-row: 1;
        margin-top: 0;
    }

    .calc-btn {
        height: 35px;
        font-size: 0.9rem;
    }

    .display-input {
        height: 50px;
        font-size: 1.5rem;
    }
}

/* Button text size adjustments for very small text */
@media (max-width: 300px) {
    .calc-btn {
        font-size: 0.75rem;
    }

    .calc-btn.scientific-btn {
        font-size: 0.65rem;
    }

    .calc-btn.operator-btn {
        font-size: 0.9rem;
    }
}


/* Improve touch targets for mobile */
@media (max-width: 768px) {
    .calc-btn {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* Adjust font weights for better readability on small screens */
@media (max-width: 480px) {
    .calc-btn {
        font-weight: 600;
    }

    .calc-btn.scientific-btn {
        font-weight: 500;
    }
}

/* Add active states for better touch feedback */
@media (max-width: 768px) {
    .calc-btn:active {
        transform: scale(0.95);
        opacity: 0.9;
    }

    .calc-btn.zero-btn,
    .calc-btn.zero-btn-advanced {
        flex: 1 1 4%;
    }
}








/* ===== RESPONSIVE NAVIGATION STYLES ===== */

/* Mobile navigation styles (768px and below) */
@media (max-width: 768px) {
    .calculator-nav-container {
        position: relative;
        margin-bottom: 1rem;
        background-image: none;
    }

    /* Hide desktop navigation */
    .calculator-nav {
        display: none;
        flex-direction: column;
        position: fixed;
        top: 0;
        right: -100%;
        width: 280px;
        height: 100vh;
        z-index: 1000;
        margin: 0;
        border-radius: 0;
        padding: 4rem 6px 2rem 8px;
        justify-content: flex-start;
        gap: 0;
        transition: right 0.4s cubic-bezier(0.23, 1, 0.32, 1);
        box-shadow: -5px 0 25px rgba(0, 0, 0, 0.3);
        overflow-y: auto;
        background: linear-gradient(135deg, #2c3e50, #2f4254);
        backdrop-filter: blur(20px);
    }

    .calculator-nav.active {
        display: flex;
        right: 0;

        right: 0;
        height: 107vh;
    }


    /* Mobile navigation header */
    .nav-header {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1001;
        background: rgba(44, 62, 80, 0.95);
        padding: 1rem 1.5rem;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
        justify-content: space-between;
        align-items: center;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .nav-header h3 {
        color: var(--text-light);
        margin: 0;
        font-size: 1.2rem;
        font-weight: 600;
    }

    .close-btn {
        background: rgba(255, 255, 255, 0.15);
        border: none;
        color: var(--text-light);
        font-size: 1.5rem;
        cursor: pointer;
        padding: 0.5rem;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        transition: all 0.3s ease;
    }

    .close-btn:hover {
        background: rgba(255, 255, 255, 0.25);
        transform: rotate(90deg);
    }

    /* Navigation content */
    .nav-content {
        display: flex;
        flex-direction: column;
        width: 100%;
        padding: 0;
        gap: 0;
        margin-top: 1rem;
    }

    /* Navigation buttons */
    .nav-btn {
        width: 100%;
        justify-content: flex-start;
        padding: 1.2rem 1.8rem;
        border-radius: 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        background: transparent;
        margin: 0;
        font-size: 1rem;
        color: var(--text-light);
        box-shadow: none;
        min-width: auto;
        transition: all 0.3s ease;
        position: relative;
        overflow: hidden;
        opacity: 0;
        animation: slideInRight 0.5s ease forwards;
        text-decoration: none;
        display: flex;
        align-items: center;
        gap: 0.8rem;
        border: none;
        cursor: pointer;
    }

    .calculator-nav.active .nav-btn {
        opacity: 1;
    }

    /* Staggered animation for nav items */
    .calculator-nav.active .nav-btn:nth-child(1) {
        animation-delay: 0.1s;
    }

    .calculator-nav.active .nav-btn:nth-child(2) {
        animation-delay: 0.15s;
    }

    .calculator-nav.active .nav-btn:nth-child(3) {
        animation-delay: 0.2s;
    }

    .calculator-nav.active .nav-btn:nth-child(4) {
        animation-delay: 0.25s;
    }

    .calculator-nav.active .nav-btn:nth-child(5) {
        animation-delay: 0.3s;
    }

    .calculator-nav.active .nav-btn:nth-child(6) {
        animation-delay: 0.35s;
    }

    @keyframes slideInRight {
        from {
            opacity: 0;
            transform: translateX(30px);
        }

        to {
            opacity: 1;
            transform: translateX(0);
        }
    }

    /* Hover effects */
    .nav-btn::before {
        content: '';
        position: absolute;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100%;
        background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
        transition: left 0.6s ease;
    }

    .nav-btn:hover::before {
        left: 100%;
    }

    .nav-btn:hover {
        background: rgba(255, 255, 255, 0.1) !important;
        color: #fff;
        padding-left: 2.2rem;
    }

    .nav-btn.active {
        background: rgba(255, 255, 255, 0.15) !important;
        box-shadow: inset 4px 0 0 var(--primary-color);
        color: var(--text-light);
        font-weight: 600;
    }

    /* Navigation icons */
    .nav-icon {
        font-size: 1.1rem;
        width: 24px;
        text-align: center;
        color: var(--text-light);
        transition: transform 0.3s ease;
    }

    .nav-btn:hover .nav-icon {
        transform: scale(1.2);
    }

    .nav-text {
        font-size: 0.95rem;
        color: var(--text-light);
        transition: letter-spacing 0.3s ease;
    }

    .nav-btn:hover .nav-text {
        letter-spacing: 0.5px;
    }

    /* Mobile overlay background */
    .mobile-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.6);
        z-index: 999;
        opacity: 0;
        transition: opacity 0.3s ease;
        backdrop-filter: blur(3px);
    }

    .mobile-overlay.active {
        display: block;
        opacity: 1;
    }

    /* Hamburger button */
    .hamburger-btn {
        display: flex;
        position: absolute;

        top: -8.8rem;
        right: 1.2rem;
        z-index: 1002;
        background: rgba(44, 62, 80, 0.9);
        border: 1px solid rgba(255, 255, 255, 0.2);
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
        width: 48px;
        height: 48px;
        border-radius: 50%;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        cursor: pointer;
        transition: all 0.3s ease;
    }

    .hamburger-btn:hover {
        background: rgba(44, 62, 80, 1);
        transform: scale(1.05);
    }

    .hamburger-line {
        background: var(--text-light);
        width: 22px;
        height: 2px;
        margin: 3px 0;
        transition: all 0.3s ease;
        border-radius: 1px;
    }

    .hamburger-btn.active .hamburger-line:nth-child(1) {
        transform: rotate(-45deg) translate(-5px, 6px);
    }

    .hamburger-btn.active .hamburger-line:nth-child(2) {
        opacity: 0;
    }

    .hamburger-btn.active .hamburger-line:nth-child(3) {
        transform: rotate(45deg) translate(-5px, -6px);
    }

    /* Category navigation */
    .nav-category {
        width: 100%;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .category-btn {
        width: 100%;
        background: rgba(255, 255, 255, 0.05);
        border: none;
        color: white;
        font-size: 1rem;
        font-weight: 600;
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 1.2rem 1.8rem;
        cursor: pointer;
        transition: all 0.3s ease;
    }

    .category-btn:hover {
        background: rgba(255, 255, 255, 0.1);
    }

    .category-btn .arrow {
        transition: transform 0.3s ease;
        font-size: 0.9rem;
    }

    .category-btn.open .arrow {
        transform: rotate(180deg);
    }

    .submenu {
        max-height: 0;
        border-radius: 1rem;
        overflow: hidden;
        transition: max-height 0.4s ease;
        background: rgb(0 0 0 / 17%);
    }

    .submenu.open {
        max-height: 500px;
    }

    .submenu .nav-btn {
        padding-left: 2.8rem;
        font-size: 0.9rem;
        background: rgba(0, 0, 0, 0.1);
    }

    .submenu .nav-btn:hover {
        background: rgba(255, 255, 255, 0.05) !important;
        padding-left: 3rem;
    }
}

/* Small mobile devices (480px and below) */
@media (max-width: 480px) {
    .calculator-nav {
        width: 100%;
        right: -100%;
    }

    .nav-btn {
        padding: 1.1rem 1.5rem;
        font-size: 0.95rem;
    }

    .nav-icon {
        font-size: 1rem;
        width: 22px;
    }

    .nav-text {
        font-size: 0.9rem;
    }

    .hamburger-btn {
        top: -6.2rem;
        right: 0.8rem;
        width: 42px;
        height: 42px;
    }

    .nav-header {
        padding: 0.9rem 1.2rem;
    }

    .nav-header h3 {
        font-size: 1.1rem;
    }

    .close-btn {
        width: 36px;
        height: 36px;
        font-size: 1.3rem;
    }

    .category-btn {
        padding: 1.1rem 1.5rem;
        font-size: 0.95rem;
    }

    .submenu .nav-btn {
        padding-left: 2.5rem;
    }
}

/* Very small mobile devices (400px and below) */
@media (max-width: 400px) {
    .nav-btn {
        padding: 1rem 1.2rem;
        font-size: 0.9rem;
    }

    .hamburger-btn {
        top: -6.2rem;
        right: 0.8rem;
        width: 42px;
        height: 42px;
    }

    .nav-header {
        padding: 0.8rem 1rem;
    }

    .nav-header h3 {
        font-size: 1rem;
    }

    .category-btn {
        padding: 1rem 1.2rem;
        font-size: 0.9rem;
    }

    .submenu .nav-btn {
        padding-left: 2.2rem;
        font-size: 0.85rem;
    }
}

/* Ultra-small devices (300px and below) */
@media (max-width: 300px) {
    .nav-btn {
        padding: 0.9rem 1rem;
        font-size: 0.85rem;
    }

    .nav-icon {
        font-size: 0.9rem;
        width: 20px;
    }

    .hamburger-btn {
        width: 40px;
        height: 40px;
    }

    .hamburger-line {
        width: 18px;
    }

    .category-btn {
        padding: 0.9rem 1rem;
        font-size: 0.85rem;
    }

    .submenu .nav-btn {
        padding-left: 2rem;
    }
}

/* Landscape orientation for mobile devices */
@media (max-width: 767px) and (orientation: landscape) {
    .calculator-nav {
        width: 60%;
        padding-top: 3.5rem;
    }

    .nav-btn {
        padding: 0.9rem 1.5rem;
    }

    .nav-header {
        padding: 0.8rem 1.5rem;
    }
}

/* Tablets and small laptops (768px to 1023px) - Show desktop nav */
@media (min-width: 769px) and (max-width: 1023px) {
    .calculator-nav {
        display: flex;
        position: static;
        width: auto;
        height: auto;
        flex-direction: row;
        padding: 1.2rem;
        max-width: 95%;
        margin: 0 auto 2rem;
        border-radius: 20px;

        background: linear-gradient(135deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.15));
        backdrop-filter: blur(20px);
    }

    .hamburger-btn,
    .mobile-overlay,
    .nav-header,
    .menu-hint {
        display: none;
    }

    .nav-btn {
        opacity: 1;
        animation: none;
        padding: 0.9rem 1.5rem;
        font-size: 0.95rem;
        border-radius: 50px;
        background: linear-gradient(135deg, rgba(149, 149, 149, 0.3), rgba(255, 255, 255, 0.2));
        border-bottom: none;
        width: auto;
    }
}

/* Desktop (1024px and above) - Show desktop nav */
@media (min-width: 1024px) {
    .calculator-nav {
        display: flex;
    }

    .hamburger-btn,
    .mobile-overlay,
    .nav-header,
    .menu-hint {
        display: none;
    }
}

/* Prevent body scroll when mobile nav is open */
@media (max-width: 768px) {
    body.nav-open {
        overflow: hidden;
    }

    .calculator-nav.active~* {
        pointer-events: none;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {

    .calculator-nav,
    .nav-btn,
    .hamburger-btn,
    .close-btn,
    .category-btn {
        transition-duration: 0.1s;
        animation: none;
    }

    .nav-btn {
        animation: none;
        opacity: 1;
    }

    @keyframes slideInRight {
        from {
            opacity: 1;
            transform: translateX(0);
        }

        to {
            opacity: 1;
            transform: translateX(0);
        }
    }
}

/* High DPI screens */
@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {

    .nav-btn,
    .category-btn,
    .hamburger-btn {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* Focus styles for accessibility */
@media (max-width: 768px) {

    .nav-btn:focus,
    .category-btn:focus,
    .hamburger-btn:focus,
    .close-btn:focus {
        outline: 2px solid rgba(255, 255, 255, 0.5);
        outline-offset: 2px;
    }
}