/* ==========================================
   ImageTools - Основные стили
   ========================================== */

:root {
    --primary: #007bff;
    --primary-dark: #0056b3;
    --secondary: #6c757d;
    --success: #28a745;
    --text: #333;
    --bg: #f8f9fa;
    --border: #dee2e6;
    --white: #ffffff;
    --radius: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.12);
}

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

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

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

/* ---- HEADER ---- */
header {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 15px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.logo a {
    display: flex;
    align-items: center;
    text-decoration: none;
    gap: 10px;
    color: var(--text);
    font-weight: 700;
    font-size: 20px;
}

.logo img { height: 36px; }

nav {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

nav a {
    color: var(--text);
    text-decoration: none;
    font-size: 15px;
    transition: color 0.2s;
}

nav a:hover { color: var(--primary); }



/* ---- MAIN ---- */
main.container {
    padding-top: 40px;
    padding-bottom: 40px;
    min-height: 60vh;
}

main h1 {
    font-size: 2rem;
    margin-bottom: 10px;
    color: var(--text);
}

.subtitle {
    color: var(--secondary);
    font-size: 1.1rem;
    margin-bottom: 30px;
}

/* ---- TOOL CONTAINER ---- */
.tool-container {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 30px;
    margin: 20px 0;
    box-shadow: var(--shadow);
}

/* ---- UPLOAD BOX ---- */
.upload-box {
    border: 2px dashed var(--primary);
    border-radius: var(--radius);
    padding: 60px 40px;
    text-align: center;
    margin: 20px 0;
    cursor: pointer;
    background: #f8f9ff;
    transition: background 0.2s;
}

.upload-box:hover { background: #e8efff; }
.upload-box p { color: var(--secondary); margin-top: 10px; }

/* ---- BUTTONS ---- */
.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 28px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    margin: 8px 4px;
    transition: background 0.2s;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
    background: var(--secondary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    margin: 8px 4px;
    transition: background 0.2s;
}
.btn-secondary:hover { background: #545b62; }

/* ---- CONTROLS ---- */
.control-group { margin: 14px 0; }
.control-group label { font-weight: 500; color: var(--text); }
input[type=range] { width: 220px; vertical-align: middle; accent-color: var(--primary); }
input[type=number], input[type=text], select {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 14px;
    color: var(--text);
}
input:focus, select:focus { outline: none; border-color: var(--primary); }

canvas { max-width: 100%; }

/* ---- STATS ---- */
.stats {
    background: #e8f5e9;
    padding: 12px 16px;
    border-radius: 6px;
    margin: 12px 0;
    color: #1b5e20;
}

/* ---- PROGRESS ---- */
.progress {
    background: #e9ecef;
    border-radius: 6px;
    height: 22px;
    overflow: hidden;
    margin: 10px 0;
}
.progress-bar {
    background: var(--primary);
    height: 100%;
    transition: width 0.3s ease;
    border-radius: 6px;
}

/* ---- HOW-TO BLOCK ---- */
.how-to {
    background: var(--white);
    padding: 35px 40px;
    margin-top: 40px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.how-to h3 { color: var(--primary); margin-bottom: 16px; font-size: 1.2rem; }
.how-to ol { padding-left: 20px; }
.how-to ol li { line-height: 1.9; }

/* ---- FEATURES BLOCK ---- */
.features {
    background: var(--bg);
    padding: 60px 0;
    margin-top: 40px;
}
.features h2 { text-align: center; margin-bottom: 0; font-size: 1.6rem; }
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 24px;
    margin-top: 30px;
}
.feature {
    text-align: center;
    padding: 28px 20px;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.feature-icon { font-size: 44px; margin-bottom: 12px; }
.feature h3 { margin-bottom: 8px; font-size: 1.1rem; }
.feature p { color: var(--secondary); font-size: 14px; }

/* ---- TOOLS GRID (homepage) ---- */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin: 30px 0;
}
.tool-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    text-decoration: none;
    color: var(--text);
    transition: all 0.2s;
    background: var(--white);
}
.tool-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(0,123,255,0.15);
    transform: translateY(-2px);
}
.tool-card .icon { font-size: 36px; margin-bottom: 10px; }
.tool-card h3 { font-size: 15px; margin: 0; }

/* ---- HERO ---- */
.hero {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: white;
    padding: 80px 0;
    text-align: center;
}
.hero h1 { font-size: 2.5rem; margin-bottom: 15px; }
.hero p { font-size: 1.2rem; opacity: 0.9; margin-bottom: 30px; }
.hero .btn-primary { background: white; color: var(--primary); font-weight: 700; font-size: 18px; padding: 15px 36px; }
.hero .btn-primary:hover { background: #f0f0f0; }

/* ---- FOOTER ---- */
footer {
    background: #2d3748;
    color: #a0aec0;
    padding: 30px 0;
    margin-top: 60px;
}
footer .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}
footer p { margin: 0; }
.footer-links {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
}
.footer-links a {
    color: #a0aec0;
    text-decoration: none;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: color 0.2s;
}
.footer-links a:hover { color: white; }

/* ---- DROPDOWN ---- */
.dropdown { position: relative; }
.dropdown-toggle { cursor: pointer; }
.dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    min-width: 200px;
    z-index: 1000;
}
.dropdown.active .dropdown-menu { display: grid; }
.dropdown-menu.two-columns {
    grid-template-columns: 1fr 1fr;
    padding: 12px;
    min-width: 440px;
}
.dropdown-column a {
    display: block;
    padding: 8px 14px;
    color: var(--text);
    text-decoration: none;
    border-radius: 4px;
    font-size: 14px;
    white-space: nowrap;
}
.dropdown-column a:hover { background: #f0f4ff; color: var(--primary); }

/* ---- COOKIE CONSENT ---- */
.cookie-consent {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: rgba(45,55,72,0.97);
    color: white;
    padding: 16px;
    z-index: 10000;
    backdrop-filter: blur(4px);
}
.cookie-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}
.cookie-content p { margin: 0; font-size: 14px; }
.cookie-content a { color: #63b3ed; }

/* ---- PREVIEW IMG ---- */
.preview-img {
    max-width: 100%;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* ---- LANGUAGE SWITCHER ---- */
.lang-switch {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    text-decoration: none;
    transition: border-color 0.2s, background 0.2s;
    font-size: 12px;
    color: var(--text);
    gap: 5px;
    vertical-align: middle;
    line-height: 1;
}
.lang-switch:hover { border-color: var(--primary); background: #f0f4ff; }
.lang-switch img { display: block; border-radius: 2px; }
.lang-flag {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border: 1px solid transparent;
    border-radius: 6px;
    text-decoration: none;
    transition: border-color 0.2s, background 0.2s;
}
.lang-flag:hover, .lang-flag.active { border-color: var(--primary); background: #f0f4ff; }
.lang-flag img { display: block; border-radius: 2px; }


/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
    main h1 { font-size: 1.5rem; }
    .hero h1 { font-size: 1.8rem; }
    nav { gap: 12px; }
    .tool-container { padding: 20px 15px; }
    .how-to { padding: 25px 20px; }
    footer .container { flex-direction: column; text-align: center; }
    .footer-links { justify-content: center; }
    .dropdown-menu.two-columns { min-width: 280px; grid-template-columns: 1fr; }
    .features-grid { grid-template-columns: 1fr 1fr; gap: 15px; }
    .feature { padding: 20px 15px; }
}

@media (max-width: 480px) {
    header .container { flex-wrap: wrap; }
    .features-grid { grid-template-columns: 1fr; }
    .tools-grid { grid-template-columns: 1fr 1fr; }
}

/* Mobile nav — prevent horizontal overflow */
@media (max-width: 768px) {
    .dropdown-menu.two-columns {
        grid-template-columns: 1fr !important;
        min-width: 200px !important;
        max-width: calc(100vw - 40px);
        left: auto !important;
        right: 0;
    }
    .dropdown-menu {
        min-width: 180px;
        max-width: calc(100vw - 20px);
    }
    body { overflow-x: hidden; }
    .container { overflow-x: hidden; }
    nav .dropdown-menu {
        position: fixed;
        top: auto;
        left: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        border-radius: 0 0 8px 8px;
        max-height: 70vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ─── FAQ Section ──────────────────────────────────────── */
.faq-section {
    background: #fff;
    padding: 60px 0;
    margin-top: 40px;
}
.faq-section h2 {
    font-size: 1.8rem;
    margin-bottom: 30px;
    color: #1a1a2e;
    text-align: center;
}
.faq-item {
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    margin-bottom: 16px;
    overflow: hidden;
}
.faq-question {
    background: #f8f9fa;
    margin: 0;
    padding: 18px 24px;
    font-size: 1rem;
    font-weight: 600;
    color: #2c3e50;
    cursor: default;
}
.faq-answer {
    padding: 16px 24px;
    color: #555;
    line-height: 1.7;
}
.faq-answer p { margin: 0; }

/* ─── Error section ─────────────────────────────────────── */
.error-section {
    text-align: center;
    padding: 80px 20px;
    min-height: 50vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.error-icon { font-size: 4rem; margin-bottom: 20px; }
.error-section h1 { font-size: 2.5rem; color: #1a1a2e; margin-bottom: 16px; }
.error-section p  { font-size: 1.1rem; color: #666; max-width: 500px; margin: 0 auto 32px; }
.error-buttons { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }

/* ===== Yandex Direct Ad Banners ===== */
.ad-banner {
    width: 100%;
    text-align: center;
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
}
.ad-banner-top {
    border-bottom: 1px solid #e9ecef;
}
.ad-banner-bottom {
    border-top: 1px solid #e9ecef;
    margin-top: 40px;
}
/* Empty ad banners are hidden */
.ad-banner:empty,
.ad-banner > *:empty {
    display: none;
}

/* === Yandex Direct Ad Banners === */
.ad-banner { width:100%; text-align:center; background:#f8f9fa; }
.ad-banner-top { border-bottom:1px solid #e9ecef; }
.ad-banner-bottom { border-top:1px solid #e9ecef; margin-top:40px; }
