/* Explain: Styling for reusable UI components like buttons, cards, and forms. */
/* ---------- Buttons ---------- */
.btn-primary, .btn-outline, .btn-soft {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    font-weight: 600;
    font-size: .95rem;
    padding: .72rem 1.25rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 1px solid transparent;
    transition: all .2s ease;
    text-align: center;
    line-height: 1.2;
}

.btn-primary { background: var(--brand-gradient); color: #fff; box-shadow: 0 6px 16px rgba(108, 92, 231, .28); }
.btn-primary:hover { background: var(--brand-gradient); filter: brightness(1.07); box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.btn-outline { background: #fff; color: var(--primary-color); border-color: var(--border-color); }
.btn-outline:hover { border-color: var(--primary-color); background: var(--primary-soft); }
.btn-soft { background: var(--primary-soft); color: var(--primary-color); }
.btn-soft:hover { background: #ddd6ff; color: var(--primary-hover); }
.btn-primary:active, .btn-outline:active, .btn-soft:active { transform: translateY(0); }
.btn-primary:disabled, .btn-outline:disabled { opacity: .6; cursor: not-allowed; }

.btn-row { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: 1rem; }

/* ---------- Cards ---------- */
.card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.card-pad { padding: 1.5rem; }

/* ---------- Chips ---------- */
.chip {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .48rem .95rem;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: #fff;
    font-size: .875rem;
    font-weight: 500;
    color: var(--text-color);
    transition: all .2s;
    cursor: pointer;
}

.chip:hover { border-color: var(--primary-color); color: var(--primary-color); }
.chip.is-active { background: var(--brand-gradient); border-color: transparent; color: #fff; box-shadow: 0 6px 14px rgba(108, 92, 231, .28); }

/* ---------- Forms ---------- */
.field { margin-bottom: 1rem; }

.field label {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    margin-bottom: .4rem;
    color: var(--text-color);
}

.input, .select, .textarea {
    width: 100%;
    padding: .72rem .85rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: #fff;
    font-size: .95rem;
    color: var(--text-color);
    font-family: inherit;
    transition: border-color .15s, box-shadow .15s;
}

.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(22, 53, 122, .12);
}

.textarea { resize: vertical; min-height: 150px; line-height: 1.5; }
.select { cursor: pointer; }

.form-status { font-size: .9rem; margin-top: .6rem; }
.form-status-ok { color: var(--success-color); font-weight: 600; }
.form-status-err { color: var(--danger-color); font-weight: 600; }

/* ---------- Result ---------- */
.result-panel { display: flex; flex-direction: column; }
.result-empty { color: var(--text-muted); font-size: .95rem; }
.result-value {
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary-color);
    line-height: 1.25;
    margin-bottom: .35rem;
}

.result-sub { color: var(--text-muted); font-size: .92rem; margin-bottom: 1rem; }

.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: .9rem;
    margin-top: 1rem;
}

.result-stat {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: .9rem .75rem;
    text-align: center;
}

.result-stat .num {
    display: block;
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--primary-color);
}

.result-stat .lbl { font-size: .78rem; color: var(--text-muted); }

.badge-soft {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    background: var(--primary-soft);
    color: var(--primary-color);
    border-radius: 999px;
    padding: .38rem .85rem;
    font-size: .82rem;
    font-weight: 600;
}

.badge-ok { background: #e6f6ee; color: var(--success-color); }
.badge-warn { background: #fef4e2; color: #b45309; }
.badge-err { background: #fdeaea; color: var(--danger-color); }

.code-out {
    background: #0f1e3d;
    color: #e2e8f0;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .85rem;
    padding: 1rem;
    border-radius: var(--radius-sm);
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
    min-height: 70px;
    max-height: 340px;
    overflow: auto;
}

/* ---------- Tool card ---------- */
.tool-card {
    display: flex;
    gap: .9rem;
    align-items: flex-start;
    padding: 1.1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: #fff;
    transition: all .2s ease;
    height: 100%;
}

.tool-card:hover { border-color: var(--primary-color); box-shadow: var(--shadow-md); transform: translateY(-3px); }

.tool-icon {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--primary-soft);
    color: var(--primary-color);
    display: grid;
    place-items: center;
    font-size: 1.1rem;
}

.tool-card h3 { font-size: 1rem; font-weight: 700; }
.tool-card p { font-size: .85rem; color: var(--text-muted); margin-top: .15rem; }

/* ---------- Category card ---------- */
.cat-card {
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: #fff;
    transition: all .2s ease;
    height: 100%;
}

.cat-card:hover { box-shadow: var(--shadow-md); }

.cat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--primary-soft);
    color: var(--primary-color);
    display: grid;
    place-items: center;
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

.cat-card ul { margin-top: 1rem; display: flex; flex-direction: column; gap: .5rem; }

.cat-card ul a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    font-size: .92rem;
    color: var(--text-muted);
    padding: .25rem 0;
}

.cat-card ul a:hover { color: var(--primary-color); }

/* ---------- Feature card ---------- */
.feature {
    display: flex;
    flex-direction: column;
    gap: .6rem;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: #fff;
    height: 100%;
}

.feature .f-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: var(--primary-soft);
    color: var(--primary-color);
    display: grid;
    place-items: center;
    font-size: 1.15rem;
}

