/* ================================================
   RICH TEXT EDITOR - Modern Single Layer
   Clean contenteditable-based implementation
   ================================================ */

.rich-text-editor-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.2s ease;
    /* Removed margin-top and margin-bottom */
}

.rich-text-editor-wrapper:focus-within {
    border-color: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.rich-text-editor {
    /* Layout */
    flex: 1;
    height: 100%;
    min-height: 500px;
    max-height: 600px;
    padding: 16px 24px;
    /* Slightly reduced top padding */

    /* Typography - FORCED BLACK TEXT */
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif !important;
    font-size: 1rem !important;
    font-weight: 400 !important;
    line-height: 1.5;
    color: #000000 !important;
    -webkit-text-fill-color: #000000 !important;

    /* Background - WHITE */
    background-color: #ffffff !important;

    /* Text behavior */
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;

    /* Scrolling */
    overflow-y: auto;
    overflow-x: hidden;

    /* Interaction */
    outline: none;
    cursor: text;

    /* Rendering */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Placeholder */
.rich-text-editor:empty:before {
    content: attr(data-placeholder);
    color: #94a3b8;
    pointer-events: none;
    display: block;
    /* Changed from position:absolute to avoid interference */
}

/* Scrollbar styling */
.rich-text-editor::-webkit-scrollbar {
    width: 8px;
}

.rich-text-editor::-webkit-scrollbar-track {
    background: transparent;
}

.rich-text-editor::-webkit-scrollbar-thumb {
    background: rgba(203, 213, 225, 0.5);
    border-radius: 4px;
}

.rich-text-editor::-webkit-scrollbar-thumb:hover {
    background: rgba(203, 213, 225, 0.8);
}

/* ================================================
   PILL STYLES - Mentions, Dates, Files
   ================================================ */

.mention-pill,
.date-pill,
.file-pill {
    display: inline;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.95em;
    white-space: nowrap;
    transition: all 0.15s ease;
}

/* Mention Pills (@name) */
.mention-pill {
    background: linear-gradient(135deg, rgba(147, 51, 234, 0.1) 0%, rgba(147, 51, 234, 0.2) 100%);
    color: #9333ea;
    box-shadow: 0 0 0 1px rgba(147, 51, 234, 0.2);
}

.mention-pill.group {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(59, 130, 246, 0.2) 100%);
    color: #2563eb;
    box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.2);
}

/* Date Pills (#date#) */
.date-pill {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(16, 185, 129, 0.2) 100%);
    color: #059669;
    box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.2);
}

/* File Pills ($[file]) */
.file-pill {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.1) 0%, rgba(245, 158, 11, 0.2) 100%);
    color: #d97706;
    box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.2);
    cursor: pointer;
}

.file-pill:hover {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.15) 0%, rgba(245, 158, 11, 0.25) 100%);
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.3);
}

/* Selection styling */
.rich-text-editor::selection {
    background: rgba(59, 130, 246, 0.2);
}

.rich-text-editor::-moz-selection {
    background: rgba(59, 130, 246, 0.2);
}

.mention-pill::selection,
.date-pill::selection,
.file-pill::selection {
    background: rgba(59, 130, 246, 0.3);
}

/* Focus state */
.rich-text-editor:focus {
    outline: none;
}

/* Mobile optimization */
@media (max-width: 768px) {
    .rich-text-editor {
        font-size: 16px;
        /* Prevent iOS zoom */
        padding: 16px;
        min-height: 300px;
    }

    .mention-pill,
    .date-pill,
    .file-pill {
        padding: 3px 8px;
        font-size: 0.9em;
    }
}

/* ================================================
   AUTOCOMPLETE MENU
   ================================================ */

.rte-autocomplete {
    position: fixed;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    max-height: 300px;
    min-width: 200px;
    overflow-y: auto;
    z-index: 10000;
}

.rte-autocomplete-item {
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.rte-autocomplete-item:first-child {
    border-radius: 12px 12px 0 0;
}

.rte-autocomplete-item:last-child {
    border-radius: 0 0 12px 12px;
}

.rte-autocomplete-item:hover,
.rte-autocomplete-item.selected {
    background: #eff6ff;
}

.rte-autocomplete-icon {
    font-size: 1.1rem;
    width: 24px;
    height: 24px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rte-autocomplete-photo {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
}

.rte-autocomplete-text {
    font-weight: 500;
    color: #1e293b;
}

/* ================================================
   DATE PICKER
   ================================================ */

.rte-datepicker {
    position: fixed;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    padding: 16px;
    z-index: 10000;
    min-width: 300px;
}

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

.rte-datepicker-title {
    font-weight: 700;
    font-size: 1.1rem;
    color: #1e293b;
}

.rte-datepicker-nav {
    background: #f1f5f9;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.15s ease;
}

.rte-datepicker-nav:hover {
    background: #e2e8f0;
}

.rte-datepicker-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-bottom: 8px;
}

.rte-datepicker-weekdays>div {
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
    padding: 8px 0;
}

.rte-datepicker-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.rte-datepicker-day {
    text-align: center;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.15s ease;
}

.rte-datepicker-day:hover:not(.empty) {
    background: #eff6ff;
}

.rte-datepicker-day.empty {
    cursor: default;
}

.rte-datepicker-day.start,
.rte-datepicker-day.end {
    background: #10b981 !important;
    color: white !important;
}

.rte-datepicker-day.in-range {
    background: rgba(16, 185, 129, 0.15);
    color: #059669;
}

.rte-datepicker-footer {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e2e8f0;
}

.rte-datepicker-selection {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 0.9rem;
    color: #64748b;
}

.rte-datepicker-selection strong {
    color: #1e293b;
}

.rte-datepicker-confirm {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.rte-datepicker-confirm:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.rte-datepicker-confirm:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
}

/* ================================================
   PILL ENHANCEMENTS
   ================================================ */

.mention-pill,
.date-pill,
.file-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.95em;
    white-space: nowrap;
    vertical-align: baseline;
    margin: 0 2px;
}

.mention-pill {
    background: linear-gradient(135deg, rgba(147, 51, 234, 0.15) 0%, rgba(147, 51, 234, 0.25) 100%);
    color: #9333ea;
    border: 1px solid rgba(147, 51, 234, 0.3);
}

.mention-pill.group {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, rgba(59, 130, 246, 0.25) 100%);
    color: #2563eb;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.date-pill {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(16, 185, 129, 0.25) 100%);
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.file-pill {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.15) 0%, rgba(245, 158, 11, 0.25) 100%);
    color: #d97706;
    border: 1px solid rgba(245, 158, 11, 0.3);
    cursor: pointer;
}

.file-pill:hover {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.2) 0%, rgba(245, 158, 11, 0.3) 100%);
}