/* ═══ MMS Studio — Graphic & GIF Generator ═══ */

#section-mms-studio { padding: 0 !important; margin: 0 !important; }
#mmsStudioContainer { height: 100%; }
.ms-cockpit {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--bg-body, #f0f4f8);
}

/* Header — hidden, breadcrumb is enough */
.ms-header { display: none; }

/* Tabs */
.ms-tabs {
    display: flex;
    gap: 0;
    padding: 8px 16px 0;
    border-bottom: 1px solid var(--border-light, #e2e8f0);
}
.ms-tab {
    padding: 10px 20px;
    border: none;
    background: none;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary, #64748b);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}
.ms-tab:hover { color: var(--text-primary, #1e293b); }
.ms-tab.active {
    color: #e85d04;
    border-bottom-color: #e85d04;
}

/* Tab Content */
.ms-tab-content {
    display: none;
    flex: 1;
    overflow-y: auto;
}
.ms-tab-content.active {
    display: flex;
    flex-direction: row;
}
.ms-tab-content.active[data-tab-content='gallery'] {
    flex-direction: column;
}

/* ── Studio Tab ── */
.ms-studio-scroll {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    padding: 10px 16px;
}
.ms-studio-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 480px;
}

/* Preview Panel */
.ms-preview-panel {
    width: 380px;
    min-width: 320px;
    border-left: 1px solid var(--border-light, #e2e8f0);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: #1a1a2e;
}
.ms-preview-frame {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    max-width: 100%;
    position: relative;
}
.ms-preview-frame img {
    display: block;
    max-width: 100%;
    height: auto;
}
.ms-preview-meta {
    margin-top: 12px;
    text-align: center;
    font-size: 12px;
    color: rgba(255,255,255,0.5);
    font-family: 'JetBrains Mono', monospace;
}
.ms-preview-size {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}
.ms-preview-size.ok { background: rgba(34,197,94,0.2); color: #22c55e; }
.ms-preview-size.warn { background: rgba(245,158,11,0.2); color: #f59e0b; }
.ms-preview-size.over { background: rgba(239,68,68,0.2); color: #ef4444; }

/* Decorations Bar */
.ms-deco-bar {
    display: flex;
    gap: 20px;
    padding: 8px 0 12px;
    border-bottom: 1px solid var(--border-light, #e2e8f0);
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.ms-deco-section {
    display: flex;
    align-items: center;
    gap: 6px;
}
.ms-deco-section .ms-field-label {
    font-size: 10px;
    margin: 0;
    white-space: nowrap;
}
.ms-icon-pills {
    display: flex;
    gap: 3px;
    align-items: center;
    flex-wrap: wrap;
}
.ms-icon-pill {
    min-width: 30px;
    height: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 15px;
    border: 1.5px solid var(--border-light, #e2e8f0);
    background: var(--bg-card, #fff);
    transition: all 0.15s;
    user-select: none;
}
.ms-icon-pill:hover { border-color: #e85d04; transform: scale(1.08); }
.ms-icon-pill.active { border-color: #e85d04; background: rgba(232,93,4,0.08); box-shadow: 0 0 0 2px rgba(232,93,4,0.15); }
.ms-icon-pill.ms-pill-label {
    padding: 0 10px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.3px;
    color: var(--text-secondary, #64748b);
    text-transform: uppercase;
}
.ms-icon-pill.ms-pill-label.active { color: #e85d04; }
.ms-color-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1.5px solid rgba(0,0,0,0.1);
}
.ms-line-pill {
    width: auto;
    padding: 0 10px;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-secondary, #64748b);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.ms-line-pill.active { color: #e85d04; }
.ms-icon-custom {
    width: 32px;
    height: 28px;
    border-radius: 6px;
    border: 1px dashed var(--border-light, #e2e8f0);
    text-align: center;
    font-size: 14px;
    background: var(--bg-card, #fff);
    outline: none;
}
.ms-icon-custom:focus { border-color: #e85d04; }

/* Form Fields */
.ms-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.ms-field-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary, #64748b);
}
.ms-input {
    padding: 9px 12px;
    border: 1px solid var(--border-light, #e2e8f0);
    border-radius: 8px;
    font-size: 14px;
    background: var(--bg-card, #fff);
    color: var(--text-primary, #1e293b);
    transition: border-color 0.2s;
}
.ms-input:focus {
    outline: none;
    border-color: #e85d04;
    box-shadow: 0 0 0 3px rgba(232,93,4,0.1);
}
.ms-select {
    padding: 9px 12px;
    border: 1px solid var(--border-light, #e2e8f0);
    border-radius: 8px;
    font-size: 14px;
    background: var(--bg-card, #fff);
    color: var(--text-primary, #1e293b);
    cursor: pointer;
}
.ms-textarea {
    min-height: 60px;
    resize: vertical;
    font-family: inherit;
}

/* Template Strip (compact horizontal scroll) */
.ms-tpl-strip-wrap {
    padding: 0 0 8px;
    border-bottom: 1px solid var(--border-light, #e2e8f0);
    margin-bottom: 10px;
}
.ms-tpl-strip {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    padding: 4px 0;
}
.ms-tpl-chip {
    flex-shrink: 0;
    position: relative;
    width: 78px;
    height: 44px;
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.ms-tpl-chip:hover {
    border-color: #e85d04;
    transform: translateY(-1px);
}
.ms-tpl-chip.selected {
    border-color: #e85d04;
    box-shadow: 0 0 0 2px rgba(232,93,4,0.25);
}
.ms-tpl-label {
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.6);
    text-align: center;
    line-height: 1.2;
    padding: 0 4px;
}
.ms-tpl-gif {
    position: absolute;
    top: 3px;
    right: 3px;
    font-size: 7px;
    font-weight: 800;
    padding: 1px 4px;
    border-radius: 4px;
    background: #e85d04;
    color: #fff;
}
/* Selected template info */
.ms-sel-info {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    font-size: 12px;
}
.ms-sel-name { font-weight: 700; color: var(--text-primary, #1e293b); }
.ms-sel-desc { color: var(--text-secondary, #64748b); }
.ms-sel-badge {
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    background: rgba(232,93,4,0.1);
    color: #e85d04;
}
.ms-sel-badge.static { background: rgba(59,130,246,0.1); color: #3b82f6; }

/* Form 2-column grid */
.ms-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
.ms-form-col {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.ms-input-row {
    display: flex;
    gap: 8px;
}
.ms-input-row .ms-input { flex: 1; }

/* Line row with size slider */
.ms-line-row {
    display: flex;
    align-items: center;
    gap: 6px;
}
.ms-line-input { flex: 1; min-width: 0; }
.ms-size-slider {
    width: 50px;
    height: 20px;
    cursor: pointer;
    accent-color: #e85d04;
    flex-shrink: 0;
}
.ms-size-val {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-secondary, #64748b);
    font-family: 'JetBrains Mono', monospace;
    width: 18px;
    text-align: right;
    flex-shrink: 0;
}

/* AI Copy Variants */
.ms-copy-variants {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.ms-copy-variant {
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border-light, #e2e8f0);
    background: var(--bg-card, #fff);
    cursor: pointer;
    font-size: 13px;
    color: var(--text-primary, #1e293b);
    transition: all 0.2s;
    line-height: 1.5;
}
.ms-copy-variant:hover { border-color: #e85d04; background: rgba(232,93,4,0.03); }
.ms-copy-variant.selected {
    border-color: #e85d04;
    background: rgba(232,93,4,0.05);
    font-weight: 600;
}
.ms-copy-variant .ms-copy-chars {
    float: right;
    font-size: 10px;
    color: var(--text-secondary, #64748b);
    font-weight: 400;
}

/* Style Pills */
.ms-style-pills {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.ms-style-pill {
    padding: 5px 12px;
    border-radius: 16px;
    font-size: 11px;
    font-weight: 600;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-light, #e2e8f0);
    color: var(--text-secondary, #64748b);
    cursor: pointer;
    transition: all 0.2s;
}
.ms-style-pill:hover { border-color: #e85d04; color: #e85d04; }
.ms-style-pill.active { background: rgba(232,93,4,0.08); border-color: #e85d04; color: #e85d04; }

/* Generate Button */
.ms-generate-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #e85d04, #c2410c);
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.3px;
}
.ms-generate-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(232,93,4,0.3);
}
.ms-generate-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}
.ms-ai-btn {
    padding: 8px 16px;
    border: 1px solid #e85d04;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    color: #e85d04;
    background: rgba(232,93,4,0.05);
    cursor: pointer;
    transition: all 0.2s;
}
.ms-ai-btn:hover { background: rgba(232,93,4,0.1); }
.ms-ai-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Gallery Tab ── */
.ms-gallery-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-light, #e2e8f0);
}
.ms-gallery-search {
    flex: 1;
    max-width: 300px;
}
.ms-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    padding: 20px 24px;
}
.ms-graphic-card {
    background: var(--bg-card, #fff);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-light, #e2e8f0);
    transition: all 0.2s;
}
.ms-graphic-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    transform: translateY(-2px);
}
.ms-graphic-thumb {
    aspect-ratio: 4/3;
    overflow: hidden;
    background: #1a1a2e;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ms-graphic-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.ms-graphic-meta {
    padding: 10px 12px;
}
.ms-graphic-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #1e293b);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ms-graphic-info {
    font-size: 11px;
    color: var(--text-secondary, #64748b);
    margin-top: 4px;
    display: flex;
    gap: 8px;
}
.ms-graphic-actions {
    display: flex;
    gap: 6px;
    padding: 0 12px 10px;
}
.ms-graphic-actions button {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid var(--border-light, #e2e8f0);
    background: var(--bg-card, #fff);
    color: var(--text-secondary, #64748b);
    cursor: pointer;
    transition: all 0.2s;
}
.ms-graphic-actions button:hover { border-color: #e85d04; color: #e85d04; }
.ms-graphic-actions button.delete:hover { border-color: #ef4444; color: #ef4444; }

/* Preview Actions */
.ms-preview-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
    margin-top: 12px;
}
.ms-save-btn {
    padding: 10px 24px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.3px;
}
.ms-save-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(34,197,94,0.4);
}
.ms-save-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}
.ms-download-link {
    color: rgba(255,255,255,0.6);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    transition: color 0.2s;
}
.ms-download-link:hover { color: #fff; }

/* Empty State */
.ms-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-secondary, #64748b);
    text-align: center;
    gap: 12px;
    font-size: 14px;
}
.ms-empty svg { width: 48px; height: 48px; fill: var(--text-secondary, #64748b); opacity: 0.3; }

/* Responsive */
@media (max-width: 900px) {
    .ms-tab-content.active { flex-direction: column; }
    .ms-preview-panel { width: 100%; min-width: unset; border-left: none; border-top: 1px solid var(--border-light, #e2e8f0); }
    .ms-form-grid { grid-template-columns: 1fr; }
}
