/* Moti Writer CSS - sozpaed.net angepasst (warm, neutral) */

/* --- Variables - warme, neutrale Palette für sozpaed.net --- */
:root {
    --moti-primary: #2d2a26;
    /* Warmes Dunkelgrau */
    --moti-secondary: #2098cd;
    /* Main buttons */
    --moti-accent: #3bbeec;
    /* Unterbuttons */
    --moti-success: #059669;
    /* Grün - Erfolg */
    --moti-warning: #d97706;
    /* Amber */
    --moti-purple: #3bbeec;
    /* Unterbuttons */
    --moti-teal: #2098cd;
    /* Main buttons */
    --moti-secondary-hover: #004d68;
    /* Hover für beide */
    --moti-bg: #f8f7f5;
    /* Warmes Off-White / Creme */
    --moti-card-bg: #ffffff;
    --moti-text: #2d2a26;
    /* Warmes Dunkelgrau */
    --moti-text-light: #6b6560;
    /* Warmes Grau */
    --moti-border: #e5e3df;
    /* Warme Border */
    --moti-radius: 16px;
    --moti-shadow: 0 10px 15px -3px rgba(45, 42, 38, 0.08), 0 4px 6px -2px rgba(45, 42, 38, 0.04);
    --moti-shadow-lg: 0 20px 25px -5px rgba(45, 42, 38, 0.1), 0 10px 10px -5px rgba(45, 42, 38, 0.04);
}

/* --- Layout --- */
.moti-writer-container {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--moti-text);
    background: var(--moti-bg);
    padding: 30px;
    border-radius: var(--moti-radius);
    display: flex;
    flex-direction: column;
    gap: 30px;
    max-width: 1400px;
    /* Reduced slightly for focus */
    margin: 0 auto;
    box-sizing: border-box;
}

.moti-header {
    text-align: left;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--moti-border);
    padding-bottom: 20px;
}

.moti-header h2 {
    color: var(--moti-primary);
    margin: 0;
    font-size: 2.75rem;
    font-weight: 900;
    letter-spacing: -0.03em;
    /* Solid color - sozpaed.net angepasst */
}

.moti-header p {
    font-size: 1.25rem;
    color: var(--moti-text-light);
    margin-top: 12px;
    max-width: 700px;
    line-height: 1.6;
    font-weight: 400;
}

/* --- Filter Bar (Top) --- */
.moti-step-label {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--moti-text-light);
    margin: 0 0 10px 0;
}

.moti-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: flex-start;
    padding-bottom: 10px;
}

.moti-filter-btn {
    background: var(--moti-card-bg);
    border: 2px solid var(--moti-border);
    padding: 12px 24px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 700;
    font-size: 1rem;
    color: var(--moti-text);
    box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
}

.moti-filter-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
}

.moti-filter-btn:hover::before {
    left: 100%;
}

