/* ========================================
   ToolRU — style.css
   Единый CSS. Кэшируется. Версионируется filemtime().
   ======================================== */

/* === ПЕРЕМЕННЫЕ === */
:root {
    --bg: #ffffff;
    --bg-secondary: #f7f8fa;
    --bg-tool: #f0f4ff;
    --text: #1a1a2e;
    --text-secondary: #5a5a7a;
    --text-tertiary: #717190;
    --accent: #4361ee;
    --accent-hover: #3a56d4;
    --accent-light: #eef1ff;
    --border: #e2e5f1;
    --border-light: #f0f1f5;
    --success: #10b981;
    --success-light: #ecfdf5;
    --error: #ef4444;
    --error-light: #fef2f2;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --transition: 0.2s ease;
    --max-width: 800px;
}

[data-theme="dark"] {
    --bg: #1a1a2e;
    --bg-secondary: #16162a;
    --bg-tool: #232344;
    --text: #e8e8f0;
    --text-secondary: #a0a0c0;
    --text-tertiary: #8888aa;
    --accent: #6b7fff;
    --accent-hover: #8b9fff;
    --accent-light: #2a2a4e;
    --border: #2e2e50;
    --border-light: #252545;
    --success: #34d399;
    --success-light: #1a2e28;
    --error: #f87171;
    --error-light: #2e1a1a;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #1a1a2e;
        --bg-secondary: #16162a;
        --bg-tool: #232344;
        --text: #e8e8f0;
        --text-secondary: #a0a0c0;
        --text-tertiary: #8888aa;
        --accent: #6b7fff;
        --accent-hover: #8b9fff;
        --accent-light: #2a2a4e;
        --border: #2e2e50;
        --border-light: #252545;
        --success: #34d399;
        --success-light: #1a2e28;
        --error: #f87171;
        --error-light: #2e1a1a;
        --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
        --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    }
}

/* === RESET === */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* === BODY & LAYOUT === */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

main {
    flex: 1;
}

/* === CONTAINER === */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 20px;
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
}

/* === HEADER === */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    height: 56px;
    display: flex;
    align-items: center;
    padding-top: env(safe-area-inset-top);
}

.header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text);
    font-weight: 700;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.logo svg {
    color: var(--accent);
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color var(--transition);
}

.header-nav a:hover {
    color: var(--accent);
}

/* === SKIP LINK === */
.skip-link {
    position: absolute;
    top: -100%;
    left: 16px;
    z-index: 200;
    background: var(--accent);
    color: #fff;
    padding: 8px 16px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.875rem;
}

.skip-link:focus {
    top: 8px;
}

/* === BREADCRUMBS === */
.breadcrumbs {
    padding: 12px 0 4px;
    font-size: 0.8125rem;
    color: var(--text-tertiary);
}

.breadcrumbs a {
    color: var(--text-secondary);
    text-decoration: none;
}

.breadcrumbs a:hover {
    color: var(--accent);
}

.breadcrumbs span {
    margin: 0 6px;
}

/* === TYPOGRAPHY === */
h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 8px;
    line-height: 1.2;
}

h2 {
    font-size: 1.375rem;
    font-weight: 600;
    margin-bottom: 12px;
    line-height: 1.3;
}

h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: 4px;
}

p {
    margin-bottom: 12px;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* === TOOL AREA === */
.tool-area {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin: 24px 0;
    box-shadow: var(--shadow);
}

/* === CONTROLS === */
.control {
    margin-bottom: 16px;
}

.control label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    font-size: 0.875rem;
    color: var(--text);
}

.control-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

input[type="text"],
input[type="email"],
input[type="date"],
textarea,
select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
    line-height: 1.5;
    transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.15);
}

textarea {
    resize: vertical;
    min-height: 120px;
}

select {
    cursor: pointer;
}

/* === INPUT ERROR === */
.input-error {
    border-color: var(--error) !important;
}

.error-message {
    color: var(--error);
    font-size: 0.8125rem;
    margin-top: 4px;
}

/* === BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9375rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background var(--transition), transform var(--transition);
    text-decoration: none;
    background: var(--accent);
    color: #fff;
}

.btn:hover {
    background: var(--accent-hover);
    text-decoration: none;
}

.btn:active {
    transform: scale(0.98);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border-light);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8125rem;
}

.btn-clear {
    gap: 4px;
}

.btn-copy {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-copy:hover {
    color: var(--accent);
}

.btn-copy.copied {
    color: var(--success);
}

/* === RESULT === */
.result {
    background: var(--bg-tool);
    border-radius: var(--radius-sm);
    padding: 16px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.9375rem;
    word-break: break-word;
    min-height: 48px;
}

.result:empty {
    display: none;
}

/* === DROPZONE === */
.dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px 24px;
    text-align: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
}

.dropzone:hover,
.dropzone.dragover {
    border-color: var(--accent);
    background: var(--accent-light);
}

.dropzone svg {
    margin-bottom: 12px;
    color: var(--text-tertiary);
}

/* === CONTENT SECTIONS === */
.content-section {
    margin: 32px 0;
}

.content-section h2 {
    margin-top: 0;
}

.content-section p {
    color: var(--text-secondary);
}

.content-section table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
}

.content-section th,
.content-section td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.9375rem;
}

.content-section th {
    font-weight: 600;
    color: var(--text);
    background: var(--bg-secondary);
}

.content-section td {
    color: var(--text-secondary);
}

/* === FAQ === */
.faq-item {
    border-bottom: 1px solid var(--border-light);
}

.faq-question {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 14px 0;
    background: none;
    border: none;
    font-size: 0.9375rem;
    font-weight: 500;
    font-family: inherit;
    color: var(--text);
    cursor: pointer;
    text-align: left;
    gap: 12px;
}

.faq-question:hover {
    color: var(--accent);
}

.faq-toggle {
    flex-shrink: 0;
    transition: transform var(--transition);
    color: var(--text-tertiary);
}

.faq-question.open .faq-toggle {
    transform: rotate(45deg);
}

.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.faq-answer.open {
    max-height: 500px;
    padding-bottom: 14px;
}

.faq-answer p {
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

/* === TOOLS GRID === */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 8px;
}

.tools-grid a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text);
    text-decoration: none;
    font-size: 0.875rem;
    transition: background var(--transition);
}

.tools-grid a:hover {
    background: var(--bg-secondary);
    text-decoration: none;
}

.tools-grid a.current {
    background: var(--accent-light);
    color: var(--accent);
}

.tools-grid--large a {
    flex-direction: column;
    align-items: flex-start;
    padding: 16px;
    border: 1px solid var(--border-light);
}

.tools-grid--large a strong {
    font-size: 0.9375rem;
}

.tools-grid--large a p {
    margin: 0;
    font-size: 0.8125rem;
}

/* === SHARE BAR === */
.share-bar {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    margin: 12px 0;
}

.btn-share {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-family: inherit;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}

.btn-share:hover {
    background: var(--bg-secondary);
    color: var(--text);
}

.btn-share--tg:hover { color: #0088cc; }
.btn-share--vk:hover { color: #4a76a8; }
.btn-share--copy:hover { color: var(--accent); }

/* === COUNTER === */
.usage-counter {
    font-size: 0.8125rem;
    color: var(--text-tertiary);
    margin-top: 8px;
}

/* === COOKIE CONSENT === */
.cookie-consent {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 150;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    background: var(--bg);
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.08);
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.cookie-consent p {
    margin: 0;
}

/* === AD SLOTS === */
.ad-slot {
    margin: 16px 0;
    min-height: 0;
}

/* === NOSCRIPT === */
.noscript-warning {
    padding: 24px;
    text-align: center;
    color: var(--text-secondary);
    background: var(--error-light);
    border-radius: var(--radius-sm);
}

/* === LOADING SPINNER === */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 32px;
    color: var(--text-secondary);
}

.loading-spinner::before {
    content: '';
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* === NEXT HINT === */
.next-hint {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    padding: 12px 16px;
    background: var(--accent-light);
    border-radius: var(--radius-sm);
}

/* === FRESHNESS BADGE === */
.freshness-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--success-light);
    color: var(--success);
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 500;
    margin: 8px 0;
}

