/* ===============================================================
   ToolDuck — Format Studio & Code Formatter Styles
   Shared styles for /format-studio/ and individual formatters
   =============================================================== */

/* ---------------------------------------------------------------
   1. Shared Formatter Tool Application (.fmt-app)
   --------------------------------------------------------------- */
.fmt-app {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.fmt-header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.85rem 1.15rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md, 8px);
}

.fmt-toolbar-left {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.fmt-toolbar-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--ink-2);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.fmt-format-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary, #1d4ed8);
    background: rgba(29, 78, 216, 0.08);
    border: 1px solid rgba(29, 78, 216, 0.2);
    border-radius: 999px;
}

.fmt-global-actions {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.fmt-file-btn {
    cursor: pointer;
    margin: 0;
}

/* Options Bar */
.fmt-options-bar {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex-wrap: wrap;
    padding: 0.65rem 1.15rem;
    background: var(--bg-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 6px);
    font-size: 0.85rem;
}

.fmt-option-group {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.fmt-option-label {
    font-weight: 550;
    color: var(--ink-2);
    font-size: 0.82rem;
}

.fmt-option-select {
    padding: 4px 8px;
    font-size: 0.82rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--ink);
}

/* Status Bar & Indicators */
.fmt-status-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.85rem;
    font-size: 0.82rem;
    color: var(--ink-2);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
}

.fmt-status-indicator {
    font-size: 0.75rem;
    color: #10b981; /* Green */
}

.fmt-status-bar.is-error .fmt-status-indicator {
    color: #ef4444; /* Red */
}

.fmt-status-bar.is-error {
    background: rgba(239, 68, 68, 0.05);
    border-color: rgba(239, 68, 68, 0.3);
    color: #b91c1c;
}

html[data-theme="dark"] .fmt-status-bar.is-error {
    color: #f87171;
}

.fmt-error-banner {
    padding: 0.85rem 1.15rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-left: 4px solid #ef4444;
    border-radius: 4px;
    color: #991b1b;
    font-size: 0.86rem;
    line-height: 1.45;
    font-family: ui-monospace, SFMono-Regular, monospace;
}

html[data-theme="dark"] .fmt-error-banner {
    background: #450a0a;
    border-color: #7f1d1d;
    border-left-color: #ef4444;
    color: #fca5a5;
}

/* Dual Column Editors */
.fmt-editors {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
}

@media (min-width: 900px) {
    .fmt-editors {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.fmt-column {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md, 8px);
    overflow: hidden;
}

.fmt-column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 1rem;
    background: var(--bg-muted);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 0.5rem;
}

.fmt-column-title {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.fmt-badge {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 7px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--ink-2);
}

