/* ============================================
   Online Calculator - Global Styles
   ============================================ */

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(-45deg, #2c3e50, #34495e, #3c5aa6, #2c3e50);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Animations */
@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

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

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes glow {
    0% { box-shadow: 0 0 20px rgba(52, 152, 219, 0.3); }
    50% { box-shadow: 0 0 30px rgba(52, 152, 219, 0.6); }
    100% { box-shadow: 0 0 20px rgba(52, 152, 219, 0.3); }
}

@keyframes buttonPress {
    0% { transform: scale(1); }
    50% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

@keyframes shimmer {
    0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
    100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    min-height: 100vh;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    animation: fadeInUp 1s ease-out;
}

/* ============================================
   Header & Navigation
   ============================================ */
header {
    background: linear-gradient(45deg, #2c3e50, #34495e, #2c3e50);
    background-size: 200% 200%;
    animation: gradientShift 10s ease infinite;
    color: white;
    padding: 1rem 0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: visible;
}

header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transform: rotate(45deg);
    animation: shimmer 3s infinite;
    pointer-events: none;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    position: relative;
    z-index: 10;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.logo {
    font-size: 1.8rem;
    font-weight: bold;
    color: #ecf0f1;
    animation: slideInLeft 1s ease-out;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo:hover {
    color: #fff;
}

.logo img {
    vertical-align: middle;
}

/* Hamburger Menu */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    z-index: 1001;
}

.menu-toggle span {
    display: block;
    width: 25px;
    height: 3px;
    background: #ecf0f1;
    margin: 5px 0;
    transition: all 0.3s ease;
    border-radius: 2px;
}

.menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
}

/* Main Navigation */
nav {
    animation: fadeInUp 1s ease-out 0.3s both;
}

nav > ul {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

nav > ul > li {
    position: relative;
}

nav > ul > li > a,
nav > ul > li > .dropdown-toggle {
    color: #ecf0f1;
    text-decoration: none;
    padding: 0.6rem 1.2rem;
    border-radius: 25px;
    transition: all 0.3s ease;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    cursor: pointer;
    background: transparent;
    border: none;
    font-size: 1rem;
    font-family: inherit;
}

nav > ul > li > a:hover,
nav > ul > li > .dropdown-toggle:hover,
nav > ul > li > a.active,
nav > ul > li.active > .dropdown-toggle {
    background: linear-gradient(45deg, #3498db, #2980b9);
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 25px rgba(52, 152, 219, 0.4);
}

.dropdown-arrow {
    font-size: 0.7rem;
    transition: transform 0.3s ease;
}

nav > ul > li:hover .dropdown-arrow,
nav > ul > li.open .dropdown-arrow {
    transform: rotate(180deg);
}

/* Dropdown Menu */
.dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    border-radius: 15px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2);
    min-width: 280px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s ease;
    z-index: 1000;
    overflow: hidden;
    margin-top: 0.5rem;
}

nav > ul > li:hover .dropdown,
nav > ul > li.open .dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 30px;
    width: 16px;
    height: 16px;
    background: white;
    transform: rotate(45deg);
    box-shadow: -3px -3px 5px rgba(0, 0, 0, 0.05);
}

.dropdown-header {
    background: linear-gradient(45deg, #2c3e50, #34495e);
    color: white;
    padding: 0.8rem 1.2rem;
    font-weight: bold;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dropdown ul {
    list-style: none;
    padding: 0.5rem 0;
}

.dropdown ul li a {
    display: block;
    padding: 0.8rem 1.5rem;
    color: #2c3e50;
    text-decoration: none;
    transition: all 0.3s ease;
    font-weight: 500;
    border-left: 3px solid transparent;
}

.dropdown ul li a:hover {
    background: #f8f9fa;
    color: #3498db;
    border-left-color: #3498db;
    padding-left: 2rem;
}

.dropdown ul li a.coming-soon {
    color: #aaa;
    pointer-events: none;
}

.dropdown ul li a.coming-soon::after {
    content: ' (скоро)';
    font-size: 0.75rem;
    color: #bbb;
}

/* Blog Link */
.nav-blog {
    margin-left: auto;
}

/* ============================================
   Main Content
   ============================================ */
main {
    padding: 2rem;
}

h1 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 2rem;
    font-size: 2.2rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
    animation: fadeInUp 1s ease-out 0.6s both;
    background: linear-gradient(45deg, #2c3e50, #3498db, #34495e);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: fadeInUp 1s ease-out 0.6s both, gradientShift 5s ease infinite;
}

h2 {
    color: #2c3e50;
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
    border-bottom: 3px solid #3498db;
    padding-bottom: 0.5rem;
}

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

/* ============================================
   Calculator Container
   ============================================ */
.calculator-container {
    max-width: 400px;
    margin: 0 auto 3rem;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 30px;
    box-shadow:
        0 25px 50px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(15px);
    animation: fadeInUp 1s ease-out 0.9s both, glow 3s ease-in-out infinite;
    position: relative;
}

.calculator-container::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, #3498db, #2c3e50, #34495e, #5dade2);
    border-radius: 32px;
    z-index: -1;
    animation: gradientShift 8s ease infinite;
}

.calculator-container.wide {
    max-width: 800px;
}

.calculator-container.extra-wide {
    max-width: 900px;
}

.calculator {
    padding: 2rem;
}

/* Display */
.display {
    width: 100%;
    height: 80px;
    font-size: 2rem;
    text-align: right;
    padding: 1rem;
    border: 3px solid transparent;
    background: linear-gradient(white, white) padding-box,
                linear-gradient(45deg, #3498db, #34495e) border-box;
    border-radius: 15px;
    margin-bottom: 1rem;
    color: #2c3e50;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.1);
}

.display:focus {
    outline: none;
    box-shadow:
        inset 0 2px 5px rgba(0, 0, 0, 0.1),
        0 0 20px rgba(52, 152, 219, 0.5);
    animation: pulse 0.5s ease;
}

/* Calculator Buttons */
.buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.buttons button {
    height: 60px;
    font-size: 1.2rem;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-weight: bold;
    box-shadow:
        0 6px 12px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    position: relative;
    overflow: hidden;
}

.buttons button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 70%);
    transition: all 0.3s ease;
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

.buttons button:active::before {
    width: 300px;
    height: 300px;
}

.buttons button:active {
    transform: translateY(0) scale(0.95);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
    animation: buttonPress 0.1s ease;
}

/* Button Types */
.btn-number {
    background: linear-gradient(145deg, #3498db, #2980b9);
    color: white;
    box-shadow:
        0 6px 12px rgba(52, 152, 219, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn-number:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow:
        0 10px 20px rgba(52, 152, 219, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn-operator {
    background: linear-gradient(145deg, #34495e, #2c3e50);
    color: white;
    box-shadow:
        0 6px 12px rgba(52, 73, 94, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn-operator:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow:
        0 10px 20px rgba(52, 73, 94, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn-clear {
    background: linear-gradient(145deg, #7f8c8d, #95a5a6);
    color: white;
    box-shadow:
        0 6px 12px rgba(127, 140, 141, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn-clear:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow:
        0 10px 20px rgba(127, 140, 141, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn-percent {
    background: linear-gradient(145deg, #e67e22, #d35400);
    color: white;
    box-shadow:
        0 6px 12px rgba(230, 126, 34, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn-percent:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow:
        0 10px 20px rgba(230, 126, 34, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn-equals {
    background: linear-gradient(145deg, #27ae60, #229954);
    color: white;
    grid-column: span 2;
    box-shadow:
        0 8px 16px rgba(39, 174, 96, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    border: 2px solid #27ae60;
    font-size: 1.3rem;
    font-weight: 900;
}

.btn-equals:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow:
        0 12px 24px rgba(39, 174, 96, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    background: linear-gradient(145deg, #2ecc71, #27ae60);
}

.btn-function {
    background: linear-gradient(145deg, #ecf0f1, #bdc3c7);
    color: #2c3e50;
    font-size: 0.9rem;
}

.btn-function:hover {
    background: linear-gradient(145deg, #d5dbdb, #a6acaf);
    transform: translateY(-2px);
}

/* ============================================
   Content Sections
   ============================================ */
.content-section {
    background: white;
    padding: 3rem;
    margin: 2rem 0;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.content-section p {
    margin-bottom: 1.5rem;
    text-align: justify;
    font-size: 1.1rem;
    line-height: 1.8;
}

.content-section ul,
.content-section ol {
    margin-bottom: 1.5rem;
    padding-left: 2rem;
}

.content-section li {
    margin-bottom: 0.5rem;
    line-height: 1.8;
}

.content-section img {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    margin: 1rem 0;
}

.highlight {
    background: linear-gradient(120deg, #a8edea 0%, #fed6e3 100%);
    padding: 0.2rem 0.5rem;
    border-radius: 5px;
    font-weight: bold;
}

/* Features Grid */
.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin: 2rem 0;
}

.feature {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 10px;
    border-left: 4px solid #3498db;
}

.feature h3 {
    color: #2c3e50;
    margin-bottom: 1rem;
}

/* ============================================
   Footer
   ============================================ */
footer {
    background: linear-gradient(45deg, #2c3e50, #34495e);
    color: white;
    text-align: center;
    padding: 2rem;
    margin-top: 3rem;
    animation: fadeInUp 1s ease-out 1.2s both;
}

footer a {
    color: #fff;
    text-decoration: none;
    transition: color 0.3s ease;
}

footer a:hover {
    color: #3498db;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.footer-copyright {
    margin-top: 1rem;
    opacity: 0.8;
    font-size: 0.9rem;
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 992px) {
    nav > ul {
        gap: 0.3rem;
    }

    nav > ul > li > a,
    nav > ul > li > .dropdown-toggle {
        padding: 0.5rem 0.8rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 768px) {
    .header-content {
        padding: 0 1rem;
    }

    .header-top {
        margin-bottom: 0;
    }

    .menu-toggle {
        display: block;
        z-index: 100000;
        position: relative;
    }

    nav {
        position: fixed;
        top: 0;
        left: -100%;
        width: 85%;
        max-width: 320px;
        height: 100vh;
        height: 100dvh;
        background: #1a252f;
        z-index: 99999;
        transition: left 0.3s ease;
        overflow-y: auto;
        padding-top: 20px;
        box-shadow: 5px 0 30px rgba(0, 0, 0, 0.5);
        pointer-events: auto;
        -webkit-overflow-scrolling: touch;
    }

    nav.open {
        left: 0;
    }

    nav * {
        pointer-events: auto;
    }

    /* Close button area */
    nav::before {
        content: 'МЕНЮ';
        display: block;
        color: #3498db;
        font-size: 0.9rem;
        font-weight: bold;
        letter-spacing: 2px;
        padding: 1rem 1.5rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        margin-bottom: 0.5rem;
    }

    nav > ul {
        flex-direction: column;
        gap: 0;
        padding: 0.5rem 1rem;
    }

    nav > ul > li {
        width: 100%;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    }

    nav > ul > li > a,
    nav > ul > li > .dropdown-toggle {
        padding: 1rem 0.5rem;
        border-radius: 8px;
        width: 100%;
        justify-content: space-between;
        font-size: 1rem;
    }

    nav > ul > li > a:hover,
    nav > ul > li > .dropdown-toggle:hover,
    nav > ul > li.open > .dropdown-toggle {
        transform: none;
        background: rgba(52, 152, 219, 0.2);
    }

    .dropdown {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        background: rgba(0, 0, 0, 0.15);
        border-radius: 8px;
        box-shadow: none;
        margin: 0.5rem 0;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease, padding 0.3s ease;
    }

    .dropdown::before {
        display: none;
    }

    nav > ul > li.open .dropdown {
        max-height: 500px;
        padding: 0.5rem 0;
    }

    .dropdown-header {
        display: none;
    }

    .dropdown ul {
        padding: 0;
    }

    .dropdown ul li a {
        color: #bdc3c7;
        padding: 0.7rem 1.5rem;
        font-size: 0.95rem;
        border-left: none;
    }

    .dropdown ul li a:hover,
    .dropdown ul li a.active {
        background: rgba(52, 152, 219, 0.25);
        color: white;
        padding-left: 1.5rem;
    }

    .dropdown ul li a.active {
        color: #3498db;
        font-weight: bold;
    }

    .dropdown ul li a.coming-soon {
        color: #7f8c8d;
    }

    .nav-blog {
        margin-left: 0;
        margin-top: 1rem;
        padding-top: 1rem;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }

    .nav-blog a {
        color: #3498db !important;
        font-weight: bold;
    }

    /* Overlay - only covers area outside nav */
    .nav-overlay {
        position: fixed;
        top: 0;
        right: 0;
        width: 100%;
        height: 100%;
        height: 100dvh;
        background: rgba(0, 0, 0, 0.5);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
        z-index: 99990;
        pointer-events: none;
    }

    .nav-overlay.active {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    /* Main content */
    h1 {
        font-size: 1.4rem;
    }

    main {
        padding: 1rem;
    }

    .content-section {
        padding: 1.5rem;
    }

    .footer-links {
        flex-direction: column;
        gap: 1rem;
    }
}

@media (max-width: 480px) {
    .calculator {
        padding: 1rem;
    }

    .display {
        height: 60px;
        font-size: 1.5rem;
    }

    .buttons {
        gap: 8px;
    }

    .buttons button {
        height: 50px;
        font-size: 1rem;
    }
}
