*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    background-color: #f3f5f9;
    color: #0f172a;
    font-family: "Inter", "Segoe UI", "Ubuntu", -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 13px;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

.hidden {
    display: none !important;
}

.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    height: 100vh;
    height: 100dvh;
    background-color: #f3f5f9;
}

/* Header Bar */
.header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background-color: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    padding: 9px 18px;
    flex-shrink: 0;
}

.header-title-col {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.app-title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.25;
}

.app-subtitle {
    margin: 0;
    font-size: 12px;
    color: #64748b;
    line-height: 1.3;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.github-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    background-color: #0f172a;
    border-color: #0f172a;
    color: #ffffff;
}

.github-btn:hover {
    background-color: #1e293b;
    border-color: #1e293b;
}

.github-icon {
    flex-shrink: 0;
}

/* Body */
.app-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 10px 14px;
    gap: 10px;
    min-height: 0;
}

/* Type Selector Bar */
.type-selector {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    flex-shrink: 0;
}

.type-btn {
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 9px;
    padding: 7px 14px;
    min-height: 34px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.type-btn:hover {
    background-color: #f8fafc;
    border-color: #cbd5e1;
    color: #0f172a;
}

.type-btn.active {
    background-color: #ecfdf5;
    border: 1.5px solid #10b981;
    color: #047857;
}

/* Content Row (3:2 split matching PyQt6 layout) */
.content-row {
    flex: 1;
    display: flex;
    gap: 14px;
    min-height: 0;
}

.card {
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.form-card {
    flex: 3;
    padding: 4px;
    min-width: 0;
}

.form-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
}

.form-pane {
    display: none;
}

.form-pane.active {
    display: block;
}

.preview-card {
    flex: 2;
    min-width: 430px;
    max-width: 520px;
    padding: 10px 12px;
    gap: 5px;
}

.preview-card-title {
    flex-shrink: 0;
}

.preview-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-shrink: 0;
}

.mobile-form-bar {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 14px 4px;
    border-bottom: 1px solid #f1f5f9;
}

.mobile-type-bar {
    display: none;
}

.mobile-only-btn {
    display: none;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    padding: 4px 10px;
}

.preview-scroll {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 0 2px 2px 0;
    min-height: 0;
}

/* Typography & Labels */
.section-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #0f172a;
    line-height: 1.3;
}

.field-label {
    font-size: 12px;
    font-weight: 600;
    color: #334155;
    display: inline-block;
}

.hint-label {
    margin: 0;
    font-size: 11px;
    color: #64748b;
    line-height: 1.35;
}

.req {
    color: #dc2626;
}

/* Form Layout Helpers */
.form-stack-v {
    display: flex;
    flex-direction: column;
}

.gap-10 {
    gap: 10px;
}

.gap-12 {
    gap: 12px;
}

.gap-14 {
    gap: 14px;
}

