/* --- ОБЩИЕ СТИЛИ --- */
:root {
    --primary-color: #1a73e8;
    --primary-color-dark: #1558b0;
    --bg-light: #f8f9fa;
    --bg-white: #ffffff;
    --border-color: #dee2e6;
    --text-color: #212529;
    --text-color-light: #6c757d;
    --text-color-dark: #343a40;
    --footer-bg: #343a40;
    --footer-text: #f8f9fa;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 8px 25px rgba(0, 0, 0, 0.08);
}
*, *::before, *::after {
    box-sizing: border-box;
}
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-white);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
.container {
    width: 100%;
    max-width: 1140px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
}
h1, h2, h3 {
    margin-top: 0;
    font-weight: 700;
    color: var(--text-color-dark);
}
h1 {
    font-size: 2.8rem;
    margin-bottom: 1rem;
}
h2 {
    font-size: 2rem;
    text-align: center;
    margin-bottom: 1rem;
}
.section-subtitle {
    font-size: 1.15rem;
    color: var(--text-color-light);
    text-align: center;
    margin-top: -0.5rem;
    margin-bottom: 3rem;
}
p {
    color: var(--text-color-light);
    line-height: 1.6;
    font-size: 1rem;
}
.hidden {
    display: none !important;
}

/* ============================================= */
/* 1. СТИЛИ ЛЕНДИНГА (ШАПКА, СЕКЦИИ, ПОДВАЛ) */
/* ============================================= */

.site-header {
    background: var(--bg-white);
    box-shadow: var(--shadow);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
}
.site-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    text-decoration: none;
}
.main-nav ul {
    margin: 0; padding: 0; list-style: none; display: flex; gap: 1.5rem;
}
.main-nav a {
    text-decoration: none;
    color: var(--text-color-dark);
    font-weight: 500;
    transition: color 0.2s;
}
.main-nav a:hover {
    color: var(--primary-color);
}
#mobile-menu-toggle {
    display: none; background: none; border: none; cursor: pointer; padding: 0;
}
#mobile-menu-toggle span {
    display: block; width: 25px; height: 3px; background: var(--text-color-dark);
    margin: 5px 0; border-radius: 2px; transition: transform 0.3s, opacity 0.3s;
}
.hero-section {
    background: var(--bg-light);
    padding: 5rem 0;
    text-align: center;
}
.hero-subtitle {
    font-size: 1.2rem;
    color: var(--text-color);
    max-width: 700px;
    margin: 0 auto 2rem auto;
}
/* ИЗМЕНЕНИЕ: Стили для .button-primary, когда это ссылка */
a.button-primary {
    display: inline-block;
    text-decoration: none;
}
.hero-cta {
    padding: 0.8rem 2.5rem;
    font-size: 1.1rem;
}
.tool-selector-section,
.features-section,
.other-tools-section,
.faq-section {
    padding: 5rem 0;
}
.features-section,
.faq-section {
    background: var(--bg-light);
}
.mode-options-primary {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}
.mode-options-primary .mode-card {
    flex-basis: 400px;
    max-width: 100%;
}
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
}
.feature-item h3 {
    color: var(--primary-color);
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}
.feature-item p {
    font-size: 0.95rem;
}
.mode-options-secondary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}
.faq-list {
    max-width: 750px;
    margin: 0 auto;
}
.faq-item {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 1rem;
}
.faq-item summary {
    font-size: 1.1rem;
    font-weight: 600;
    padding: 1.25rem 1.5rem;
    cursor: pointer;
    list-style: none;
    position: relative;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
    content: '+';
    position: absolute;
    right: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.5rem;
    color: var(--primary-color);
}
.faq-item[open] summary::after {
    content: '−';
}
.faq-item p {
    padding: 0 1.5rem 1.25rem 1.5rem;
    margin: 0;
    border-top: 1px solid var(--border-color);
    font-size: 1rem;
}
.mode-card {
    background: var(--bg-white);
    border-radius: 12px;
    padding: 2rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    text-align: left;
    display: flex;
    flex-direction: column;
    position: relative;
}
.mode-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}
.mode-card h3 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}
.mode-card p {
    font-size: 0.95rem;
    flex-grow: 1;
}
.mode-card .button-primary {
    margin-top: 1.5rem;
}
.mode-card.disabled {
    opacity: 0.7;
    background: #fdfdfd;
}
.mode-card.disabled:hover {
    transform: none;
    box-shadow: var(--shadow);
}
.card-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: var(--primary-color-dark);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 12px;
}
.site-footer {
    background: var(--footer-bg);
    color: var(--footer-text);
    padding: 3rem 0 1.5rem 0;
    margin-top: auto;
}
.footer-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 2fr;
    gap: 2rem;
}
.footer-column h4 {
    color: var(--bg-white); margin-bottom: 1rem; font-size: 1rem; font-weight: 600;
}
.footer-column ul {
    margin: 0; padding: 0; list-style: none;
}
.footer-column li {
    margin-bottom: 0.5rem;
}
.footer-column a,
.footer-column p {
    color: var(--border-color); text-decoration: none; font-size: 0.9rem; transition: color 0.2s;
}
.footer-column a:hover {
    color: var(--bg-white);
}
.footer-column p {
    line-height: 1.6;
}
.footer-bottom {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #495057;
    text-align: center;
    font-size: 0.85rem;
    color: var(--border-color);
}