.moti-filter-btn:hover {
    background: linear-gradient(135deg, #faf9f7 0%, #f8f7f5 100%);
    border-color: var(--moti-secondary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px -2px rgba(32, 152, 205, 0.25);
}

.moti-filter-btn.active {
    background: var(--moti-secondary);
    color: white;
    border-color: var(--moti-secondary);
    box-shadow: 0 6px 20px -4px rgba(32, 152, 205, 0.35);
    transform: translateY(-2px);
}

.moti-filter-btn.active:hover {
    background: var(--moti-secondary-hover);
    border-color: var(--moti-secondary-hover);
}

/* --- Main Editor Layout --- */
.moti-editor-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    /* Fixed Sidebar, Flex Content */
    gap: 40px;
    align-items: start;
}

@media (max-width: 1024px) {
    .moti-editor-layout {
        grid-template-columns: 1fr;
    }
}

/* --- Sidebar (Snippet Selection) --- */
.moti-sidebar {
    /* Sticky behaviour */
    position: sticky;
    top: 20px;
    height: calc(100vh - 40px);
    overflow-y: auto;

    padding-right: 15px;
    /* Space for scrollbar */
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Scrollbar styling */
.moti-sidebar::-webkit-scrollbar {
    width: 6px;
}

.moti-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.moti-sidebar::-webkit-scrollbar-thumb {
    background-color: #d4d1cc;
    border-radius: 20px;
}

.moti-sidebar h3 {
    margin: 0 0 16px 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--moti-text-light);
    letter-spacing: 0.02em;
}

.moti-search-input {
    width: 100%;
    padding: 12px 16px 12px 40px;
    border: 2px solid var(--moti-border);
    border-radius: 10px;
    font-size: 0.95rem;
    margin-bottom: 20px;
    background: var(--moti-card-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='%236b6560' viewBox='0 0 24 24'%3E%3Cpath d='M15.5 14h-.79l-.28-.27A6.47 6.47 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'/%3E%3C/svg%3E") no-repeat 14px center;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.moti-search-input:focus {
    outline: none;
    border-color: var(--moti-secondary);
    box-shadow: 0 0 0 3px rgba(32, 152, 205, 0.15);
}

.moti-search-input::placeholder {
    color: var(--moti-text-light);
}

/* Section Tabs - Unterkategorien */
.moti-section-tabs {
    display: none;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.moti-section-tabs.moti-section-tabs-visible {
    display: flex;
}

.moti-section-tab {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    border: 2px solid var(--moti-border);
    border-radius: 8px;
    background: var(--moti-card-bg);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--moti-text);
    cursor: pointer;
    transition: all 0.25s ease;
    text-align: center;
}

.moti-section-tab:hover:not(.disabled) {
    border-color: var(--moti-accent);
    background: #e0f7ff;
    transform: translateY(-1px);
}

.moti-section-tab.active {
    border-color: var(--moti-accent);
    background: var(--moti-accent);
    color: white;
}

.moti-section-tab.active:hover {
    background: var(--moti-secondary-hover);
    border-color: var(--moti-secondary-hover);
}

.moti-section-tab.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.moti-tab-count {
    font-size: 0.7rem;
    opacity: 0.9;
}

.moti-section-tab.active .moti-tab-count {
    opacity: 0.85;
}

@media (max-width: 600px) {
    .moti-section-tabs {
        flex-direction: column;
    }
    .moti-section-tab {
        flex: none;
        width: 100%;
    }
}

.moti-no-snippets {
    color: var(--moti-text-light);
    font-size: 0.95rem;
    padding: 24px 16px;
    text-align: center;
    margin: 0;
}

/* Smooth section transition */
.moti-snippet-fade-out {
    opacity: 0.6;
    transition: opacity 0.15s ease;
}

.moti-snippet-fade-in {
    animation: motiFadeIn 0.2s ease forwards;
}

@keyframes motiFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Snippet Cards */
.moti-snippet-item {
    background: linear-gradient(135deg, #ffffff 0%, #faf9f7 100%);
    border: 2px solid var(--moti-border);
    padding: 18px;
    margin-bottom: 14px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.moti-snippet-item:hover {
    transform: translateY(-4px) scale(1.01);
    border-color: var(--moti-secondary);
    box-shadow: var(--moti-shadow-lg);
    background: linear-gradient(135deg, #ffffff 0%, #e0f7ff 100%);
}

.moti-snippet-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    background: transparent;
    transition: all 0.3s;
    border-radius: 12px 0 0 12px;
}

.moti-snippet-item:hover::before {
    background: var(--moti-secondary);
    width: 6px;
}

.moti-snippet-label {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    color: var(--moti-primary);
    margin-bottom: 6px;
    letter-spacing: -0.01em;
}

.moti-snippet-preview {
    font-size: 0.85rem;
    color: var(--moti-text-light);
    line-height: 1.5;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-weight: 400;
}

.moti-snippet-tooltip {
    position: absolute;
    left: 100%;
    top: 0;
    margin-left: 8px;
    width: 280px;
    max-height: 200px;
    overflow-y: auto;
    padding: 12px;
    background: white;
    border-radius: 8px;
    box-shadow: var(--moti-shadow-lg);
    border: 1px solid var(--moti-border);
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--moti-text);
    white-space: pre-wrap;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-8px);
    transition: opacity 0.2s, visibility 0.2s, transform 0.2s;
    z-index: 100;
    pointer-events: none;
}

.moti-snippet-item:hover .moti-snippet-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

@media (max-width: 1024px) {
    .moti-snippet-tooltip {
        left: 0;
        right: 0;
        width: auto;
        max-width: none;
        top: 100%;
        margin: 8px 0 0 0;
    }
    .moti-snippet-item:hover .moti-snippet-tooltip {
        transform: translateY(0);
    }
}

/* --- Preview Area (The Letter) --- */
.moti-preview {
    background: var(--moti-card-bg);
    border-radius: var(--moti-radius);
    padding: 50px;
    box-shadow: var(--moti-shadow);
    border: 1px solid var(--moti-border);
    min-height: 800px;
    position: relative;
}

.moti-preview h3 {
    margin-top: 0;
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--moti-primary);
    border-bottom: 3px solid var(--moti-secondary);
    padding-bottom: 20px;
    margin-bottom: 35px;
    letter-spacing: -0.02em;
}

#moti-live-preview {
    min-height: 600px;
    outline: none;
    line-height: 1.7;
    font-size: 0.95rem;
    color: #2d2a26;
    font-family: 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-weight: 400;
    letter-spacing: 0.01em;
}