.fmt-badge--primary {
    background: rgba(29, 78, 216, 0.1);
    color: var(--primary, #1d4ed8);
    border-color: rgba(29, 78, 216, 0.2);
}

.fmt-meta-count {
    font-size: 0.75rem;
    color: var(--ink-3);
    font-family: ui-monospace, SFMono-Regular, monospace;
}

.fmt-column-tools {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

/* View switcher tabs */
.fmt-view-tabs {
    display: inline-flex;
    background: var(--surface);
    padding: 2px;
    border-radius: 6px;
    border: 1px solid var(--border);
    gap: 2px;
}

.fmt-view-btn {
    padding: 3px 10px;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--ink-2);
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.fmt-view-btn:hover {
    color: var(--ink);
}

.fmt-view-btn.is-active {
    background: var(--primary, #1d4ed8);
    color: #ffffff;
    font-weight: 600;
}

/* Editor Body & Gutters */
.fmt-editor-body {
    position: relative;
    display: flex;
    min-height: 440px;
    max-height: 720px;
    background: var(--surface);
    overflow: hidden;
}

.fmt-view-panel {
    display: flex;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.fmt-gutter {
    flex-shrink: 0;
    width: 44px;
    padding: 0.85rem 0.5rem 0.85rem 0;
    text-align: right;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.82rem;
    line-height: 1.5;
    color: var(--ink-3, #94a3b8);
    background: var(--bg-muted);
    border-right: 1px solid var(--border);
    user-select: none;
    overflow: hidden;
    white-space: pre-wrap;
    box-sizing: border-box;
}

.fmt-textarea,
.fmt-output {
    flex: 1;
    width: 100%;
    margin: 0;
    padding: 0.85rem 1rem;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.82rem;
    line-height: 1.5;
    color: var(--ink);
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    white-space: pre;
    overflow: auto;
    tab-size: 2;
    box-sizing: border-box;
}

.fmt-output {
    background: rgba(0, 0, 0, 0.015);
    user-select: text;
}

html[data-theme="dark"] .fmt-output {
    background: rgba(255, 255, 255, 0.015);
}

/* Markdown preview */
.fmt-preview-panel {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    overflow: auto;
    padding: 1.25rem;
    background: var(--surface);
    box-sizing: border-box;
}

.fmt-md-preview {
    font-size: 0.92rem;
    line-height: 1.6;
    color: var(--ink);
}

.fmt-md-preview h1,
.fmt-md-preview h2,
.fmt-md-preview h3 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    color: var(--ink);
}

.fmt-md-preview code {
    background: var(--bg-muted);
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 0.85em;
    font-family: ui-monospace, SFMono-Regular, monospace;
}

.fmt-md-preview pre {
    background: var(--bg-muted);
    padding: 0.85rem;
    border-radius: 6px;
    overflow-x: auto;
}

.fmt-md-preview blockquote {
    border-left: 4px solid var(--border);
    padding-left: 1rem;
    margin-left: 0;
    color: var(--ink-2);
}

/* Toast */
.fmt-toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 1000;
    padding: 0.65rem 1.25rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: #ffffff;
    background: #1e293b;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.fmt-toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* ---------------------------------------------------------------
   2. Format Studio Central Hub (.fmt-hub)
   --------------------------------------------------------------- */
.fmt-hub {
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
    margin-bottom: 2.5rem;
}

.fmt-hub-search-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1rem 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md, 8px);
}

.fmt-hub-search-input {
    flex: 1 1 280px;
    padding: 0.65rem 1rem;
    font-size: 0.95rem;
    color: var(--ink);
    background: var(--bg-muted);
    border: 1px solid var(--border);
    border-radius: 6px;
    outline: none;
    transition: border-color 0.15s ease;
}

.fmt-hub-search-input:focus {
    border-color: var(--primary, #1d4ed8);
}

.fmt-hub-categories {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.fmt-cat-btn {
    padding: 5px 12px;
    font-size: 0.84rem;
    font-weight: 500;
    color: var(--ink-2);
    background: var(--bg-muted);
    border: 1px solid var(--border);
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.fmt-cat-btn:hover {
    color: var(--ink);
    background: rgba(0, 0, 0, 0.05);
}

.fmt-cat-btn.is-active {
    background: var(--primary, #1d4ed8);
    color: #ffffff;
    border-color: var(--primary, #1d4ed8);
    font-weight: 600;
}

/* Grid of Formatters */
.fmt-hub-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}

.fmt-card {
    display: flex;
    flex-direction: column;
    padding: 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md, 8px);
    text-decoration: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.fmt-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
    border-color: var(--primary, #1d4ed8);
}

.fmt-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.fmt-card-cat {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--brand-strong, #0284c7);
}

.fmt-card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--ink);
    margin: 0 0 0.4rem;
}

.fmt-card-desc {
    font-size: 0.86rem;
    color: var(--ink-2);
    line-height: 1.45;
    margin: 0 0 1rem;
    flex-grow: 1;
}

.fmt-card-caps {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.fmt-cap-pill {
    padding: 2px 7px;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 4px;
    background: var(--bg-muted);
    border: 1px solid var(--border);
    color: var(--ink-3);
}

.fmt-card-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary, #1d4ed8);
}

/* Responsive */
@media (max-width: 768px) {
    .fmt-header-bar {
        flex-direction: column;
        align-items: flex-start;
    }
    .fmt-global-actions {
        width: 100%;
    }
    .fmt-options-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    .fmt-editor-body {
        min-height: 320px;
    }
}
