/**
 * P8s Admin Panel - Minimal Styles
 *
 * Clean, minimal interface with light/dark mode support.
 */

:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-hover: #fff7ed;
    /* Orange-50 tint */
    --text-primary: #1c1917;
    /* Warm gray-900 */
    --text-secondary: #57534e;
    /* Warm gray-600 */
    --border-color: #e7e5e4;
    /* Warm gray-200 */

    /* Fire Palette - Light Mode */
    --primary: #ea580c;
    /* Orange-600 */
    --primary-text: #ffffff;
    --primary-hover: #c2410c;
    /* Orange-700 */

    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --success: #059669;
    --success-bg: #ecfdf5;

    --radius: 8px;
    --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --header-height: 60px;
    --sidebar-width: 260px;
    --sidebar-collapsed: 64px;
}

[data-theme="dark"] {
    --bg-primary: #0c0a09;
    /* Warm gray-950 */
    --bg-secondary: #1c1917;
    /* Warm gray-900 */
    --bg-hover: #292524;
    /* Warm gray-800 */
    --text-primary: #fafaf9;
    /* Warm gray-50 */
    --text-secondary: #a8a29e;
    /* Warm gray-400 */
    --border-color: #292524;
    /* Warm gray-800 */

    /* Fire Palette - Dark Mode */
    --primary: #f97316;
    /* Orange-500 */
    --primary-text: #ffffff;
    --primary-hover: #ea580c;
    /* Orange-600 */

    --danger: #f87171;
    --danger-bg: rgba(248, 113, 113, 0.1);
    --success: #34d399;
    --success-bg: rgba(52, 211, 153, 0.1);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

/* Layout */
.admin-panel {
    display: flex;
    min-height: 100vh;
    background: var(--bg-primary);
}

.admin-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: margin-left 0.2s ease;
    display: flex;
    flex-direction: column;
}

.admin-sidebar.collapsed+.admin-main {
    margin-left: var(--sidebar-collapsed);
}

/* Layout Wrappers */
.list-wrapper {
    display: flex;
    width: 100%;
    align-items: stretch;
}

.list-wrapper .admin-list {
    flex: 1;
    width: 0;
    /* Critical for flex child to shrink properly */
    min-width: 0;
    padding-right: 24px;
    /* Add some space between list and sidebar */
}

.filter-sidebar {
    width: 280px;
    min-width: 280px;
    /* Prevent shrinking */
    background: var(--bg-primary);
    border-left: 1px solid var(--border-color);
    padding: 32px 24px;
    flex-shrink: 0;
    /* Ensure it stays fixed width */
}

.filter-group {
    margin-bottom: 24px;
}

.filter-group h4 {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 12px;
    font-weight: 600;
}

.filter-group ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.filter-group li {
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.filter-group li a {
    color: var(--text-primary);
    text-decoration: none;
    display: block;
    padding: 2px 0;
    transition: color 0.15s;
}

.filter-group li a:hover {
    color: var(--primary);
}

.filter-group li.selected a {
    color: var(--primary);
    font-weight: 600;
}

/* Sortable Headers */
.data-table th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s;
}

.data-table th.sortable:hover {
    background: var(--bg-hover);
}

.sort-indicator {
    display: inline-block;
    margin-left: 6px;
    color: var(--primary);
    font-size: 1.1em;
}

/* Views Container */
.admin-list,
.admin-form,
.admin-dashboard {
    padding: 32px;
    width: 100%;
}

.admin-form {
    background: var(--bg-primary);
    /* border: 1px solid var(--border-color); */
    /* Optional: remove border if it fills page */
    /* border-radius: var(--radius); */
    /* overflow: hidden; */
    /* max-width: 800px; REMOVED */
    /* margin: 0 auto; REMOVED */
}

.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.list-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.admin-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 50;
    transition: width 0.2s ease;
}

.admin-sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 0.95rem;
}


.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 8px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    margin-bottom: 2px;
    transition: all 0.1s;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--bg-hover);
    color: var(--text-primary);
    font-weight: 500;
}

