/* Speising Editor — v2 Mockup-exact styles */

:root {
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    --color-text-primary: #1a1a1a;
    --color-text-secondary: #6b7280;
    --color-background-primary: #ffffff;
    --color-background-secondary: #f5f5f5;
    --color-border-secondary: #d1d5db;
    --color-border-tertiary: #e5e7eb;
    --border-radius-md: 6px;
    --border-radius-lg: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font-sans);
    background: var(--color-background-primary);
    color: var(--color-text-primary);
}

.app {
    padding: 1rem 1.25rem;
    max-width: 1400px;
    margin: 0 auto;
}

/* ── Header ── */
.header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 1rem;
    padding-bottom: 12px;
    border-bottom: 0.5px solid var(--color-border-tertiary);
}

.logo {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #E73440;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 500;
    font-size: 13px;
    flex-shrink: 0;
}

.header-info h1 {
    font-size: 18px;
    font-weight: 500;
    color: var(--color-text-primary);
}

.header-info p {
    font-size: 12px;
    color: var(--color-text-secondary);
}

.status-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #14A3A3;
    margin-right: 5px;
}

.user-badge {
    margin-left: auto;
    background: var(--color-background-secondary);
    padding: 5px 12px;
    border-radius: var(--border-radius-md);
    font-size: 12px;
    color: var(--color-text-secondary);
}

