/* ===== Tool Navigation ===== */
.tool-nav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 12px 0;
    position: sticky;
    top: 60px;
    z-index: 40;
    backdrop-filter: blur(12px);
    background: rgba(255, 255, 255, 0.85);
}

.tool-nav .container {
    display: flex;
    align-items: center;
    gap: 20px;
}

.tool-nav-back {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}

.tool-nav-back:hover {
    color: var(--primary);
}

.tool-nav-title {
    font-weight: 600;
    color: var(--text);
    font-size: 0.9rem;
}

/* ===== Calculator ===== */
.calculator-wrapper {
    padding: 24px 0 60px;
}

.calc-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 28px;
}

.calc-icon {
    width: 56px;
    height: 56px;
    background: var(--primary-light);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 1px solid var(--border);
    color: var(--primary);
}

.calc-icon svg {
    width: 28px;
    height: 28px;
}

.calc-header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.calc-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.calc-grid {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 32px;
    align-items: start;
}

@media (max-width: 1024px) {
    .calc-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== Form ===== */
.calc-form {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    position: sticky;
    top: 140px;
}

@media (max-width: 1024px) {
    .calc-form {
        position: static;
    }
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 5px;
    color: var(--text);
}

.form-group textarea,
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="number"],
.form-group select {
    width: 100%;
    padding: 10px 14px;
    font-size: 0.95rem;
    font-family: inherit;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    transition: var(--transition);
    outline: none;
    color: var(--text);
}

.form-group input[type="number"] {
    width: 100%;
    padding: 8px 10px;
    font-size: 0.9rem;
    border: 1.5px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
}

.form-group textarea:focus,
.form-group input:focus,
.form-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

/* File Upload */
.file-upload-area {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 24px 20px;
    text-align: center;
    background: var(--bg);
    transition: var(--transition);
    cursor: pointer;
}

.file-upload-area:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.file-upload-area.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.file-upload-area input[type="file"] {
    display: none;
}

.file-upload-area .upload-icon {
    display: flex;
    justify-content: center;
    margin-bottom: 6px;
    color: var(--primary);
}

.file-upload-area .upload-text {
    color: var(--text-secondary);
    font-weight: 500;
}

.file-upload-area .upload-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.file-name-badge {
    display: inline-block;
    background: var(--primary-light);
    color: var(--primary);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-top: 8px;
}

/* Settings */
.settings-group {
    background: var(--bg);
    border-radius: 10px;
    padding: 14px 16px;
    margin: 14px 0;
    border: 1px solid var(--border);
}

.settings-group h4 {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.settings-row {
    margin-bottom: 10px;
}

.settings-row:last-child {
    margin-bottom: 0;
}

.settings-row label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.settings-row select {
    width: 100%;
    padding: 8px 12px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text);
}

.settings-row select:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

/* Buttons */
.calc-btn {
    width: 100%;
    padding: 12px;
    font-size: 0.95rem;
    font-weight: 700;
    font-family: inherit;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.25);
}

.calc-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(37, 99, 235, 0.35);
}

.calc-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none;
}

.calc-btn.secondary {
    background: var(--bg);
    color: var(--text);
    box-shadow: none;
    border: 1.5px solid var(--border);
}

.calc-btn.secondary:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.1);
}

/* ===== Results ===== */
.calc-results {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.qr-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 320px;
}

.image-container {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
}

.drop-zone-placeholder {
    color: var(--text-muted);
    text-align: center;
    padding: 40px 20px;
}

.image-wrapper {
    position: relative;
    display: inline-block;
    max-width: 100%;
    max-height: 500px;
    overflow: hidden;
    user-select: none;
}

.image-wrapper img {
    display: block;
    max-width: 100%;
    max-height: 500px;
    width: auto;
    height: auto;
}

/* ===== CROP BOX ===== */
.crop-box {
    position: absolute;
    border: 2px solid rgba(255, 255, 255, 0.95);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45);
    cursor: move;
    pointer-events: auto;
    z-index: 5;
}

.crop-box::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 28px;
    height: 28px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    pointer-events: none;
}