.nav-icon {
    width: 20px;
    text-align: center;
    font-size: 1rem;
}

/* Global Header */
.global-header {
    height: var(--header-height);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 40;
}

/* Content Area */
.content-wrapper {
    padding: 32px;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

/* Typography */
h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0 0 24px 0;
    letter-spacing: -0.01em;
}

/* Dashboard */
.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 24px;
    margin-top: 16px;
}

.dashboard-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 24px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.dashboard-card:hover {
    border-color: var(--primary);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    transform: translateY(-4px);
}

.dashboard-card .card-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: var(--bg-secondary);
    border-radius: 12px;
    color: var(--primary);
    margin-bottom: 4px;
    transition: all 0.2s;
}

.dashboard-card:hover .card-icon {
    background: var(--primary);
    color: var(--primary-text);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 500;
}

.card-desc {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Tables */
/* Tables */
.data-table-container {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-primary);
    margin-bottom: 24px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-weight: 500;
    text-align: left;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover td {
    background: var(--bg-hover);
    cursor: pointer;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.page-buttons {
    display: flex;
    align-items: center;
    gap: 4px;
}

.btn-page {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-primary);
    transition: all 0.1s;
}

.btn-page:hover:not(:disabled) {
    background: var(--bg-hover);
    border-color: var(--text-secondary);
}

.btn-page:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--bg-secondary);
}

.page-size-select {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.9rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s;
    background: transparent;
    white-space: nowrap;
}

/* Form Actions (buttons container) */
.form-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 24px;
}

/* Popup Actions */
.popup-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    justify-content: flex-end;
}

.btn-primary {
    background: var(--primary);
    color: var(--primary-text);
    border-color: transparent;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--bg-primary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--bg-secondary);
    border-color: var(--text-secondary);
}

.btn-danger {
    color: var(--danger);
    background: var(--danger-bg);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

.btn-icon {
    padding: 8px;
    color: var(--text-secondary);
}

.btn-icon:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

/* Forms Container */
/* Forms Container */
/* .admin-form style is now handled in Layout section above */

.form-header {
    background: var(--bg-secondary);
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 16px;
    border-radius: var(--radius) var(--radius) 0 0;
    /* Add radius if we keep the card look */
}

/* We want the form to look integrated, so we might wrap the inner form in a card if needed */
.dynamic-form {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 0 0 var(--radius) var(--radius);
    padding: 32px;
}

/* Fix form header to match */
.form-header {
    border: 1px solid var(--border-color);
    border-bottom: none;
    border-radius: var(--radius) var(--radius) 0 0;
}

.form-header h1 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.btn-back {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 4px;
}

.btn-back:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Forms */
.form-input {
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: border-color 0.15s;
}

.form-input:focus {
    outline: none;
    border-color: var(--text-primary);
}

.dynamic-form {
    padding: 24px;
}

.form-group {
    margin-bottom: 24px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

.checkbox-group {
    display: flex;
    align-items: center;
}

/* Search Box */
.search-box {
    position: relative;
    max-width: 320px;
    width: 100%;
}

.search-box input {
    width: 100%;
    padding: 10px 16px 10px 42px;
    /* Space for icon */
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 12px center;
    background-size: 18px;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.1);
}

/* Custom Checkboxes */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
    padding: 4px 0;
}

.checkbox-label input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    cursor: pointer;
    position: relative;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.checkbox-label input[type="checkbox"]:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.checkbox-label input[type="checkbox"]:checked::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: translate(-50%, -60%) rotate(45deg);
}

.checkbox-label input[type="checkbox"]:focus {
    box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.1);
    border-color: var(--primary);
}

.help-text {
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Login */
.login-container {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
}

.login-box {
    width: 100%;
    max-width: 400px;
    background: var(--bg-primary);
    padding: 40px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

/* Utilities */
.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.gap-2 {
    gap: 8px;
}

.gap-4 {
    gap: 16px;
}

/* Badges */
.badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger);
}

/* Theme Toggle */
.theme-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 8px;
    border-radius: var(--radius);
}

.theme-toggle:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