.field-block {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

/* Inputs, Selects, Textareas */
.input-control,
.select-control,
.textarea-control {
    width: 100%;
    background-color: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    padding: 3px 9px;
    min-height: 28px;
    color: #0f172a;
    font-family: inherit;
    font-size: 13px;
    outline: none;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.input-control,
.select-control {
    height: 28px;
}

.input-control::placeholder,
.textarea-control::placeholder {
    color: #94a3b8;
}

.input-control:focus,
.select-control:focus,
.textarea-control:focus {
    border-color: #10b981;
    box-shadow: 0 0 0 1px #10b981;
}

.input-control:disabled {
    background-color: #f8fafc;
    color: #94a3b8;
    cursor: not-allowed;
}

.textarea-control {
    border-radius: 8px;
    padding: 8px 10px;
    resize: vertical;
}

.plain-textarea {
    min-height: 170px;
}

.raw-textarea {
    min-height: 150px;
}

.email-textarea {
    min-height: 84px;
    max-height: 120px;
}

.sms-textarea {
    min-height: 96px;
    max-height: 130px;
}

.input-with-suffix {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-suffix .input-control {
    padding-right: 28px;
}

.input-suffix {
    position: absolute;
    right: 9px;
    font-size: 12px;
    color: #64748b;
    pointer-events: none;
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #1e293b;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #10b981;
    cursor: pointer;
    margin: 0;
}

/* Buttons */
.btn-primary {
    background-color: #10b981;
    border: none;
    border-radius: 8px;
    color: #ffffff;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    padding: 8px 14px;
    min-height: 36px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 0.12s ease;
}

.btn-primary:hover:not(:disabled) {
    background-color: #059669;
}

.btn-primary:disabled {
    background-color: #cbd5e1;
    color: #64748b;
    cursor: not-allowed;
}

.btn-secondary {
    background-color: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    color: #1e293b;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    padding: 4px 10px;
    min-height: 28px;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.12s ease;
}

.btn-secondary:hover {
    background-color: #e2e8f0;
}

/* Contact Form Specifics */
.contact-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.contact-title-box {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.contact-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 8px 12px;
}

.contact-initials {
    width: 46px;
    height: 46px;
    border-radius: 8px;
    background-color: #dbeafe;
    color: #1d4ed8;
    font-size: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.contact-badge-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.contact-badge-name {
    font-weight: 700;
    color: #0f172a;
    font-size: 13px;
}

.contact-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 12px;
}

.urls-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 2px;
}

.urls-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.url-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.url-row .input-control {
    flex: 1;
}

.remove-url-btn {
    width: 34px;
    padding: 4px 0;
    text-align: center;
}

/* Social Form Specifics */
.social-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.social-btn {
    width: 46px;
    height: 46px;
    background-color: #ffffff;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-family: inherit;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.12s ease, background-color 0.12s ease;
}

.social-btn:hover {
    border-color: #94a3b8;
    background-color: #f8fafc;
}

.social-btn.active {
    border: 2px solid #10b981;
    background-color: #ecfdf5;
}

/* Custom Sub-pages */
.custom-subpane {
    display: none;
}

.custom-subpane.active {
    display: block;
}

.split-row-1-2 {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 10px;
}

.split-row-equal {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* Preview Panel */
.preview-frame {
    position: relative;
    flex: 1 1 140px;
    min-height: 120px;
    max-height: 220px;
    background-color: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 12px;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.qr-preview-canvas {
    position: absolute;
    inset: 0;
    margin: auto;
    max-width: calc(100% - 14px);
    max-height: calc(100% - 14px);
    width: auto;
    height: auto;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    border-radius: 4px;
}

.preview-placeholder {
    margin: 0;
    color: #64748b;
    font-size: 13px;
    text-align: center;
    padding: 0 12px;
}

/* Status Banner */
.status-banner {
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 12px;
    word-break: break-word;
    flex-shrink: 0;
}

.status-banner.error {
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
}

.status-banner.success {
    background-color: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #047857;
}

/* Export Grid */
.export-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 3px 8px;
    flex-shrink: 0;
}

/* Colors & Margin Row */
.style-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
    align-items: center;
    flex-shrink: 0;
}

.preview-scroll > .field-block {
    flex-shrink: 0;
}

.color-btn-wrap {
    position: relative;
    display: block;
    cursor: pointer;
}

.hidden-color-input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

.color-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    font-size: 12px;
    padding: 4px 8px;
}

.color-swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    border: 1px solid #94a3b8;
    flex-shrink: 0;
}

.margin-input-wrap {
    display: flex;
    align-items: center;
    background-color: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    padding: 0 8px;
    min-height: 28px;
    gap: 4px;
}

.margin-input-wrap:focus-within {
    border-color: #10b981;
    box-shadow: 0 0 0 1px #10b981;
}

.margin-prefix {
    font-size: 12px;
    color: #334155;
    white-space: nowrap;
}

.margin-number {
    width: 100%;
    border: none;
    outline: none;
    background: transparent;
    color: #0f172a;
    font-family: inherit;
    font-size: 13px;
    padding: 2px 0;
}

.inline-action-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.inline-action-row .input-control {
    flex: 1;
}

.target-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 1px;
    flex-shrink: 0;
}

.target-hint {
    text-align: right;
}

.preview-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.preview-actions .btn-primary {
    flex: 1;
}

.copy-action-btn {
    min-height: 36px;
    padding: 0 14px;
    border-radius: 8px;
}

/* Status Bar */
.status-bar {
    background-color: #ffffff;
    color: #475569;
    border-top: 1px solid #e2e8f0;
    padding: 4px 14px;
    font-size: 12px;
    flex-shrink: 0;
}