/* ===== CROP HANDLES - внутри crop box ===== */
.crop-handle {
    position: absolute;
    width: 16px;
    height: 16px;
    background: #ffffff;
    border: 2.5px solid var(--primary, #2563eb);
    border-radius: 50%;
    z-index: 10;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
    pointer-events: auto;
    transition: transform 0.12s ease;
}

.crop-handle:hover {
    transform: scale(1.25);
    box-shadow: 0 2px 14px rgba(0, 0, 0, 0.45);
}

/* Corners - positioned on crop box edges */
.crop-handle-nw {
    top: -8px;
    left: -8px;
    cursor: nw-resize;
}
.crop-handle-ne {
    top: -8px;
    right: -8px;
    cursor: ne-resize;
}
.crop-handle-sw {
    bottom: -8px;
    left: -8px;
    cursor: sw-resize;
}
.crop-handle-se {
    bottom: -8px;
    right: -8px;
    cursor: se-resize;
}

/* Edges - centered on each side */
.crop-handle-n {
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    cursor: n-resize;
}
.crop-handle-s {
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    cursor: s-resize;
}
.crop-handle-w {
    top: 50%;
    left: -8px;
    transform: translateY(-50%);
    cursor: w-resize;
}
.crop-handle-e {
    top: 50%;
    right: -8px;
    transform: translateY(-50%);
    cursor: e-resize;
}

/* Hover states for centered handles */
.crop-handle-n:hover,
.crop-handle-s:hover {
    transform: translateX(-50%) scale(1.25);
}
.crop-handle-w:hover,
.crop-handle-e:hover {
    transform: translateY(-50%) scale(1.25);
}

/* ===== Info ===== */
.qr-info {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
}

.qr-info h4 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 10px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    border-bottom: 1px solid var(--border);
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.info-value {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
    text-align: right;
    max-width: 60%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Tips */
.examples-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
}

.examples-container h4 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 10px;
}

.example-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tip-badge {
    padding: 5px 14px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--bg);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* ===== SEO Content ===== */
.seo-content {
    margin-top: 50px;
    padding-top: 40px;
    border-top: 1px solid var(--border);
}

.seo-inner {
    max-width: 760px;
}

.seo-content h2 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text);
    letter-spacing: -0.02em;
}

.seo-content h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 24px;
    margin-bottom: 10px;
    color: var(--text);
}

.seo-content h4 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-top: 16px;
    margin-bottom: 6px;
    color: var(--text);
}

.seo-content p {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.8;
    margin-bottom: 14px;
}

.seo-content ul {
    list-style: none;
    padding: 0;
    margin-bottom: 16px;
}

.seo-content ul li {
    font-size: 0.92rem;
    color: var(--text-secondary);
    line-height: 1.7;
    padding: 4px 0 4px 24px;
    position: relative;
}

.seo-content ul li::before {
    content: '—';
    position: absolute;
    left: 0;
    color: var(--primary);
    font-weight: 600;
}

.seo-content strong {
    color: var(--text);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .calc-header {
        flex-direction: column;
        text-align: center;
    }

    .calc-header h1 {
        font-size: 1.4rem;
    }

    .calc-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .calculator-wrapper {
        padding: 16px 0 40px;
    }

    .calc-form {
        padding: 16px;
    }

    .qr-container {
        padding: 16px;
        min-height: 200px;
    }

    .image-wrapper {
        max-height: 300px;
    }

    .image-wrapper img {
        max-height: 300px;
    }

    .crop-handle {
        width: 14px;
        height: 14px;
    }
    .crop-handle-nw,
    .crop-handle-ne,
    .crop-handle-sw,
    .crop-handle-se {
        top: -7px;
        left: -7px;
        right: -7px;
        bottom: -7px;
    }
    .crop-handle-n,
    .crop-handle-s {
        top: -7px;
        bottom: -7px;
    }
    .crop-handle-w,
    .crop-handle-e {
        left: -7px;
        right: -7px;
    }

    .seo-content {
        margin-top: 30px;
        padding-top: 24px;
    }

    .seo-content h2 {
        font-size: 1.2rem;
    }

    .seo-content h3 {
        font-size: 1rem;
    }

    .seo-content p,
    .seo-content ul li {
        font-size: 0.88rem;
    }

    .info-value {
        max-width: 50%;
        font-size: 0.7rem;
    }
    
    .tip-badge {
        font-size: 0.7rem;
        padding: 4px 10px;
    }
}