/* Notification */
.notification {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    padding: 12px 24px;
    border-radius: var(--radius);
    background: var(--text-primary);
    color: var(--bg-primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-weight: 500;
    max-width: 90%;
    width: auto;
    text-align: center;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        transform: translate(-50%, -100%);
        opacity: 0;
    }

    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

.notification.success {
    background: var(--success);
    color: white;
}

.notification.error {
    background: var(--danger);
    color: white;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.modal-content {
    background: var(--bg-primary);
    border-radius: var(--radius);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    border: 1px solid var(--border-color);
}

.modal-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-body {
    padding: 0;
    /* DynamicForm has its own padding */
    overflow-y: auto;
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-close:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

/* ========================================
   Inline Editor Styles
   ======================================== */

.inline-editor {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.inline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.inline-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.btn-add-inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-add-inline:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
    color: var(--primary);
}

/* Tabular Inline */
.tabular-inline .inline-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
}

.tabular-inline .inline-table th {
    background: var(--bg-secondary);
    padding: 10px 12px;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: capitalize;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

.tabular-inline .inline-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
}

.tabular-inline .inline-table tr:last-child td {
    border-bottom: none;
}

.tabular-inline .row-new {
    background: var(--success-bg);
}

.th-drag,
.td-drag {
    width: 32px;
    text-align: center;
}

.drag-handle {
    color: var(--text-secondary);
    cursor: grab;
}

.th-actions,
.td-actions {
    width: 48px;
    text-align: center;
}

.inline-input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.inline-input:focus {
    outline: none;
    border-color: var(--primary);
}

.inline-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.btn-delete-inline {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-delete-inline:hover {
    color: var(--danger);
    background: var(--danger-bg);
}

.required {
    color: var(--danger);
    margin-left: 2px;
}

.inline-empty {
    color: var(--text-secondary);
    font-size: 0.9rem;
    padding: 24px;
    text-align: center;
    background: var(--bg-secondary);
    border-radius: var(--radius);
}

/* Stacked Inline */
.stacked-inline .stacked-items {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.stacked-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
}

.stacked-item.item-new {
    border-color: var(--success);
}

.stacked-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
}

.item-title {
    font-weight: 500;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.badge-new {
    font-size: 0.7rem;
    padding: 2px 6px;
    background: var(--success-bg);
    color: var(--success);
    border-radius: 4px;
}

.stacked-item-fields {
    padding: 16px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.stacked-field label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: capitalize;
}

/* =============================================================================
   RICH TEXT EDITOR (Google Docs Style)
   ============================================================================= */

.richtext-editor {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-primary);
}

.richtext-editor.modern {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.richtext-editor.disabled {
    opacity: 0.6;
    pointer-events: none;
}

/* Toolbar */
.richtext-toolbar {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 6px 12px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 2px;
}

.toolbar-btn {
    padding: 6px 8px;
    min-width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    color: #64748b;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toolbar-btn:hover {
    background: #e2e8f0;
    color: #1e293b;
}

.toolbar-btn.active {
    background: #3b82f6;
    color: white;
}

.toolbar-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.heading-select {
    padding: 6px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    background: white;
    color: #374151;
    font-size: 13px;
    cursor: pointer;
    min-width: 100px;
}

.heading-select:hover {
    border-color: #94a3b8;
}

.toolbar-divider {
    width: 1px;
    height: 24px;
    background: #e2e8f0;
    margin: 0 8px;
}

/* Link Input Popup */
.link-input-popup {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #f1f5f9;
    border-bottom: 1px solid var(--border-color);
}

.link-input-popup input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-size: 13px;
}

.link-input-popup input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.link-input-popup .btn-apply {
    padding: 8px 16px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
}

.link-input-popup .btn-apply:hover {
    background: #2563eb;
}

.link-input-popup .btn-remove {
    padding: 8px 16px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
}

.link-input-popup .btn-cancel {
    padding: 8px 16px;
    background: #e2e8f0;
    color: #475569;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
}

/* Bubble Menu */
.bubble-menu {
    display: flex;
    background: #1e293b;
    border-radius: 6px;
    padding: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.bubble-menu button {
    padding: 6px 10px;
    background: transparent;
    border: none;
    color: #e2e8f0;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 4px;
}

.bubble-menu button:hover {
    background: rgba(255, 255, 255, 0.1);
}

.bubble-menu button.active {
    background: #3b82f6;
    color: white;
}

/* Editor Content Area */
.richtext-content {
    padding: 24px;
    min-height: 300px;
    background: white;
}

.richtext-content .ProseMirror {
    outline: none;
    min-height: 250px;
    font-size: 16px;
    line-height: 1.7;
    color: #1e293b;
}

/* Placeholder */
.richtext-content .ProseMirror p.is-editor-empty:first-child::before {
    color: #94a3b8;
    content: attr(data-placeholder);
    float: left;
    height: 0;
    pointer-events: none;
    font-style: italic;
}

/* Headings */
.richtext-content .ProseMirror h1 {
    font-size: 2em;
    font-weight: 700;
    margin: 1em 0 0.5em;
    color: #0f172a;
    line-height: 1.3;
}

.richtext-content .ProseMirror h2 {
    font-size: 1.5em;
    font-weight: 600;
    margin: 0.8em 0 0.4em;
    color: #1e293b;
    line-height: 1.4;
}

.richtext-content .ProseMirror h3 {
    font-size: 1.25em;
    font-weight: 600;
    margin: 0.6em 0 0.3em;
    color: #334155;
    line-height: 1.4;
}

/* Paragraphs */
.richtext-content .ProseMirror p {
    margin: 0.5em 0;
}

/* Lists */
.richtext-content .ProseMirror ul,
.richtext-content .ProseMirror ol {
    padding-left: 1.5em;
    margin: 0.5em 0;
}

.richtext-content .ProseMirror li {
    margin: 0.25em 0;
}

.richtext-content .ProseMirror ul {
    list-style-type: disc;
}

.richtext-content .ProseMirror ol {
    list-style-type: decimal;
}

/* Blockquote */
.richtext-content .ProseMirror blockquote {
    border-left: 4px solid #3b82f6;
    margin: 1em 0;
    padding: 0.5em 1em;
    background: #f1f5f9;
    border-radius: 0 4px 4px 0;
    color: #475569;
    font-style: italic;
}

/* Code Block */
.richtext-content .ProseMirror pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 16px;
    border-radius: 6px;
    font-family: 'Fira Code', 'Monaco', monospace;
    font-size: 14px;
    overflow-x: auto;
    margin: 1em 0;
}

.richtext-content .ProseMirror code {
    background: #f1f5f9;
    color: #e11d48;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Fira Code', 'Monaco', monospace;
    font-size: 0.9em;
}

.richtext-content .ProseMirror pre code {
    background: transparent;
    color: inherit;
    padding: 0;
}

/* Links */
.richtext-content .ProseMirror a,
.richtext-content .ProseMirror .editor-link {
    color: #3b82f6;
    text-decoration: underline;
    cursor: pointer;
}

.richtext-content .ProseMirror a:hover {
    color: #2563eb;
}

/* Horizontal Rule */
.richtext-content .ProseMirror hr {
    border: none;
    border-top: 2px solid #e2e8f0;
    margin: 2em 0;
}

/* Highlight */
.richtext-content .ProseMirror mark {
    background: #fef08a;
    padding: 2px 0;
}

/* Text Alignment */
.richtext-content .ProseMirror [style*="text-align: center"] {
    text-align: center;
}

.richtext-content .ProseMirror [style*="text-align: right"] {
    text-align: right;
}

.richtext-content .ProseMirror [style*="text-align: justify"] {
    text-align: justify;
}

/* Full Screen Mode */
.richtext-editor.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    background: white;
    border-radius: 0;
    border: none;
    display: flex;
    flex-direction: column;
}

.richtext-editor.fullscreen .richtext-toolbar {
    padding: 12px 24px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.richtext-editor.fullscreen .richtext-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px calc(50% - 400px);
    /* Centered document view */
    background: #f1f5f9;
}

.richtext-editor.fullscreen .richtext-content .ProseMirror {
    min-height: 100%;
    background: white;
    padding: 48px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    border-radius: 8px;
}

/* Toolbar Button Special Styles */
.popup-label {
    font-size: 13px;
    font-weight: 500;
    color: #475569;
    margin-bottom: 8px;
    display: block;
}

/* Editor Popup (New Design) */
.editor-popup-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.2);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.editor-popup {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    width: 400px;
    max-width: 90vw;
    display: flex;
    flex-direction: column;
    gap: 16px;
    animation: popupFadeIn 0.2s ease-out;
    border: 1px solid #e2e8f0;
}