/* ---------- FAQ ---------- */
.faq details {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: #fff;
    margin-bottom: .75rem;
    overflow: hidden;
}

.faq summary {
    list-style: none;
    cursor: pointer;
    padding: 1rem 1.1rem;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.faq summary::-webkit-details-marker { display: none; }
.faq summary .chev { transition: transform .2s; color: var(--primary-color); }
.faq details[open] summary .chev { transform: rotate(180deg); }
.faq .faq-body { padding: 0 1.1rem 1.1rem; color: var(--text-muted); font-size: .94rem; }

/* ---------- Breadcrumb ---------- */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .85rem;
    color: var(--text-muted);
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.breadcrumb a:hover { color: var(--primary-color); }
.breadcrumb i { font-size: .65rem; opacity: .6; }

/* ---------- Info list ---------- */
.info-list { margin-top: 1rem; display: flex; flex-direction: column; gap: .55rem; }
.info-list li { display: flex; gap: .6rem; font-size: .92rem; color: var(--text-muted); }
.info-list li i { color: var(--primary-color); margin-top: .25rem; flex: 0 0 auto; }

/* ---------- Search results ---------- */
.result-item {
    display: block;
    padding: 1rem 1.1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: #fff;
    margin-bottom: .75rem;
    transition: all .2s;
}

.result-item:hover { border-color: var(--primary-color); box-shadow: var(--shadow-sm); }
.result-item h3 { font-size: 1.02rem; font-weight: 700; color: var(--primary-color); }
.result-item p { font-size: .9rem; color: var(--text-muted); margin-top: .25rem; }
.result-item .g-label {
    display: inline-block;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--secondary-color);
    margin-bottom: .3rem;
}

/* ---------- Overflow / overlap safety ---------- */
.tool-card > span:last-child { min-width: 0; }
.tool-card h3, .tool-card p { overflow-wrap: anywhere; }
.result-value, .result-stat .num, .stat-compare .box .v { overflow-wrap: anywhere; }
.cat-card h3, .feature h3, .cat-card p { overflow-wrap: anywhere; }
.footer-desc, .hero-sub, .tool-head p { overflow-wrap: anywhere; }
.result-grid { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }

/* ---------- Drop zone (file tools) ---------- */
.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    background: var(--surface-color);
    padding: 2rem 1.25rem;
    text-align: center;
    cursor: pointer;
    transition: all .2s ease;
}
.drop-zone:hover, .drop-zone:focus-visible, .drop-zone.is-over {
    border-color: var(--primary-color);
    background: var(--primary-soft);
    outline: none;
}
.drop-zone i { font-size: 1.9rem; color: var(--primary-color); margin-bottom: .6rem; }
.drop-zone p { font-size: .92rem; color: var(--text-muted); }
.drop-zone p + p { margin-top: .25rem; }
.drop-zone strong { color: var(--text-color); }

/* ---------- Tabs (converter modes) ---------- */
.tabs { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.tab-btn {
    padding: .6rem 1.1rem;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: #fff;
    font-size: .9rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all .2s ease;
}
.tab-btn:hover { border-color: var(--primary-color); color: var(--primary-color); }
.tab-btn.is-active { background: var(--primary-color); border-color: var(--primary-color); color: #fff; }
.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

/* ---------- File chip + loading bar ---------- */
.file-chip {
    display: flex;
    align-items: center;
    gap: .6rem;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: .6rem .85rem;
    font-size: .88rem;
    margin-top: .9rem;
    overflow-wrap: anywhere;
}
.file-chip i { color: var(--primary-color); }
.progress-bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: .9rem; }
.progress-bar > span {
    display: block;
    height: 100%;
    width: 35%;
    background: var(--primary-color);
    border-radius: 999px;
    animation: pbar 1.1s ease-in-out infinite;
}
@keyframes pbar {
    0% { margin-left: -35%; }
    100% { margin-left: 100%; }
}

/* ---------- Before/after comparison ---------- */
.stat-compare { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; margin-top: 1rem; }
.stat-compare .box {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: .9rem;
    text-align: center;
}
.stat-compare .box .k { font-size: .76rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; display: block; }
.stat-compare .box .v { font-family: var(--font-heading); font-weight: 800; font-size: 1.15rem; color: var(--primary-color); }

/* ---------- Image preview frame ---------- */
.img-preview {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--surface-color);
    margin-top: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 140px;
    padding: .5rem;
}
.img-preview img { max-height: 260px; width: auto; max-width: 100%; object-fit: contain; }

