@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600;700&display=swap');

:root {
    --primary-bg: #1a1918;
    --secondary-bg: #262624;
    --accent-bg: #323230;
    --card-bg: #2d2c2a;
    --border-color: #3e3d3b;
    --btn-back: #67101055;
    --text-primary: #f8f8f8;
    --text-secondary: #d4d4d4;
    --text-muted: #a0a0a0;
    --accent-orange: #c96442;
    --accent-orange-hover: #d4734f;
    --accent-orange-light: #c9644220;
    --accent-orange-glow: #c9644260;
    --success-color: #5cb85c;
    --success-hover: #6cc56c;
    --warning-color: #f0ad4e;
    --danger-color: #d9534f;
    --shadow-light: rgba(0, 0, 0, 0.2);
    --shadow-medium: rgba(0, 0, 0, 0.4);
    --shadow-heavy: rgba(0, 0, 0, 0.7);
}

* {
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: var(--primary-bg);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(0.5rem, 2vw, 1rem);
    position: relative;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 30%, rgba(201, 100, 66, 0.12) 0%, transparent 40%),
        radial-gradient(circle at 80% 70%, rgba(201, 100, 66, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 50% 50%, rgba(50, 50, 48, 0.3) 0%, transparent 60%);
    z-index: -1;
}

.container {
    background: var(--secondary-bg);
    border: 1px solid var(--border-color);
    border-radius: clamp(16px, 3vw, 24px);
    padding: clamp(1rem, 3vw, 2.5rem);
    box-shadow: 
        0 20px 60px var(--shadow-heavy),
        0 0 0 1px rgba(201, 100, 66, 0.1);
    max-width: 920px;
    width: 90%;
    position: relative;
    max-height: 95vh;
    overflow: visible;
    backdrop-filter: blur(10px);
}

.container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    opacity: 0.8;
}

.header {
    text-align: center;
    margin-bottom: clamp(1rem, 3vw, 2rem);
    padding-bottom: clamp(0.75rem, 2vw, 1.5rem);
    border-bottom: 1px solid var(--border-color);
}

.header h1 {
    font-size: clamp(1.25rem, 4vw, 2rem);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 10px rgba(201, 100, 66, 0.2);
    line-height: 1.2;
}

.page-switcher {
    display: flex;
    justify-content: center;
    margin-bottom: clamp(1rem, 2.5vw, 2rem);
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: clamp(10px, 2vw, 14px);
    padding: clamp(0.25rem, 0.5vw, 0.4rem);
    gap: clamp(0.25rem, 0.5vw, 0.4rem);
    flex-wrap: wrap;
}

.page-btn {
    flex: 1;
    min-width: fit-content;
    padding: clamp(0.6rem, 1.5vw, 0.85rem) clamp(0.75rem, 2vw, 1.5rem);
    background: transparent;
    color: var(--text-muted);
    border: none;
    border-radius: clamp(8px, 1.5vw, 10px);
    font-size: clamp(0.8rem, 1.5vw, 0.95rem);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    white-space: nowrap;
}

.page-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--accent-orange-light);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.page-btn.active {
    background: var(--accent-orange);
    color: var(--text-primary);
    box-shadow: 0 4px 12px var(--accent-orange-glow);
}

.page-btn:hover:not(.active) {
    color: var(--text-primary);
    background: var(--accent-bg);
}

.page-btn:hover:not(.active)::before {
    opacity: 1;
}

.pages-container {
    position: relative;
    overflow: hidden;
    height: auto;
    max-height: none;
    min-height: 400px;
}

.page {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease;
    pointer-events: none;
    padding-right: clamp(8px, 1.5vw, 15px);
}

.page.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.page::-webkit-scrollbar {
    width: clamp(4px, 0.8vw, 6px);
}

.page::-webkit-scrollbar-track {
    background: var(--accent-bg);
    border-radius: 3px;
}

.page::-webkit-scrollbar-thumb {
    background: var(--accent-orange);
    border-radius: 3px;
}

.page::-webkit-scrollbar-thumb:hover {
    background: var(--accent-orange-hover);
}