@keyframes popupFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.popup-header {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 4px;
}

.popup-tabs {
    display: flex;
    gap: 16px;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 12px;
}

.popup-tab {
    padding: 8px 0;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    color: #64748b;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.popup-tab:hover {
    color: #1e293b;
}

.popup-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 500;
}

.popup-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
}

.popup-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.9rem;
}

.popup-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.1);
}

.btn-popup-primary {
    padding: 8px 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
}

.btn-popup-secondary {
    padding: 8px 16px;
    background: white;
    border: 1px solid #cbd5e1;
    color: #475569;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
}

.btn-popup-secondary:hover {
    background: #f1f5f9;
}

.drop-zone {
    border: 2px dashed #cbd5e1;
    border-radius: 8px;
    padding: 32px;
    text-align: center;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s;
    background: #f8fafc;
}

.drop-zone:hover {
    border-color: var(--primary);
    background: #fff7ed;
    color: var(--primary);
}

/* Media Styling */
.richtext-content .ProseMirror img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 1em 0;
    display: block;
}

.richtext-content .ProseMirror img.ProseMirror-selectednode {
    outline: 3px solid #60a5fa;
}

.richtext-content .ProseMirror div[data-youtube-video] {
    cursor: move;
    max-width: 640px;
    width: 100%;
    margin: 1.5em auto;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.richtext-content .ProseMirror div[data-youtube-video] iframe {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    display: block;
    border: none;
}

/* Float styling for images/media if aligned */
.richtext-content .ProseMirror [style*="text-align: center"] img,
.richtext-content .ProseMirror [style*="text-align: center"] iframe {
    margin-left: auto;
    margin-right: auto;
}

.richtext-content .ProseMirror [style*="text-align: right"] img,
.richtext-content .ProseMirror [style*="text-align: right"] iframe {
    margin-left: auto;
    margin-right: 0;
    display: block;
    border: none;
}

/* Tables */
.richtext-content .ProseMirror {
    /* Ensure tables can scroll if needed */
    overflow-x: auto;
}

.richtext-content .ProseMirror table {
    border-collapse: collapse;
    margin: 0;
    overflow: hidden;
    table-layout: fixed;
    width: 100%;
}

.richtext-content .ProseMirror table td,
.richtext-content .ProseMirror table th {
    border: 1px solid #ced4da;
    box-sizing: border-box;
    min-width: 1em;
    padding: 6px 8px;
    position: relative;
    vertical-align: top;
}

.richtext-content .ProseMirror table th {
    font-weight: bold;
    text-align: left;
    background-color: #f1f3f5;
}

.richtext-content .ProseMirror table .selectedCell:after {
    z-index: 2;
    position: absolute;
    content: "";
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    background: rgba(200, 200, 255, 0.4);
    pointer-events: none;
}

.richtext-content .ProseMirror table .column-resize-handle {
    background-color: #adf;
    bottom: -2px;
    position: absolute;
    right: -2px;
    pointer-events: none;
    top: 0;
    width: 4px;
}

/* Footer & Character Count */
.richtext-footer {
    padding: 8px 12px;
    background: #f8fafc;
    border-top: 1px solid var(--border-color);
    font-size: 11px;
    color: #64748b;
    display: flex;
    justify-content: flex-end;
}

/* Slash Command Menu */
.slash-command-menu {
    background: white;
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    padding: 8px;
    width: 280px;
    max-height: 300px;
    overflow-y: auto;
}

.slash-command-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    color: #1e293b;
}

