/* PellEditor - Definitive Premium Overhaul */

:root {
    --pell-primary: #2563eb;
    --pell-bg: #ffffff;
    --pell-border: #e2e8f0;
    --pell-text: #1e293b;
    --pell-muted: #64748b;
    --pell-hover: #f1f5f9;
    --pell-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --pell-radius: 16px;
}

.pelleditor-wrapper {
    display: flex;
    flex-direction: column;
    background: var(--pell-bg);
    border: 1px solid var(--pell-border);
    border-radius: var(--pell-radius);
    margin-bottom: 24px;
    box-shadow: var(--pell-shadow);
    overflow: visible;
    transition: all 0.3s ease;
}

/* Action Bar */
.pell-actionbar {
    background: #f8fafc;
    border-bottom: 1px solid var(--pell-border);
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-radius: var(--pell-radius) var(--pell-radius) 0 0;
}

.pell-actionbar-left {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    flex: 1;
}

.pell-actionbar-right {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.pell-button {
    background: transparent;
    border: none;
    height: 36px;
    min-width: 36px;
    padding: 0 8px;
    border-radius: 10px;
    color: var(--pell-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    transition: all 0.2s;
}

.pell-button i { font-size: 16px; }
.pell-button:hover { background: var(--pell-hover); color: var(--pell-primary); }
.pell-button-selected { background: #dbeafe; color: var(--pell-primary); font-weight: 600; }
.pell-button-format { min-width: 130px !important; padding: 0 12px !important; }
.pell-button-format .pell-btn-text { white-space: nowrap; margin: 0 4px; }

/* Dropdowns */
.pell-dropdown { position: relative; }
.pell-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(12px);
    border: 1px solid var(--pell-border);
    border-radius: 14px;
    padding: 8px;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
    z-index: 10000;
    display: none;
    min-width: 220px;
}
.pell-dropdown-menu.show { display: block; animation: pellFadeIn 0.2s; }
.pell-dropdown-menu.color-grid { grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 12px; min-width: 0; }
.pell-dropdown-menu.color-grid.show { display: grid; }

.pell-dropdown-menu button {
    width: 100%; padding: 10px 14px; border: none; background: transparent;
    display: flex; align-items: center; gap: 12px; border-radius: 8px;
    cursor: pointer; color: var(--pell-text); font-size: 14px; transition: 0.2s;
}
.pell-dropdown-menu button:hover { background: var(--pell-hover); color: var(--pell-primary); }
.pell-dropdown-menu .divider { height: 1px; background: var(--pell-border); margin: 6px 0; }

.pell-dropdown-right .pell-dropdown-menu { left: auto; right: 0; }

/* Content Area */
.pell-content {
    min-height: 250px;
    height: auto;
    padding: 60px;
    outline: none;
    font-size: 16px;
    line-height: 1.8;
    color: var(--pell-text);
    background: #fff;
}

/* Critical Fix for Lists */
.pell-content ol { list-style-type: decimal !important; padding-left: 45px !important; margin: 1.2em 0 !important; }
.pell-content ul { list-style-type: disc !important; padding-left: 45px !important; margin: 1.2em 0 !important; }
.pell-content li { display: list-item !important; margin-bottom: 0.6em; }

/* Action Trigger (Floating Button) */
.pell-action-trigger {
    position: absolute;
    display: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--pell-primary);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10000;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    opacity: 0;
    transform: scale(0.8);
}
.pell-action-trigger.visible { opacity: 1; transform: scale(1); }
.pell-action-trigger:hover { transform: scale(1.1); background: #1d4ed8; }

/* Vertical Contextual Toolbar */
.pell-context-toolbar {
    position: absolute;
    display: none;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(15px);
    border: 1px solid var(--pell-border);
    border-radius: 16px;
    padding: 8px 0;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    z-index: 20000;
    flex-direction: column;
    min-width: 200px;
}
.pell-context-toolbar.show { display: flex; animation: pellFadeIn 0.2s; }

.pell-context-toolbar .close-tb {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 24px;
    height: 24px;
    background: #ef4444;
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.pell-context-toolbar button {
    width: 100%; padding: 12px 20px; border: none; background: transparent;
    display: flex; align-items: center; gap: 15px; cursor: pointer;
    font-size: 14px; color: var(--pell-text); transition: 0.2s;
}
.pell-context-toolbar button i { width: 22px; text-align: center; color: var(--pell-muted); font-size: 16px; }
.pell-context-toolbar button span { flex: 1; }
.pell-context-toolbar button:hover { background: var(--pell-hover); color: var(--pell-primary); }
.pell-context-toolbar button:hover i { color: var(--pell-primary); }
.pell-context-toolbar button.danger { color: #ef4444; }
.pell-context-toolbar button.danger:hover { background: #fef2f2; }
.pell-context-toolbar .sep { height: 1px; background: var(--pell-border); margin: 8px 0; }

/* Tables & Images */
.pell-content table { border-collapse: collapse; width: 100%; margin: 20px 0; border: 1px solid #e2e8f0; }
.pell-content td, .pell-content th { border: 1px solid #e2e8f0; padding: 12px; min-width: 50px; }
.pell-content img { max-width: 100%; height: auto; border-radius: 8px; transition: 0.3s; cursor: pointer; }
.pell-content img:hover { outline: 3px solid var(--pell-primary) !important; }

/* Status Bar (Word Count) */
.pell-status {
    background: #f8fafc;
    border-top: 1px solid var(--pell-border);
    padding: 6px 16px;
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    font-size: 12px;
    color: var(--pell-muted);
    border-radius: 0 0 var(--pell-radius) var(--pell-radius);
}
.pell-status span { font-weight: 600; color: var(--pell-text); }

/* Animations */
@keyframes pellFadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* Fullscreen */
.pelleditor-wrapper.full-screen {
    position: fixed; top: 0; left: 0; width: 100% !important; height: 100% !important;
    z-index: 999999; border-radius: 0; margin: 0;
}
.pelleditor-wrapper.full-screen .pell-content { height: calc(100vh - 90px); }

/* Mobile */
@media (max-width: 1024px) {
    .pell-button span { display: none; }
    .pell-button { min-width: 32px; height: 32px; padding: 0; }
}

@media (max-width: 768px) {
    .pell-content { padding: 30px 15px; }
    .pell-actionbar { padding: 8px; flex-wrap: wrap; height: auto; }
    .pell-context-toolbar { min-width: 160px; }
    .pell-context-toolbar button span { display: inline-block; }
}

/* Print Rules */
@media print {
    body * { visibility: hidden; }
    .pelleditor-wrapper, .pelleditor-wrapper * { visibility: visible; }
    .pelleditor-wrapper { position: absolute; left: 0; top: 0; width: 100%; border: none; box-shadow: none; }
    .pell-actionbar, .pell-status, .pell-action-trigger, .pell-context-toolbar { display: none !important; }
    .pell-content { padding: 0; }
}