/* ---------- Colorful icon tiles (dopamine-friendly, easy on the eyes) ---------- */
.tool-icon, .cat-icon, .feature .f-icon { transition: transform .25s ease; }
.tool-card:hover .tool-icon, .cat-card:hover .cat-icon, .feature:hover .f-icon { transform: scale(1.07) rotate(-4deg); }

.grid > :nth-child(4n+1) .tool-icon,
.grid > :nth-child(4n+1) .cat-icon,
.grid > :nth-child(4n+1) .f-icon { background: var(--accent-sky-soft); color: #1f8fe0; }

.grid > :nth-child(4n+2) .tool-icon,
.grid > :nth-child(4n+2) .cat-icon,
.grid > :nth-child(4n+2) .f-icon { background: var(--accent-pink-soft); color: #e14b7f; }

.grid > :nth-child(4n+3) .tool-icon,
.grid > :nth-child(4n+3) .cat-icon,
.grid > :nth-child(4n+3) .f-icon { background: var(--accent-sun-soft); color: #cf8f00; }

.grid > :nth-child(4n+4) .tool-icon,
.grid > :nth-child(4n+4) .cat-icon,
.grid > :nth-child(4n+4) .f-icon { background: var(--secondary-soft); color: #00988c; }

.cat-card:hover { border-color: #d7d0ff; }
.feature:hover { border-color: #ffe0c9; }

/* ---------- Hashtag output ---------- */
.tag-cloud { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .35rem; }

.tag-pill {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    background: var(--primary-soft);
    color: var(--primary-color);
    border: 1px solid transparent;
    border-radius: 999px;
    padding: .42rem .9rem;
    font-size: .85rem;
    font-weight: 600;
    font-family: inherit;
    overflow-wrap: anywhere;
    max-width: 100%;
}

.tag-pill.is-copy { cursor: pointer; transition: all .2s ease; }
.tag-pill.is-copy:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.tag-pill:nth-child(3n+2) { background: var(--accent-sky-soft); color: #1f8fe0; }
.tag-pill:nth-child(3n+3) { background: var(--secondary-soft); color: #00988c; }

/* ---------- Thumbnail previews ---------- */
.thumb-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; margin-top: .5rem; }
@media (min-width: 640px) { .thumb-grid { grid-template-columns: repeat(2, 1fr); } }

.thumb-item {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--surface-color);
}

.thumb-item img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--surface-2); }

.thumb-item .thumb-meta { padding: .8rem .85rem; display: flex; flex-direction: column; gap: .5rem; align-items: flex-start; }
.thumb-item .thumb-meta strong { font-size: .9rem; }
.thumb-item .thumb-meta span { font-size: .78rem; color: var(--text-muted); }
.thumb-item .thumb-meta .btn-primary,
.thumb-item .thumb-meta .btn-outline { padding: .5rem .85rem; font-size: .83rem; width: 100%; }

/* ---------- Copy-ready generator output ---------- */
.gen-list { display: flex; flex-direction: column; gap: .6rem; margin-top: .5rem; }

.gen-row {
    display: flex;
    align-items: flex-start;
    gap: .7rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--surface-color);
    padding: .75rem .85rem;
}

.gen-row .gen-text { flex: 1; min-width: 0; font-size: .94rem; overflow-wrap: anywhere; }
.gen-row .gen-len { font-size: .75rem; color: var(--text-muted); white-space: nowrap; padding-top: .15rem; }

.gen-row .gen-copy {
    flex: 0 0 auto;
    border: 1px solid var(--border-color);
    background: #fff;
    color: var(--primary-color);
    border-radius: 8px;
    padding: .35rem .6rem;
    font-size: .78rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: all .2s ease;
}

.gen-row .gen-copy:hover { border-color: var(--primary-color); background: var(--primary-soft); }

/* ---------- Image cropper stage ---------- */
.crop-stage {
    position: relative;
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    border-radius: var(--radius-sm);
    line-height: 0;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.crop-stage img { width: auto; max-width: 100%; max-height: 62vh; display: block; }

.crop-box {
    position: absolute;
    border: 2px solid var(--primary-color);
    box-shadow: 0 0 0 9999px rgba(27, 30, 58, .45);
    cursor: move;
}

.crop-handle {
    position: absolute;
    width: 16px;
    height: 16px;
    background: #fff;
    border: 2px solid var(--primary-color);
    border-radius: 4px;
    display: block;
}

.crop-handle.nw { top: -9px; left: -9px; cursor: nwse-resize; }
.crop-handle.ne { top: -9px; right: -9px; cursor: nesw-resize; }
.crop-handle.sw { bottom: -9px; left: -9px; cursor: nesw-resize; }
.crop-handle.se { bottom: -9px; right: -9px; cursor: nwse-resize; }