.slash-command-item:hover,
.slash-command-item.is-selected {
    background: #f1f5f9;
}

.slash-command-label {
    display: flex;
    flex-direction: column;
}

.slash-command-label .title {
    font-size: 14px;
    font-weight: 500;
}

.slash-command-label .description {
    font-size: 11px;
    color: #64748b;
}

.slash-command-empty {
    padding: 12px;
    font-size: 13px;
    color: #64748b;
    text-align: center;
}

/* Bubble Menu */
.bubble-menu {
    display: flex;
    background-color: #0D0D0D;
    padding: 0.2rem;
    border-radius: 0.5rem;
}

.bubble-menu button {
    border: none;
    background: none;
    color: #FFF;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0 0.2rem;
    opacity: 0.6;
}

.bubble-menu button:hover,
.bubble-menu button.is-active {
    opacity: 1;
}

/* =============================================================================
   COLOR PICKER
   ============================================================================= */

.color-picker-field {
    position: relative;
}

.color-picker-field.disabled {
    opacity: 0.6;
    pointer-events: none;
}

.color-picker-input {
    display: flex;
    align-items: center;
    gap: 12px;
}

.color-swatch {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    border: 2px solid var(--border-color);
    cursor: pointer;
    transition: border-color 0.15s;
}

.color-swatch:hover {
    border-color: var(--text-secondary);
}