.status-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    display: none;
}
.status-badge.building { display: inline-block; background: #FEF3C7; color: #92400E; }
.status-badge.publishing { display: inline-block; background: #D1FAE5; color: #065F46; }
.status-badge.error { display: inline-block; background: #FEE2E2; color: #991B1B; }
.status-badge.success { display: inline-block; background: #D1FAE5; color: #065F46; }

/* ── Tabs ── */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 0.5px solid var(--color-border-tertiary);
    margin-bottom: 1rem;
}

.tab {
    padding: 8px 16px;
    font-size: 13px;
    color: var(--color-text-secondary);
    cursor: pointer;
    border: none;
    background: none;
    border-bottom: 2px solid transparent;
    font-family: inherit;
}

.tab.active {
    color: #E73440;
    border-bottom-color: #E73440;
    font-weight: 500;
}

.tab:hover:not(.active) {
    color: var(--color-text-primary);
}

/* ── Layout Chooser ── */
.section-label {
    font-size: 12px;
    color: var(--color-text-secondary);
    margin-bottom: 8px;
}

.layouts-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-bottom: 10px;
}

.layout-card {
    border: 0.5px solid var(--color-border-tertiary);
    border-radius: 6px;
    padding: 4px;
    cursor: pointer;
    text-align: center;
    transition: border-color 0.15s;
}

.layout-card.selected {
    border-color: #E73440;
    border-width: 2px;
}

.layout-card:hover:not(.selected) {
    border-color: var(--color-border-secondary);
}

.layout-mini {
    background: #0B2027;
    border-radius: 3px;
    height: 36px;
    margin-bottom: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 4px;
}

.layout-mini .col {
    flex: 1;
    height: 20px;
    background: rgba(20,163,163,0.2);
    border-radius: 2px;
}

.layout-label {
    font-size: 9px;
    color: var(--color-text-secondary);
}

/* ── Main Layout ── */
.main-layout {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr) 260px;
    gap: 12px;
}

/* ── Sidebar (slide list) ── */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sidebar-title {
    font-size: 11px;
    color: var(--color-text-secondary);
    margin-bottom: 4px;
    font-weight: 500;
}

.slide-thumb {
    background: #0B2027;
    border-radius: 6px;
    padding: 6px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.15s;
}

.slide-thumb.active {
    border-color: #E73440;
}

.slide-thumb:hover:not(.active) {
    border-color: #14A3A3;
}

.slide-thumb-inner {
    background: #122a33;
    border-radius: 3px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.slide-thumb-inner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 3px;
}

.slide-thumb-num {
    position: absolute;
    top: 3px;
    left: 5px;
    font-size: 9px;
    color: #14A3A3;
    font-weight: 500;
    z-index: 1;
    text-shadow: 0 0 4px rgba(0,0,0,0.8);
}

.slide-thumb-title {
    font-size: 8px;
    color: rgba(255,255,255,0.7);
    text-align: center;
    padding: 0 4px;
    line-height: 1.2;
}

.slide-thumb-label {
    font-size: 10px;
    color: var(--color-text-secondary);
    padding: 3px 0 0 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.slide-more {
    font-size: 10px;
    color: var(--color-text-secondary);
    text-align: center;
    padding: 4px;
    cursor: pointer;
}

.slide-more:hover {
    color: #14A3A3;
}

/* ── Preview ── */
.preview-area {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.preview-box {
    background: #0B2027;
    border-radius: var(--border-radius-lg);
    aspect-ratio: 16/9;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-box img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.preview-placeholder-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 20px;
}

.preview-logo {
    background: #E73440;
    border-radius: 2px;
    padding: 3px 10px;
    font-size: 7px;
    color: #fff;
    font-weight: 500;
    letter-spacing: 0.3px;
    margin-bottom: 12px;
}

.preview-title {
    color: #14A3A3;
    font-size: 14px;
    font-weight: 500;
}

.action-bar {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ── Buttons ── */
.btn {
    padding: 7px 14px;
    border-radius: var(--border-radius-md);
    font-size: 12px;
    cursor: pointer;
    border: none;
    font-weight: 500;
    transition: opacity 0.15s;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

.btn:hover { opacity: 0.85; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: #E73440; color: #fff; }
.btn-secondary { background: var(--color-background-secondary); color: var(--color-text-primary); border: 0.5px solid var(--color-border-tertiary); }
.btn-accent { background: #14A3A3; color: #fff; }
.btn-icon { font-size: 11px; margin-right: 4px; }
.btn-full { width: 100%; justify-content: center; font-size: 11px; margin-top: 4px; }

/* ── Editor Panel ── */
.editor-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.editor-section {
    background: var(--color-background-primary);
    border: 0.5px solid var(--color-border-tertiary);
    border-radius: var(--border-radius-lg);
    padding: 10px 12px;
}

.editor-section h3 {
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.field {
    margin-bottom: 8px;
}

.field:last-child {
    margin-bottom: 0;
}

.field label {
    display: block;
    font-size: 11px;
    color: var(--color-text-secondary);
    margin-bottom: 3px;
}

.field input[type="text"],
.field textarea,
.field select {
    width: 100%;
    padding: 6px 8px;
    border: 0.5px solid var(--color-border-tertiary);
    border-radius: 4px;
    font-size: 12px;
    background: var(--color-background-secondary);
    color: var(--color-text-primary);
    resize: none;
    font-family: inherit;
}

.field textarea {
    height: 48px;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
    outline: none;
    border-color: #14A3A3;
}

.placeholder-text {
    font-size: 12px;
    color: var(--color-text-secondary);
    text-align: center;
    padding: 20px 0;
}

.settings-row {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.settings-row .field {
    margin-bottom: 0;
    flex: 1;
    min-width: 80px;
}

.color-circle {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: inline-block;
    vertical-align: middle;
    border: 0.5px solid var(--color-border-tertiary);
    cursor: pointer;
}

.color-hex {
    font-size: 11px;
    color: var(--color-text-secondary);
}

/* ── AI Box ── */
.ai-box {
    background: var(--color-background-primary);
    border: 0.5px solid var(--color-border-tertiary);
    border-radius: var(--border-radius-lg);
    padding: 10px 12px;
}

.ai-box h3 {
    font-size: 12px;
    font-weight: 500;
    color: #14A3A3;
    margin-bottom: 8px;
}

#ai-messages {
    max-height: 180px;
    overflow-y: auto;
}

.ai-msg {
    margin-bottom: 8px;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.5;
}

.ai-msg.user {
    background: var(--color-background-secondary);
    color: var(--color-text-primary);
    margin-left: 12px;
}

.ai-msg.assistant {
    background: rgba(20,163,163,0.08);
    color: var(--color-text-primary);
    margin-right: 12px;
    border: 0.5px solid rgba(20,163,163,0.2);
}

.ai-msg.thinking {
    color: var(--color-text-secondary);
    font-style: italic;
}

.ai-input-row {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}

.ai-input-row textarea {
    flex: 1;
    padding: 6px 8px;
    border: 0.5px solid var(--color-border-tertiary);
    border-radius: 4px;
    font-size: 11px;
    font-family: var(--font-mono);
    background: var(--color-background-secondary);
    color: var(--color-text-primary);
    height: 36px;
    resize: none;
}

.ai-input-row textarea:focus {
    outline: none;
    border-color: #14A3A3;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.chip {
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 10px;
    background: rgba(20,163,163,0.1);
    color: #14A3A3;
    cursor: pointer;
    border: 0.5px solid rgba(20,163,163,0.25);
    white-space: nowrap;
}

.chip:hover {
    background: rgba(20,163,163,0.2);
}

/* ── Attach button (paperclip) ── */
.ai-attach-btn {
    width: 36px;
    height: 36px;
    border: 0.5px solid var(--color-border-tertiary);
    background: var(--color-background-secondary);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary);
    flex-shrink: 0;
    transition: border-color 0.15s, color 0.15s;
}

.ai-attach-btn:hover {
    border-color: #14A3A3;
    color: #14A3A3;
}

/* ── Pending files (preview before sending) ── */
.ai-pending-files {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 0;
}

.pending-file-item {
    position: relative;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--color-border-tertiary);
}

.pending-file-thumb {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 5px;
    display: block;
}

.pending-file-doc {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: var(--color-background-secondary);
    font-size: 10px;
    max-width: 140px;
}

.pending-file-icon {
    font-size: 14px;
    flex-shrink: 0;
}

.pending-file-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--color-text-secondary);
}

.pending-file-remove {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #EF4444;
    color: #fff;
    border: none;
    font-size: 10px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pending-file-remove:hover {
    background: #DC2626;
}

/* ── Card section in editor (for multi-item editors) ── */
.card-section {
    background: var(--color-background-secondary);
    border: 0.5px solid var(--color-border-tertiary);
    border-radius: 6px;
    padding: 8px 10px;
    margin-bottom: 8px;
}

.card-section h4 {
    font-size: 11px;
    font-weight: 500;
    color: #E73440;
    margin-bottom: 6px;
}

.item-row {
    display: flex;
    gap: 4px;
    align-items: flex-start;
    margin-bottom: 4px;
}

.item-row textarea {
    flex: 1;
    min-height: 26px;
    padding: 4px 6px;
    background: var(--color-background-primary);
    border: 0.5px solid var(--color-border-tertiary);
    border-radius: 3px;
    color: var(--color-text-primary);
    font-size: 11px;
    font-family: inherit;
    resize: vertical;
}

.item-row textarea:focus {
    outline: none;
    border-color: #14A3A3;
}

.item-controls {
    display: flex;
    gap: 1px;
    flex-shrink: 0;
}

.item-btn {
    width: 20px;
    height: 20px;
    border: 0.5px solid var(--color-border-tertiary);
    background: var(--color-background-primary);
    color: var(--color-text-secondary);
    border-radius: 3px;
    cursor: pointer;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.item-btn:hover { background: var(--color-background-secondary); color: var(--color-text-primary); }
.item-btn.delete:hover { background: #FEE2E2; color: #EF4444; }

.toggle-btn {
    width: 22px;
    height: 20px;
    border: 0.5px solid var(--color-border-tertiary);
    background: var(--color-background-primary);
    color: var(--color-text-secondary);
    border-radius: 3px;
    cursor: pointer;
    font-size: 10px;
    font-weight: 700;
}

.toggle-btn.active {
    background: #14A3A3;
    color: #fff;
    border-color: #14A3A3;
}

.btn-add-item {
    width: 100%;
    padding: 4px;
    background: transparent;
    border: 0.5px dashed var(--color-border-tertiary);
    border-radius: 3px;
    color: var(--color-text-secondary);
    font-size: 10px;
    cursor: pointer;
    margin-top: 4px;
}

.btn-add-item:hover { border-color: #14A3A3; color: #14A3A3; }

/* Table editor */
.table-editor { width: 100%; border-collapse: collapse; font-size: 11px; }
.table-editor td { padding: 1px; }
.table-editor input {
    width: 100%;
    padding: 3px 5px;
    background: var(--color-background-primary);
    border: 0.5px solid var(--color-border-tertiary);
    border-radius: 2px;
    color: var(--color-text-primary);
    font-size: 10px;
}
.table-editor input:focus { outline: none; border-color: #14A3A3; }
.table-editor .header-row input { font-weight: 600; color: #14A3A3; }

/* ── Footer ── */
.footer {
    margin-top: 1rem;
    padding-top: 8px;
    border-top: 0.5px solid var(--color-border-tertiary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: var(--color-text-secondary);
}

.footer a {
    color: #14A3A3;
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border-tertiary); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-border-secondary); }