/* === EMBED CODE === */
.embed-code {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    overflow-x: auto;
}

.embed-code code {
    flex: 1;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* === FOOTER === */
footer {
    margin-top: 48px;
    padding: 24px 0;
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--border-light);
    font-size: 0.8125rem;
    color: var(--text-tertiary);
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.footer-content a {
    color: var(--text-secondary);
}

.footer-nav {
    display: flex;
    gap: 16px;
}

.footer-nav a {
    color: var(--text-tertiary);
    text-decoration: none;
}

.footer-nav a:hover {
    color: var(--accent);
}

.footer-note {
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

/* === THEME TOGGLE === */
.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text);
    padding: 4px;
    display: flex;
    align-items: center;
}

.theme-toggle:hover {
    color: var(--accent);
}

[data-theme="dark"] .icon-sun,
:root:not([data-theme]) .icon-moon {
    display: none;
}

[data-theme="dark"] .icon-moon {
    display: block;
}

[data-theme="light"] .icon-moon {
    display: none;
}

[data-theme="light"] .icon-sun {
    display: block;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .icon-sun { display: none; }
    :root:not([data-theme="light"]) .icon-moon { display: block; }
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) .icon-moon { display: none; }
    :root:not([data-theme="dark"]) .icon-sun { display: block; }
}

/* === TOOL CARD (category pages) === */
.tool-card {
    text-decoration: none;
    color: var(--text);
    transition: background var(--transition), box-shadow var(--transition);
}

.tool-card:hover {
    box-shadow: var(--shadow);
    text-decoration: none;
}

/* === SHARE HINT === */
.share-hint {
    min-height: 1.2em;
}

/* === UTILITIES === */
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.hidden { display: none; }
.text-sm { font-size: 0.8125rem; }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }

/* === CHECKBOX & RADIO === */
input[type="checkbox"],
input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
    vertical-align: middle;
    margin-right: 6px;
}

/* === RANGE INPUT === */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid var(--bg);
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid var(--bg);
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

input[type="range"]:focus-visible::-webkit-slider-thumb {
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.3);
}

/* === COLOR INPUT === */
input[type="color"] {
    -webkit-appearance: none;
    appearance: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    padding: 2px;
    background: var(--bg);
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 4px;
}

/* === MOBILE === */
@media (max-width: 600px) {
    h1 { font-size: 1.375rem; }
    h2 { font-size: 1.125rem; }

    .container {
        padding-left: max(20px, env(safe-area-inset-left));
        padding-right: max(20px, env(safe-area-inset-right));
    }

    .tool-area { padding: 16px; margin: 16px 0; }

    .header-nav a + a:not(:last-of-type) {
        display: none;
    }

    .control-row {
        flex-direction: column;
        align-items: stretch;
    }

    .tools-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }

    .content-section {
        margin: 24px 0;
    }

    .content-section table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .footer-content {
        flex-direction: column;
        text-align: center;
    }

    .share-bar {
        justify-content: center;
    }

    .cookie-consent {
        flex-direction: column;
        text-align: center;
        gap: 8px;
    }

    .embed-code {
        flex-direction: column;
    }

    .embed-code code {
        white-space: pre-wrap;
        word-break: break-all;
    }

    .result {
        font-size: 0.8125rem;
        padding: 12px;
    }

    .faq-question {
        font-size: 0.875rem;
    }
}

/* === PRINT === */
@media print {
    .header,
    footer,
    .tools-grid,
    .other-tools,
    .share-bar,
    .ad-slot,
    .cookie-consent,
    .skip-link,
    .theme-toggle,
    .breadcrumbs,
    .btn-clear,
    .next-hint,
    .embed-code {
        display: none !important;
    }

    body {
        background: #fff;
        color: #000;
    }

    .tool-area {
        border: 1px solid #ccc;
        box-shadow: none;
    }

    a { color: #000; text-decoration: underline; }
    a::after { content: " (" attr(href) ")"; font-size: 0.75rem; }
}

/* === ACCESSIBILITY === */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* === REDUCED MOTION === */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
