/* ============================================================
   style.css — md2plain Pro Studio
   ============================================================ */

/* ── Reset & Variables ── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-body: #060810;
    --bg-surface: #0c1018;
    --bg-elevated: #131924;
    --bg-hover: #1a2233;
    --border: #1c2438;
    --border-focus: #0fd694;
    --text-1: #eaeff8;
    --text-2: #7b8aa3;
    --text-3: #4a5568;
    --accent: #0fd694;
    --accent-hover: #0bba80;
    --accent-soft: rgba(15, 214, 148, 0.08);
    --accent-glow: rgba(15, 214, 148, 0.25);
    --danger: #f59e0b;
    --danger-soft: rgba(245, 158, 11, 0.1);
    --radius-sm: 0.6rem;
    --radius-md: 1rem;
    --radius-lg: 1.4rem;
    --radius-xl: 1.8rem;
    --shadow-card: 0 8px 30px -12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 20px 50px -15px rgba(0, 0, 0, 0.5);
    --font-ui: 'DM Sans', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
    --transition: 0.2s cubic-bezier(0.2, 0.9, 0.4, 1);
}

body.light {
    --bg-body: #f3f5fa;
    --bg-surface: #ffffff;
    --bg-elevated: #edf0f7;
    --bg-hover: #e2e7f0;
    --border: #d5dce8;
    --border-focus: #059669;
    --text-1: #0d1320;
    --text-2: #505d73;
    --text-3: #8895a8;
    --accent: #059669;
    --accent-hover: #047857;
    --accent-soft: #ecfdf5;
    --accent-glow: rgba(5, 150, 105, 0.2);
    --danger: #d97706;
    --danger-soft: rgba(217, 119, 6, 0.08);
    --shadow-card: 0 8px 30px -12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 20px 50px -15px rgba(0, 0, 0, 0.1);
}

/* ── Base ── */
body {
    background: var(--bg-body);
    color: var(--text-1);
    font-family: var(--font-ui);
    line-height: 1.6;
    transition: background 0.3s, color 0.3s;
    overflow-x: hidden;
}

/* Ad container styles for recommended slots */
.adsense-slot {
    max-width: 1100px;
    margin: 1.2rem auto;
    padding: 0.4rem 0;
    text-align: center;
}

.adsense-slot ins {
    display: inline-block !important;
    width: 100% !important;
    min-height: 60px;
}

.adsense-slot[data-testid="ad-header"] {
    margin-top: 0.8rem;
}

.adsense-slot[data-testid="ad-footer"] {
    margin-bottom: 1.2rem;
}

/* Small visible placeholder when ads are blocked (optional) */
.ads-fallback {
    display: none;
    margin: 0.6rem auto;
    padding: 0.8rem 1rem;
    background: var(--bg-elevated);
    color: var(--text-2);
    border: 1px dashed var(--border);
    border-radius: 8px;
    font-weight: 600;
}

.content-section {
    max-width: 980px;
    margin: 1.8rem auto;
    padding: 1.4rem 1.6rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
}

.content-section p {
    margin-bottom: 1rem;
    color: var(--text-2);
}

.brand-name {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.4px;
    color: var(--text-1);
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--accent-hover);
}

/* ── RTL — applies only inside text fields ── */
.text-rtl {
    direction: rtl;
    text-align: right;
}

/* ── Skip Link ── */
.skip-link {
    position: absolute;
    top: -100%;
    left: 1rem;
    background: var(--accent);
    color: #060810;
    padding: 0.6rem 1.4rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    z-index: 9999;
    transition: top 0.2s;
}

.skip-link:focus {
    top: 1rem;
}

/* ── Background Atmosphere ── */
.bg-blob {
    position: fixed;
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
    filter: blur(130px);
    will-change: transform;
}

.bg-blob-1 {
    width: 650px;
    height: 650px;
    background: radial-gradient(circle, rgba(15, 214, 148, 0.1) 0%, transparent 70%);
    top: -250px;
    right: -150px;
    animation: drift1 22s ease-in-out infinite;
}

.bg-blob-2 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(6, 182, 212, 0.06) 0%, transparent 70%);
    bottom: -180px;
    left: -120px;
    animation: drift2 28s ease-in-out infinite;
}

body.light .bg-blob-1 {
    background: radial-gradient(circle, rgba(5, 150, 105, 0.06) 0%, transparent 70%);
}

body.light .bg-blob-2 {
    background: radial-gradient(circle, rgba(6, 182, 212, 0.04) 0%, transparent 70%);
}

@keyframes drift1 {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    50% {
        transform: translate(-40px, 30px) scale(1.08);
    }
}

@keyframes drift2 {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    50% {
        transform: translate(30px, -25px) scale(1.05);
    }
}

/* ── Layout ── */
.app-wrap {
    position: relative;
    z-index: 1;
    max-width: 1480px;
    margin: 0 auto;
    padding: 1.6rem 1.8rem 3rem;
}

/* ── Header ── */
.top-bar {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 0.85rem 1.6rem;
    margin-bottom: 1.8rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.8rem;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(12px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    flex-shrink: 0;
}

.brand-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #0fd694, #06b6d4);
    display: grid;
    place-items: center;
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 1.1rem;
    color: #060810;
    flex-shrink: 0;
}