/* ============================================= */
/* 2. СТИЛИ ОКНА ПРИЛОЖЕНИЯ (app.php)         */
/* ============================================= */

/* ИЗМЕНЕНИЕ: Стили для селектора режима из v1 (для app.php) */
#mode-selector {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-light);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000; /* Выше всего */
    transition: opacity 0.3s ease;
}
.mode-container {
    text-align: center;
    max-width: 800px;
    padding: 2rem;
}
.mode-container h1 {
    font-size: 2.5rem;
}
.mode-options {
    display: flex;
    gap: 1.5rem;
    margin-top: 2rem;
}
/* Используем общие стили .mode-card */
#mode-selector .mode-card {
    flex: 1;
}

/* --- Основное приложение --- */
#app-wrapper {
    /* ИЗМЕНЕНИЕ: 
      - НЕ fixed, т.к. оно просто скрыто, а не поверх
      - z-index убран 
    */
    background: var(--bg-light);
    display: flex;
    flex-direction: column;
    min-height: 100vh; /* Занимает всю высоту */
}
#app-wrapper header {
    background-color: var(--bg-white);
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    position: sticky; /* Шапка приложения липнет */
    top: 0;
    z-index: 2000;
}
#app-wrapper header h1 {
    font-size: 1.5rem;
    color: var(--primary-color);
    margin-bottom: 0;
}
#back-to-modes {
    background: none; border: 1px solid var(--border-color);
    color: var(--text-color-light); padding: 0.5rem 1rem;
    border-radius: 6px; cursor: pointer; font-weight: 500;
    transition: background-color 0.2s, color 0.2s;
}
#back-to-modes:hover {
    background: var(--bg-light); color: var(--text-color);
}
#app-wrapper main {
    display: flex;
    flex-grow: 1;
    padding: 1.5rem;
    gap: 1.5rem;
    overflow: hidden;
}

/* 2А. ПАНЕЛЬ УПРАВЛЕНИЯ */
.controls {
    width: 400px;
    flex-shrink: 0;
    background: var(--bg-white);
    padding: 0 1.5rem 1.5rem 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    align-self: flex-start;
    overflow-y: auto;
    max-height: calc(100vh - 90px); /* 100vh - app-header(66px) - padding(24px) */
}
.control-group {
    margin-bottom: 1.25rem;
}
.control-group label {
    display: block; margin-bottom: 0.5rem; font-weight: 500;
}
.control-group label span {
    font-weight: normal; color: var(--text-color-light); float: right;
}