/* Below-the-fold SEO Features & FAQ Section */
.seo-section {
    background-color: #f3f5f9;
    padding: 18px 14px 32px;
    border-top: 1px solid #e2e8f0;
}

.seo-container {
    max-width: 1180px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.seo-card {
    padding: 18px 20px;
    gap: 12px;
}

.seo-heading {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
}

.seo-lead {
    margin: 0;
    font-size: 13px;
    color: #334155;
    line-height: 1.55;
}

.seo-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.seo-feature {
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px 14px;
}

.seo-feature h3 {
    margin: 0 0 4px;
    font-size: 13px;
    font-weight: 600;
    color: #0f172a;
}

.seo-feature p {
    margin: 0;
    font-size: 12px;
    color: #475569;
    line-height: 1.5;
}

.seo-feature code {
    background-color: #e2e8f0;
    color: #0f172a;
    padding: 1px 4px;
    border-radius: 4px;
    font-size: 11px;
}

.faq-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.faq-item {
    border: 1px solid #e2e8f0;
    border-radius: 9px;
    background-color: #f8fafc;
    padding: 10px 14px;
}

.faq-item summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    color: #0f172a;
}

.faq-item p {
    margin: 8px 0 0;
    font-size: 12px;
    color: #475569;
    line-height: 1.55;
}

/* Responsive adjustments for smaller laptops, tablets, and mobile phones */
@media (max-width: 1120px) {
    .preview-card {
        min-width: 360px;
    }
}

@media (max-width: 980px) {
    .app-shell {
        height: auto;
        min-height: 100vh;
        min-height: 100dvh;
    }

    .type-selector {
        display: none;
    }

    .mobile-type-bar {
        display: flex;
        align-items: center;
        gap: 10px;
        position: sticky;
        top: 0;
        z-index: 20;
        background-color: #f3f5f9;
        padding: 6px 0;
        margin: -6px 0 0 0;
    }

    .mobile-type-label {
        font-size: 12px;
        font-weight: 700;
        color: #334155;
        white-space: nowrap;
    }

    .mobile-type-select {
        flex: 1;
        background-color: #ecfdf5;
        border: 1.5px solid #10b981;
        color: #047857;
        font-weight: 600;
        min-height: 40px;
        height: 40px;
    }

    .mobile-form-bar,
    .mobile-only-btn {
        display: inline-flex;
    }

    .mobile-form-bar {
        display: flex;
    }

    .content-row {
        flex-direction: column;
        gap: 12px;
    }

    .preview-card {
        min-width: 0;
        max-width: none;
        padding: 14px;
        gap: 10px;
    }

    .form-scroll,
    .preview-scroll {
        overflow-y: visible;
    }

    .form-card,
    .preview-card {
        scroll-margin-top: 56px;
    }

    .preview-frame {
        min-height: 220px;
        max-height: 260px;
    }

    .qr-preview-canvas {
        max-height: 236px;
    }
}

@media (max-width: 768px) {
    /* Prevent iOS Safari zoom on input focus and improve touch target sizing */
    .input-control,
    .select-control,
    .textarea-control,
    .margin-number {
        font-size: 16px;
    }

    .input-control,
    .select-control {
        height: 38px;
        min-height: 38px;
    }

    .margin-input-wrap,
    .color-btn,
    .btn-secondary {
        min-height: 38px;
    }

    .btn-primary,
    .copy-action-btn {
        min-height: 44px;
        font-size: 14px;
    }

    .social-btn {
        width: 48px;
        height: 48px;
    }
}

@media (max-width: 640px) {
    .app-body {
        padding: 8px 10px 14px;
    }

    .header-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 10px 12px;
    }

    .header-actions {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .header-actions .btn-secondary {
        justify-content: center;
        text-align: center;
        padding: 6px 8px;
        font-size: 12px;
        white-space: normal;
        line-height: 1.2;
    }

    .form-scroll {
        padding: 12px;
    }

    .contact-grid,
    .export-grid,
    .split-row-1-2,
    .split-row-equal {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .style-row {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .margin-input-wrap {
        grid-column: 1 / -1;
    }

    .contact-badge {
        width: 100%;
    }

    .target-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }

    .status-bar {
        padding: 6px 12px;
    }

    .seo-section {
        padding: 14px 10px 24px;
    }

    .seo-card {
        padding: 14px;
    }

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