.brand h1 {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.4px;
    color: var(--text-1);
}

.brand-tag {
    font-size: 0.65rem;
    font-weight: 600;
    background: var(--accent-soft);
    color: var(--accent);
    padding: 0.15rem 0.65rem;
    border-radius: 40px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.ctrl-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

/* ── Buttons & Selects ── */
.btn,
.sel-wrap select {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-1);
    font-family: var(--font-ui);
    font-size: 0.8rem;
    font-weight: 550;
    padding: 0.5rem 0.95rem;
    border-radius: 40px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: all var(--transition);
    white-space: nowrap;
    line-height: 1.3;
}

.btn:hover,
.sel-wrap select:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #060810;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px -4px var(--accent-glow);
}

.btn:focus-visible,
.sel-wrap select:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.btn:active {
    transform: translateY(0);
}

.sel-wrap {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 40px;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0 0.2rem 0 0.65rem;
    transition: all var(--transition);
}

.sel-wrap:hover {
    border-color: var(--accent);
}

.sel-wrap select {
    border: none;
    background: transparent;
    padding: 0.5rem 0.6rem 0.5rem 0.2rem;
    border-radius: 0;
    box-shadow: none;
}

.sel-wrap select:hover {
    background: transparent;
    color: var(--text-1);
    transform: none;
    box-shadow: none;
}

.sel-label {
    font-size: 0.75rem;
    color: var(--text-2);
}

/* ── Hero ── */
.hero {
    text-align: center;
    margin-bottom: 2rem;
    animation: fadeUp 0.5s ease-out both;
}

.hero h1 {
    font-size: clamp(1.6rem, 3.5vw, 2.4rem);
    font-weight: 700;
    letter-spacing: -0.5px;
    line-height: 1.2;
    margin-bottom: 0.5rem;
}

.hero h1 span {
    color: var(--accent);
}

.hero p {
    font-size: 1rem;
    color: var(--text-2);
    max-width: 620px;
    margin: 0 auto;
    line-height: 1.5;
}

/* ── Converter Grid ── */
.panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.panel {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-card);
    transition: box-shadow 0.3s, transform 0.3s;
    animation: fadeUp 0.5s ease-out both;
    position: relative;
}

.panel:nth-child(2) {
    animation-delay: 0.08s;
}

.panel:hover {
    box-shadow: var(--shadow-lg);
}

.panel-head {
    padding: 0.9rem 1.3rem;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.panel-title {
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    animation: pulse 2s ease-in-out infinite;
}

.pill {
    font-size: 0.65rem;
    font-weight: 500;
    background: var(--accent-soft);
    color: var(--accent);
    padding: 0.15rem 0.6rem;
    border-radius: 20px;
}

.panel-body {
    padding: 1.2rem;
    position: relative;
}

/* ── Textarea & Editable Output ── */
textarea,
.plain-view {
    width: 100%;
    min-height: 420px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.1rem;
    font-size: 0.9rem;
    line-height: 1.65;
    color: var(--text-1);
    resize: vertical;
    transition: border-color var(--transition), box-shadow var(--transition);
    word-break: break-word;
    overflow-wrap: break-word;
}

textarea {
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

textarea:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-soft);
    outline: none;
}

.plain-view {
    font-family: var(--font-ui);
    white-space: pre-wrap;
    overflow-y: auto;
    cursor: text;
    outline: none;
}

.plain-view:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.plain-view.empty {
    color: var(--text-3);
    font-style: italic;
}

/* ── Drop Overlay ── */
.drop-overlay {
    position: absolute;
    inset: 1.2rem;
    background: var(--accent-soft);
    border: 2px dashed var(--accent);
    border-radius: var(--radius-lg);
    display: grid;
    place-items: center;
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 10;
}

.drop-overlay.visible {
    opacity: 1;
}

/* ── Panel Actions ── */
.panel-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 0.8rem;
    flex-wrap: wrap;
}

.btn-sm {
    font-size: 0.75rem;
    padding: 0.4rem 0.8rem;
}

/* ── Stats Bar ── */
.stats-bar {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0.75rem 1.4rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.2rem 2rem;
    font-size: 0.78rem;
    color: var(--text-2);
    margin-bottom: 3rem;
    animation: fadeUp 0.5s ease-out 0.16s both;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.stat-val {
    color: var(--text-1);
    font-weight: 600;
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.stat-accent {
    color: var(--accent);
}

.stat-divider {
    width: 1px;
    height: 16px;
    background: var(--border);
}

/* ── Features ── */
.section-heading {
    text-align: center;
    margin-bottom: 2rem;
}

.section-heading h2 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.3px;
    margin-bottom: 0.35rem;
}

.section-heading p {
    font-size: 0.9rem;
    color: var(--text-2);
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 3rem;
}

.feat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.2rem 1.3rem;
    transition: all var(--transition);
}

.feat-card:hover {
    border-color: var(--accent);
    transform: translateY(-3px);
    box-shadow: 0 12px 30px -10px rgba(0, 0, 0, 0.2);
}