.content-section {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: clamp(12px, 2vw, 16px);
    padding: clamp(1rem, 2.5vw, 2rem);
    margin-bottom: clamp(1rem, 2vw, 1.5rem);
    margin-right: 2px;
    transition: all 0.3s ease;
    width: calc(100% - 2px);
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.content-section:last-child {
    margin-bottom: clamp(1.5rem, 2.5vw, 2rem);
}

.content-section:hover {
    border-color: rgba(201, 100, 66, 0.3);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.content-section h2 {
    color: var(--accent-orange);
    font-size: clamp(1.1rem, 2.5vw, 1.4rem);
    margin-bottom: clamp(0.75rem, 1.5vw, 1.2rem);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    line-height: 1.3;
}

.content-section h2::before {
    content: '';
    width: clamp(3px, 0.5vw, 4px);
    height: clamp(20px, 3vw, 24px);
    background: var(--accent-orange);
    border-radius: 2px;
    flex-shrink: 0;
}

.content-section h3 {
    color: var(--text-secondary);
    font-size: clamp(0.95rem, 2vw, 1.1rem);
    margin: clamp(0.75rem, 1.5vw, 1rem) 0 clamp(0.5rem, 1vw, 0.75rem) 0;
    font-weight: 600;
    line-height: 1.4;
}

.content-section p,
.content-section li {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 0.5rem;
    font-size: clamp(0.875rem, 1.5vw, 1rem);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.content-section ul {
    padding-left: clamp(1rem, 2vw, 1.5rem);
    margin: 0.5rem 0;
}

.content-section strong {
    color: var(--text-primary);
}

.template-example {
    background: var(--accent-bg);
    border: 1px solid var(--border-color);
    border-left: clamp(3px, 0.5vw, 4px) solid var(--accent-orange);
    padding: clamp(1rem, 2vw, 1.5rem);
    margin: clamp(0.75rem, 1.5vw, 1.2rem) 0;
    border-radius: clamp(8px, 1.5vw, 12px);
    font-family: 'Courier New', monospace;
    color: var(--text-secondary);
    white-space: pre-line;
    font-size: clamp(0.8rem, 1.5vw, 0.95rem);
    line-height: 1.8;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.2);
    overflow-x: auto;
    word-wrap: break-word;
    width: calc(100% - 2px);
    max-width: 100%;
    box-sizing: border-box;
}

.copy-template-btn {
    background: linear-gradient(135deg, var(--accent-orange) 0%, var(--accent-orange-hover) 100%);
    color: var(--text-primary);
    border: none;
    padding: clamp(0.75rem, 2vw, 1rem) clamp(1rem, 3vw, 2rem);
    border-radius: clamp(10px, 1.5vw, 12px);
    font-weight: 600;
    font-size: clamp(0.875rem, 1.5vw, 1rem);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: 100%;
    margin-top: clamp(0.75rem, 1.5vw, 1rem);
    box-shadow: 0 4px 16px var(--accent-orange-glow);
    position: relative;
    overflow: hidden;
    touch-action: manipulation;
}

.copy-template-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.5s ease;
}

.copy-template-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px var(--accent-orange-glow);
}

.copy-template-btn:hover::before {
    left: 100%;
}

.copy-template-btn:active {
    transform: translateY(0);
}