.moti-preview-placeholder {
    color: var(--moti-text-light);
    font-style: italic;
    margin: 0;
}

.moti-preview-block {
    position: relative;
    margin-bottom: 24px;
    padding-right: 36px;
}

.moti-preview-block:last-child {
    margin-bottom: 0;
}

.moti-preview-block-text {
    white-space: pre-wrap;
    outline: none;
    min-height: 1.5em;
}

.moti-preview-block-text:focus {
    outline: none;
}

.moti-preview-block-delete {
    position: absolute;
    top: 0;
    right: 0;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: var(--moti-bg);
    color: var(--moti-text-light);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
    opacity: 0.7;
}

.moti-preview-block:hover .moti-preview-block-delete {
    opacity: 1;
}

.moti-preview-block-delete:hover {
    background: #fee2e2;
    color: #dc2626;
}

/* --- Actions Bar --- */
.moti-actions {
    position: sticky;
    /* Make actions stick to bottom of preview area? No, bottom of container */
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    margin-top: 20px;
    display: flex;
    justify-content: flex-end;
    /* Align right */
    gap: 15px;
    border-top: 1px solid var(--moti-border);
    padding: 20px 0 0 0;
}

.moti-btn {
    padding: 12px 24px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.moti-btn-primary {
    background: var(--moti-secondary);
    color: white;
    font-weight: 700;
    font-size: 1.05rem;
    padding: 14px 28px;
}

.moti-btn-primary:hover {
    background: var(--moti-secondary-hover);
    transform: translateY(-2px);
    box-shadow: var(--moti-shadow-lg);
}

/* Popup Notification */
.moti-toast-overlay {
    position: fixed;
    inset: 0;
    background: rgba(45, 42, 38, 0.4);
    backdrop-filter: blur(4px);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.moti-toast-overlay.show {
    opacity: 1;
    visibility: visible;
}

.moti-toast {
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 1.1rem;
    padding: 24px 40px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    color: var(--moti-primary);
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    align-items: center;
    gap: 14px;
    border: 2px solid var(--moti-success);
}

.moti-toast.show {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.moti-toast.moti-toast-error {
    border-color: #e74c3c;
}

.moti-toast-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--moti-success) 0%, #059669 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.25rem;
    line-height: 1;
}

.moti-toast.moti-toast-error .moti-toast-icon {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
}