.feat-icon {
    width: 44px;
    height: 44px;
    background: var(--accent-soft);
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-size: 1.3rem;
    margin-bottom: 0.6rem;
}

.feat-card h3 {
    font-size: 0.9rem;
    font-weight: 650;
    margin-bottom: 0.3rem;
}

.feat-card p {
    font-size: 0.8rem;
    color: var(--text-2);
    line-height: 1.5;
}

/* ── How To ── */
.howto-steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.2rem;
    margin-bottom: 3rem;
    counter-reset: step;
}

.step-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.3rem 1.4rem;
    position: relative;
    counter-increment: step;
}

.step-card::before {
    content: counter(step);
    position: absolute;
    top: -10px;
    left: 1.2rem;
    background: var(--accent);
    color: #060810;
    font-size: 0.7rem;
    font-weight: 700;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: grid;
    place-items: center;
}

.step-card h3 {
    font-size: 0.9rem;
    font-weight: 650;
    margin-top: 0.3rem;
    margin-bottom: 0.25rem;
}

.step-card p {
    font-size: 0.8rem;
    color: var(--text-2);
    line-height: 1.5;
}

/* ── FAQ ── */
.faq-list {
    max-width: 680px;
    margin: 0 auto 3rem;
}

.faq-item {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 0.6rem;
    overflow: hidden;
}

.faq-q {
    width: 100%;
    background: none;
    border: none;
    color: var(--text-1);
    font-family: var(--font-ui);
    font-size: 0.9rem;
    font-weight: 600;
    padding: 1rem 1.3rem;
    text-align: left;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background var(--transition);
}

.faq-q:hover {
    background: var(--bg-elevated);
}

.faq-q::after {
    content: '+';
    font-size: 1.2rem;
    color: var(--text-3);
    transition: transform 0.3s;
    flex-shrink: 0;
    margin-left: 0.8rem;
}

.faq-item.open .faq-q::after {
    transform: rotate(45deg);
}

.faq-a {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease, padding 0.35s ease;
    padding: 0 1.3rem;
    font-size: 0.85rem;
    color: var(--text-2);
    line-height: 1.6;
}

.faq-item.open .faq-a {
    max-height: 200px;
    padding: 0 1.3rem 1rem;
}

/* ── Footer ── */
footer {
    border-top: 1px solid var(--border);
    padding: 1.5rem 0;
    text-align: center;
    font-size: 0.78rem;
    color: var(--text-3);
}

footer a {
    color: var(--text-2);
}

footer strong {
    color: var(--text-2);
    font-weight: 600;
}

.footer-keys {
    margin-top: 0.4rem;
}

kbd {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.1rem 0.4rem;
    font-family: var(--font-mono);
    font-size: 0.7rem;
}

/* ── Toast ── */
.toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-surface);
    border: 1px solid var(--accent);
    color: var(--text-1);
    padding: 0.65rem 1.4rem;
    border-radius: 40px;
    font-size: 0.82rem;
    font-weight: 500;
    backdrop-filter: blur(16px);
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s, transform 0.25s;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.error {
    border-color: var(--danger);
}

/* ── Animations ── */
@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(18px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(0.85);
    }
}

@keyframes flashBorder {
    0% {
        border-color: var(--accent);
    }

    100% {
        border-color: var(--border);
    }
}

.flash-update {
    animation: flashBorder 0.6s ease-out;
}

/* ── Hidden File Input ── */
.file-input-hidden {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    pointer-events: none;
}

/* ── Responsive ── */
@media (max-width: 860px) {
    .app-wrap {
        padding: 1rem;
    }

    .panels {
        grid-template-columns: 1fr;
        gap: 1.2rem;
    }

    .top-bar {
        flex-direction: column;
        align-items: stretch;
        border-radius: var(--radius-lg);
    }

    .ctrl-group {
        justify-content: center;
    }

    textarea,
    .plain-view {
        min-height: 280px;
    }

    .stats-bar {
        gap: 0.6rem 1rem;
        font-size: 0.72rem;
    }

    .stat-divider {
        display: none;
    }
}

@media (max-width: 480px) {
    .hero h1 {
        font-size: 1.35rem;
    }

    .ctrl-group {
        gap: 0.35rem;
    }

    .btn,
    .sel-wrap select {
        font-size: 0.72rem;
        padding: 0.4rem 0.7rem;
    }

    .sel-label {
        display: none;
    }
}

/* ── Print ── */
@media print {

    .top-bar,
    .panel-actions,
    .stats-bar,
    .features-section,
    .howto-section,
    .faq-section,
    footer,
    .bg-blob,
    .skip-link,
    .drop-overlay {
        display: none !important;
    }

    body {
        background: #fff;
        color: #000;
        padding: 0;
    }

    .panels {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .panel {
        border: 1px solid #ccc;
        box-shadow: none;
        break-inside: avoid;
        border-radius: 0;
    }

    .panel-head {
        background: #f5f5f5;
    }

    textarea,
    .plain-view {
        border: 1px solid #ddd;
        min-height: auto;
    }
}

/* ── Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}