.copy-feedback {
    position: fixed;
    top: clamp(15px, 3vw, 30px);
    right: clamp(15px, 3vw, 30px);
    background: linear-gradient(135deg, var(--success-color), var(--success-hover));
    color: var(--text-primary);
    padding: clamp(0.75rem, 2vw, 1.2rem) clamp(1rem, 3vw, 2rem);
    border-radius: clamp(10px, 2vw, 14px);
    font-weight: 600;
    font-size: clamp(0.875rem, 1.5vw, 1rem);
    transform: translateX(400px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    box-shadow: 0 10px 30px rgba(92, 184, 92, 0.4);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    max-width: calc(100vw - 30px);
}

.copy-feedback::before {
    content: '✓';
    font-size: clamp(1rem, 2vw, 1.3rem);
}

.copy-feedback.show {
    transform: translateX(0);
    opacity: 1;
}

.warning-box {
    background: rgba(240, 173, 78, 0.08);
    border: 1px solid rgba(240, 173, 78, 0.3);
    border-left: clamp(3px, 0.5vw, 4px) solid var(--warning-color);
    border-radius: clamp(8px, 1.5vw, 12px);
    padding: clamp(1rem, 2vw, 1.5rem);
    margin: clamp(0.75rem, 1.5vw, 1.2rem) 0;
    color: var(--text-secondary);
    width: calc(100% - 2px);
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.info-box {
    background: var(--accent-orange-light);
    border: 1px solid rgba(201, 100, 66, 0.3);
    border-left: clamp(3px, 0.5vw, 4px) solid var(--accent-orange);
    border-radius: clamp(8px, 1.5vw, 12px);
    padding: clamp(1rem, 2vw, 1.5rem);
    margin: clamp(0.75rem, 1.5vw, 1.2rem) 0;
    color: var(--text-secondary);
    width: calc(100% - 2px);
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.info-box a {
    color: var(--accent-orange-hover);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
    word-wrap: break-word;
}

.info-box a:hover {
    color: var(--accent-orange);
    text-decoration: underline;
}

/* Новые стили для danger boxes */
.danger-box-top,
.danger-box-bottom {
    background: rgba(217, 83, 79, 0.15);
    border: 1px solid rgba(217, 83, 79, 0.5);
    border-left: clamp(4px, 0.6vw, 5px) solid var(--danger-color);
    border-radius: clamp(10px, 2vw, 14px);
    padding: clamp(1rem, 2.5vw, 1.5rem);
    color: var(--text-primary);
    box-shadow: 0 4px 16px rgba(217, 83, 79, 0.25);
    text-align: center;
    width: calc(100% - 2px);
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    margin-right: 2px;
}

.danger-box-top {
    animation: pulse-danger 2s ease-in-out infinite;
    margin-bottom: clamp(1rem, 2vw, 1.5rem);
}

.danger-box-bottom {
    margin-top: clamp(1rem, 2vw, 1.5rem);
    margin-bottom: 0;
}

.danger-box-top strong,
.danger-box-bottom strong {
    color: var(--text-primary);
    font-size: clamp(0.875rem, 1.8vw, 1.05rem);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(0.4rem, 1vw, 0.6rem);
    line-height: 1.5;
    flex-wrap: wrap;
    text-align: center;
}

@keyframes pulse-danger {
    0%, 100% {
        box-shadow: 0 4px 16px rgba(217, 83, 79, 0.25);
        border-color: rgba(217, 83, 79, 0.5);
    }
    50% {
        box-shadow: 0 4px 20px rgba(217, 83, 79, 0.4);
        border-color: rgba(217, 83, 79, 0.7);
    }
}

/* Экраны ноутбуков (1025px - 1440px) */
@media (max-width: 1440px) and (min-width: 1025px) {
    .container {
        max-height: 90vh;
        padding: 2rem;
    }
    
    .pages-container {
        height: calc(90vh - 180px);
        max-height: 500px;
    }
    
    .content-section {
        padding: 1.5rem;
        margin-bottom: 1.25rem;
    }
    
    .danger-box-top,
    .danger-box-bottom {
        padding: 1.25rem;
    }
}

/* Экраны планшетов (768px - 1024px) */
@media (max-width: 1024px) and (min-width: 769px) {
    .container {
        max-height: 92vh;
    }
    
    .pages-container {
        max-height: 550px;
    }
    
    .danger-box-top strong,
    .danger-box-bottom strong {
        font-size: 0.95rem;
    }
}

/* Экраны планшетов и больших телефонов (481px - 768px) */
@media (max-width: 768px) {
    body {
        padding: 0.5rem;
    }

    .container {
        padding: 1.25rem;
        max-height: none;
        overflow: visible;
        border-radius: 16px;
    }

    .header {
        margin-bottom: 1rem;
        padding-bottom: 1rem;
    }

    .page-switcher {
        margin-bottom: 1rem;
        padding: 0.3rem;
        gap: 0.3rem;
    }

    .page-btn {
        padding: 0.65rem 0.85rem;
        font-size: 0.85rem;
    }

    .pages-container {
        height: auto;
        min-height: 300px;
    }

    .content-section {
        padding: 1.25rem;
        margin-bottom: 1rem;
    }

    .template-example {
        padding: 1rem;
        font-size: 0.85rem;
    }
    
    .danger-box-top,
    .danger-box-bottom {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .danger-box-bottom {
        margin-top: 1rem;
    }
    
    .danger-box-top strong,
    .danger-box-bottom strong {
        font-size: 0.9rem;
        gap: 0.4rem;
    }
}

/* Маленькие телефоны (до 480px) */
@media (max-width: 480px) {
    body {
        padding: 0.25rem;
        align-items: flex-start;
    }

    .container {
        padding: 1rem;
        max-height: 98vh;
        border-radius: 12px;
        margin: 0.25rem 0;
    }

    .header {
        margin-bottom: 0.75rem;
        padding-bottom: 0.75rem;
    }

    .header h1 {
        font-size: 1.15rem;
    }

    .page-switcher {
        margin-bottom: 0.75rem;
        padding: 0.25rem;
        gap: 0.25rem;
    }

    .page-btn {
        padding: 0.55rem 0.65rem;
        font-size: 0.75rem;
        border-radius: 6px;
    }

    .pages-container {
        height: calc(98vh - 140px);
        max-height: none;
    }

    .content-section {
        padding: 1rem;
        margin-bottom: 0.75rem;
        border-radius: 10px;
    }

    .content-section h2 {
        font-size: 1rem;
        margin-bottom: 0.75rem;
    }

    .content-section h3 {
        font-size: 0.9rem;
    }

    .content-section p,
    .content-section li {
        font-size: 0.85rem;
        line-height: 1.5;
    }

    .template-example {
        padding: 0.85rem;
        font-size: 0.75rem;
        line-height: 1.6;
        border-radius: 8px;
    }

    .copy-template-btn {
        padding: 0.7rem 1rem;
        font-size: 0.85rem;
        margin-top: 0.75rem;
    }

    .copy-feedback {
        top: 10px;
        right: 10px;
        padding: 0.65rem 1rem;
        font-size: 0.85rem;
        max-width: calc(100vw - 20px);
    }

    .warning-box,
    .info-box {
        padding: 0.85rem;
        border-radius: 8px;
    }

    .page {
        padding-right: 5px;
    }

    .page::-webkit-scrollbar {
        width: 3px;
    }
    
    .danger-box-top,
    .danger-box-bottom {
        padding: 0.85rem;
        margin-bottom: 0.75rem;
        border-radius: 10px;
        border-left-width: 4px;
    }
    
    .danger-box-bottom {
        margin-top: 0.75rem;
    }
    
    .danger-box-top strong,
    .danger-box-bottom strong {
        font-size: 0.85rem;
        gap: 0.35rem;
        line-height: 1.4;
    }
}

/* Очень маленькие экраны (до 360px) */
@media (max-width: 360px) {
    .container {
        padding: 0.75rem;
    }

    .header h1 {
        font-size: 1rem;
    }

    .page-btn {
        padding: 0.5rem 0.5rem;
        font-size: 0.7rem;
    }

    .content-section {
        padding: 0.75rem;
    }

    .content-section h2 {
        font-size: 0.95rem;
        gap: 0.35rem;
    }

    .content-section h2::before {
        width: 3px;
        height: 18px;
    }

    .content-section p,
    .content-section li {
        font-size: 0.8rem;
    }

    .template-example {
        font-size: 0.7rem;
    }
    
    .danger-box-top,
    .danger-box-bottom {
        padding: 0.75rem;
        border-left-width: 3px;
    }
    
    .danger-box-top strong,
    .danger-box-bottom strong {
        font-size: 0.8rem;
        gap: 0.3rem;
    }
}

/* Ландшафтная ориентация на мобильных устройствах */
@media (max-height: 500px) and (orientation: landscape) {
    body {
        align-items: flex-start;
        padding: 0.5rem;
    }

    .container {
        max-height: 96vh;
        margin: 0.5rem 0;
    }

    .header {
        margin-bottom: 0.5rem;
        padding-bottom: 0.5rem;
    }

    .header h1 {
        font-size: 1.1rem;
        margin-bottom: 0.25rem;
    }

    .page-switcher {
        margin-bottom: 0.5rem;
    }

    .pages-container {
        height: calc(96vh - 110px);
        max-height: none;
    }

    .content-section {
        padding: 1rem;
        margin-bottom: 0.75rem;
    }
    
    .danger-box-top,
    .danger-box-bottom {
        padding: 0.85rem;
        margin-bottom: 0.5rem;
    }
    
    .danger-box-bottom {
        margin-top: 0.5rem;
    }
}

/* Высокие экраны */
@media (min-height: 1000px) {
    .pages-container {
        max-height: 750px;
    }
}

/* Средние экраны по высоте */
@media (min-height: 800px) and (max-height: 999px) {
    .pages-container {
        max-height: 650px;
    }
    
    .container {
        max-height: 88vh;
    }
}

/* Touch устройства - увеличение области нажатия */
@media (hover: none) and (pointer: coarse) {
    .page-btn {
        padding: 0.75rem 1rem;
        min-height: 44px;
    }

    .copy-template-btn {
        min-height: 48px;
    }

    .info-box a {
        padding: 0.25rem 0;
        display: inline-block;
    }
}