.color-hex-input {
    width: 120px !important;
    text-transform: uppercase;
    font-family: monospace;
}

.color-picker-popover {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 8px;
    z-index: 100;
}

.color-picker-cover {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
}

.color-picker-popover .react-colorful {
    width: 200px;
    height: 160px;
    border-radius: var(--radius);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

/* =============================================================================
   TAGS INPUT
   ============================================================================= */

.tags-input {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 8px;
    background: var(--bg-primary);
    transition: border-color 0.15s;
}

.tags-input:focus-within {
    border-color: var(--text-primary);
}

.tags-input.disabled {
    opacity: 0.6;
    pointer-events: none;
}

.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--primary);
    color: var(--primary-text);
    border-radius: 16px;
    font-size: 0.85rem;
}

.tag-remove {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 1.1em;
    line-height: 1;
    padding: 0;
    margin-left: 2px;
    opacity: 0.8;
}

.tag-remove:hover {
    opacity: 1;
}

.tag-input {
    border: none;
    background: transparent;
    outline: none;
    flex: 1;
    min-width: 100px;
    padding: 4px;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.tag-input::placeholder {
    color: var(--text-secondary);
}

/* =============================================================================
   CODE EDITOR
   ============================================================================= */

.code-editor {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
}

.code-editor.disabled {
    opacity: 0.6;
    pointer-events: none;
}

.code-editor-header {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.code-language-badge {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    font-weight: 600;
}

.code-editor-content .cm-editor {
    font-size: 0.9rem;
}

.code-editor-content .cm-focused {
    outline: none;
}

/* =============================================================================
   FONT & COLOR PICKER TOOLBAR CONTROLS
   ============================================================================= */

.richtext-toolbar .font-select,
.richtext-toolbar .size-select {
    padding: 4px 8px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 12px;
    background: white;
    cursor: pointer;
    min-width: 80px;
}

.richtext-toolbar .size-select {
    min-width: 60px;
}

.richtext-toolbar .font-select:focus,
.richtext-toolbar .size-select:focus {
    outline: none;
    border-color: var(--primary);
}

.color-pickers {
    display: flex;
    gap: 4px;
}

.color-picker-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 56px;
    height: 28px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    background: white;
}

.color-picker-wrapper:hover {
    border-color: var(--text-secondary);
}

.color-picker-wrapper .color-input {
    position: absolute;
    left: 24px;
    top: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    border: none;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
}

.color-picker-wrapper .color-input::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-picker-wrapper .color-input::-webkit-color-swatch {
    border: none;
    border-radius: 0;
}