/* ИЗМЕНЕНИЕ: Стили для связки Ползунок + Поле ввода */
.control-group-split {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}
.control-group-split label {
    width: 100%;
    margin-bottom: 0;
}
.control-group-split input[type="range"] {
    flex: 1;
    min-width: 150px;
    margin-top: 0; /* Сброс */
}
.control-group-split .split-input {
    width: 70px;
    /* Стили из обычного инпута */
    padding: 0.6rem 0.5rem;
    box-sizing: border-box;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-light);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.control-group-split .split-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.2);
}

/* --- Остальные стили контролов --- */
input[type="text"],
input[type="number"],
select {
    width: 100%; padding: 0.6rem 0.75rem; box-sizing: border-box;
    border: 1px solid var(--border-color); border-radius: 6px;
    background: var(--bg-light);
    transition: border-color 0.2s, box-shadow 0.2s;
}
input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
    outline: none; border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.2);
}
input[type="range"] {
    -webkit-appearance: none; width: 100%; height: 6px;
    background: #e9ecef; border-radius: 3px; outline: none; margin-top: 8px;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 18px; height: 18px; border-radius: 50%;
    background: var(--primary-color); cursor: pointer;
    border: 2px solid var(--bg-white); box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
input[type="range"]::-moz-range-thumb {
    width: 18px; height: 18px; border-radius: 50%;
    background: var(--primary-color); cursor: pointer;
    border: 2px solid var(--bg-white); box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.modern-file-input { width: 100%; }
input[type="file"] { color: var(--text-color-light); }
input[type="file"]::file-selector-button {
    font-weight: 500; padding: 0.6rem 1rem; border-radius: 6px;
    border: 1px solid var(--border-color); background: var(--bg-white);
    color: var(--text-color); cursor: pointer;
    transition: background-color 0.2s; margin-right: 1rem;
}
input[type="file"]::file-selector-button:hover {
    background-color: var(--bg-light);
}
input[type="color"] {
    width: 100%; height: 40px; padding: 0;
    border: 1px solid var(--border-color); border-radius: 6px;
    box-sizing: border-box; cursor: pointer;
}
.checkbox-group, .radio-group {
    display: flex; align-items: center; margin-top: 1rem;
    background: var(--bg-light); padding: 0.75rem; border-radius: 6px;
}
.checkbox-group input, .radio-group input {
    margin-right: 8px; width: auto; accent-color: var(--primary-color);
}
.checkbox-group label, .radio-group label {
    margin-bottom: 0; margin-right: 15px; font-weight: normal;
}
.button-primary {
    width: 100%; padding: 0.75rem; background-color: var(--primary-color);
    color: white; border: none; border-radius: 6px;
    font-size: 1rem; font-weight: 600; cursor: pointer;
    transition: background-color 0.3s ease;
}
a.button-primary { /* Для кнопок-ссылок */
    padding: 0.75rem; box-sizing: border-box; text-align: center;
}
.button-primary:hover {
    background-color: var(--primary-color-dark);
}
.button-primary:disabled {
    background-color: #aaa; cursor: not-allowed;
}

/* 2Б. PRO-СТИЛИ */
/* ИЗМЕНЕНИЕ: Фикс бага размера логотипа */
#logoPreview-pro {
    display: none; /* Скрыт, пока не загружен */
    max-width: 100%;
    height: 100px; /* Фикс. высота */
    object-fit: contain;
    margin-top: 10px;
    border: 1px dashed var(--border-color);
    padding: 5px;
    border-radius: 4px;
}

.thumbnails-container {
    display: flex; flex-wrap: wrap; gap: 8px; margin-top: 1rem;
    max-height: 200px; overflow-y: auto; background: var(--bg-light);
    padding: 8px; border-radius: 4px; border: 1px solid var(--border-color);
}
.thumbnail {
    width: 60px; height: 60px; border: 2px solid transparent;
    border-radius: 4px; cursor: pointer; position: relative; overflow: hidden;
}
.thumbnail img {
    width: 100%; height: 100%; object-fit: cover;
}
.thumbnail.active {
    border-color: var(--primary-color);
    box-shadow: 0 0 5px rgba(26, 115, 232, 0.5);
}
.tab-navigation {
    display: flex; border-bottom: 1px solid var(--border-color); margin-bottom: 1rem;
}
.tab-button {
    flex: 1; padding: 0.75rem 0.5rem; border: none; background: none;
    cursor: pointer; font-size: 0.9rem; font-weight: 600;
    color: var(--text-color-light); border-bottom: 3px solid transparent;
    margin-bottom: -1px;
}
.tab-button.active {
    color: var(--primary-color); border-bottom-color: var(--primary-color);
}
.tab-pane { display: none; }
.tab-pane.active { display: block; }
.position-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px;
}
.position-grid button {
    height: 40px; border: 2px solid var(--border-color);
    background: var(--bg-light); cursor: pointer; border-radius: 4px;
}
.position-grid button:hover { border-color: #999; }
.position-grid button.active {
    background: var(--primary-color); border-color: var(--primary-color);
}
.sub-option, .tiling-option {
    display: none; border-left: 3px solid var(--primary-color);
    padding-left: 10px; margin-top: 1rem; background: var(--bg-light);
    padding: 10px; border-radius: 4px;
}

/* --- 3. ХОЛСТ (внутри Приложения) --- */
.canvas-container {
    flex-grow: 1; display: flex; justify-content: center; align-items: center;
    background-color: var(--bg-light);
    background-image: 
        linear-gradient(45deg, #e9ecef 25%, transparent 25%), 
        linear-gradient(-45deg, #e9ecef 25%, transparent 25%), 
        linear-gradient(45deg, transparent 75%, #e9ecef 75%), 
        linear-gradient(-45deg, transparent 75%, #e9ecef 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    border-radius: 8px;
    overflow: auto;
    min-height: 400px;
}
canvas {
    background: white; box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    max-width: 100%; max-height: 75vh;
    object-fit: contain; cursor: default;
}
canvas.draggable { cursor: move; }

/* ============================================= */
/* 4. АДАПТАЦИЯ                              */
/* ============================================= */

/* --- Адаптация Приложения (app.php) --- */
@media (max-width: 900px) {
    #app-wrapper main {
        flex-direction: column;
        padding: 0.5rem;
        overflow-y: auto;
    }
    .controls {
        width: 100%;
        margin-bottom: 1rem;
        padding: 1rem;
        max-height: none;
    }
    /* Селектор режима на мобильных */
    .mode-options {
        flex-direction: column;
    }
}

/* --- Адаптация Лендинга (index.php) --- */
@media (max-width: 768px) {
    h1 { font-size: 2.2rem; }
    h2 { font-size: 1.8rem; }
    
    .site-header { padding: 1rem 1.5rem; }
    .main-nav {
        display: none; position: absolute;
        top: 65px;
        left: 0; right: 0;
        background: var(--bg-white);
        box-shadow: var(--shadow);
    }
    .main-nav.mobile-active { display: block; }
    .main-nav ul { flex-direction: column; gap: 0; }
    .main-nav li { border-bottom: 1px solid var(--border-color); }
    .main-nav a { display: block; padding: 1rem 1.5rem; }
    #mobile-menu-toggle { display: block; }
    #mobile-menu-toggle.active span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
    #mobile-menu-toggle.active span:nth-child(2) { opacity: 0; }
    #mobile-menu-toggle.active span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }

    .hero-section { padding: 3rem 0; }
    .tool-selector-section,
    .features-section,
    .other-tools-section,
    .faq-section {
        padding: 3rem 0;
    }
    .mode-options-primary {
        flex-direction: column;
        gap: 1.5rem;
    }
    .mode-options-primary .mode-card {
        flex-basis: auto;
    }
    .footer-grid {
        grid-template-columns: 1fr;
        text-align: center;
    }
    .footer-column.about-column {
        grid-row: 1;
    }
}