/**
 * FEP Modern Styles
 * Overrides Front End PM defaults to match fernarbeit.net design.
 */

/* ── Wrapper ── */
#fep-wrapper {
    font-family: MartelSans-Regular, sans-serif;
    color: #4b4b4b;
    font-size: 16px;
}

/* ── Header ── */
#fep-header {
    padding: 0 0 16px 0;
    border-bottom: 1px solid #f0f0f0;
    margin-bottom: 8px;
}

#fep-header strong {
    font-family: MartelSans-ExtraBold, sans-serif;
    font-size: 18px;
    color: #4b4b4b;
}

/* ── Menu Buttons ── */
#fep-menu {
    padding-top: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #f0f0f0;
    margin-bottom: 4px;
}

#fep-menu .fep-button,
.fep-button,
.fep-button-active {
    border-radius: 4px;
    transition: background-color 0.2s ease;
    font-size: 0.85rem;
    padding: 0.45rem 1.2rem 0.35rem;
    letter-spacing: 0.02em;
}

/* ── Content Area ── */
#fep-content {
    border: none;
    padding: 16px 0;
    margin-top: 4px;
    overflow: visible;
}

/* ── Search Form ── */
.fep-messagebox-search-form-div {
    margin-bottom: 16px;
}

.fep-messagebox-search-form-div input[type="text"],
.fep-messagebox-search-form-div .fep-messagebox-search-form-field {
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 15px;
    font-family: inherit;
    width: 100%;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.fep-messagebox-search-form-div input[type="text"]:focus {
    border-color: #00afdb;
    outline: none;
}

/* ── Action Table / Filters ── */
.fep-action-table {
    margin-bottom: 12px;
    padding: 10px 0;
}

.fep-action-table select {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    margin-top: 0;
}

.fep-action-table .fep-button {
    font-size: 0.8rem;
    padding: 0.4rem 1rem;
}

/* ── Message List ── */
#fep-table.fep-table {
    display: block;
}

#fep-table .fep-table-row {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.15s ease;
    gap: 12px;
}

#fep-table .fep-table-row:last-child {
    border-bottom: none;
}

#fep-table .fep-table-row:hover {
    background-color: #f8f9fa;
}

/* Message row columns */
#fep-table .fep-column {
    display: block;
}

#fep-table .fep-column-fep-cb {
    flex: 0 0 24px;
    padding-right: 0;
}

#fep-table .fep-column-avatar {
    flex: 0 0 auto;
    padding-right: 0;
}

/* Hide avatar containers only if they have no images */
.fep-header-avatar:empty {
    display: none;
}

#fep-table .fep-column-author {
    flex: 0 0 160px;
    min-width: auto;
}

#fep-table .fep-column-title {
    flex: 1;
    min-width: 0;
}

.fep-message-author {
    font-size: 15px;
    font-weight: 600;
    color: #4b4b4b;
    display: block;
}

.fep-message-date {
    font-size: 13px;
    color: #999;
    opacity: 1;
    display: block;
    margin-top: 2px;
}

.fep-column-title a {
    color: #4b4b4b;
    font-weight: 500;
    text-decoration: none;
    font-size: 15px;
}

.fep-column-title a:hover {
    color: #00afdb;
    text-decoration: none;
}

.fep-message-excerpt {
    opacity: 0.5;
    font-size: 14px;
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Checkbox styling */
#fep-table .fep-column-fep-cb input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.fep-cb-check-uncheck-all-div {
    padding: 8px 16px;
    font-size: 14px;
    color: #999;
    border-bottom: 1px solid #f0f0f0;
}

/* ── Conversation View ── */
#fep-content-single {
    gap: 16px;
}

#fep-content-single #fep-content-single-sidebar {
    padding: 12px;
    border-right: 1px solid #f0f0f0;
    flex: 0 0 200px !important;
    min-width: 180px;
    max-width: 240px;
}

#fep-content-single-sidebar .fep-message-head {
    padding: 8px;
    border-radius: 6px;
    margin-bottom: 4px;
    transition: background-color 0.15s;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

/* Compact 32px avatars in sidebar */
#fep-content-single-sidebar .fep-avatar-p {
    min-width: 32px;
    height: 32px !important;
    flex-shrink: 0;
}

#fep-content-single-sidebar .fep-avatar-p .fep-avatar-1,
#fep-content-single-sidebar .fep-avatar-p .fep-avatar-2 {
    width: 32px !important;
    height: 32px !important;
}

#fep-content-single-sidebar .fep-avatar-p img {
    width: 32px !important;
    height: 32px !important;
}

#fep-content-single-sidebar .fep-message-head:hover {
    background-color: #f8f9fa;
}

#fep-content-single-heads .fep-message-head-active {
    background-color: #f0f6fc;
    border-radius: 6px;
}

/* Participant name in sidebar */
.fep-head-name {
    font-size: 13px;
    font-weight: 500;
    color: #4b4b4b;
    line-height: 1.3;
}

#fep-content-single-main {
    flex: 1;
    min-width: 0;
}

/* ── Conversation Header ── */

/* Subject as plain heading — no box */
.fep-per-message-top {
    border: none !important;
    padding: 0 0 12px 0 !important;
    margin: 0 0 8px 0 !important;
    border-bottom: 1px solid #f0f0f0 !important;
    border-radius: 0 !important;
}

.fep-message .fep-message-title-heading {
    font-size: 20px;
    font-family: MartelSans-ExtraBold, sans-serif;
    padding: 0;
    border-radius: 0;
    border: none;
    background: none;
    margin-bottom: 4px;
}

/* Hide participants bar entirely */
.fep-message-title-heading.participants {
    display: none;
}

/* Always show all messages — disable toggle/hide behavior */
#fep-content .fep-hide-if-js,
#fep-content-single .fep-hide-if-js {
    display: block !important;
}

/* Hide the toggle button — no longer needed */
.fep-per-message-top .fep-align-right {
    display: none;
}

/* ── Chat-Style Messages ── */

/* Message container */
.fep-per-message {
    padding: 0;
    margin: 12px 0;
    border: none;
    border-radius: 0;
    max-width: 75%;
}

.fep-per-message:hover {
    box-shadow: none;
}

/* Reset top message wrapper */
.fep-per-message.fep-per-message-top {
    max-width: 100%;
}

/* Other person's messages: left-aligned */
.fep-per-message:not(.fep-per-message-own):not(.fep-per-message-top) {
    margin-right: auto;
    margin-left: 0;
}

.fep-per-message:not(.fep-per-message-own):not(.fep-per-message-top) .fep-message-content {
    background: #f0f6fc;
    border-radius: 12px 12px 12px 2px;
    padding: 12px 16px;
}

/* Own messages: right-aligned */
.fep-per-message.fep-per-message-own {
    margin-left: auto;
    margin-right: 0;
}

.fep-per-message.fep-per-message-own .fep-message-content {
    background: #f0f0f0;
    border-radius: 12px 12px 2px 12px;
    padding: 12px 16px;
}

/* Message title bar (sender + date) */
.fep-per-message .fep-message-title {
    font-size: 13px;
    padding: 0 4px 4px;
    border-radius: 0;
    border: none;
    background: none;
    margin-bottom: 0;
}

.fep-per-message .fep-message-title .author {
    font-weight: 600;
    color: #4b4b4b;
    display: flex;
    align-items: center;
    gap: 6px;
}

.fep-per-message .fep-message-title .author .fep-author-link {
    color: #00afdb;
    text-decoration: none;
    font-weight: 600;
}

.fep-per-message .fep-message-title .author .fep-author-link:hover {
    text-decoration: underline;
}

/* Mini avatar next to sender name */
.fep-inline-avatar {
    width: 20px !important;
    height: 20px !important;
    border-radius: 50% !important;
    border: 1px solid #e7e7e7 !important;
    object-fit: cover;
    flex-shrink: 0;
}

.fep-per-message .fep-message-title .date {
    font-size: 12px;
    color: #999;
    font-weight: normal;
}

/* Own message: right-align the title */
.fep-per-message.fep-per-message-own .fep-message-title {
    flex-direction: row-reverse;
}

/* Message content */
.fep-per-message .fep-message-content {
    line-height: 1.6;
    font-size: 15px;
}

/* Message content links */
.fep-per-message .fep-message-content a {
    color: #00afdb;
}

/* ── Reply Form ── */
.fep-form {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #f0f0f0;
}

.fep-form label {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 6px;
    text-transform: none;
    letter-spacing: normal;
    color: #4b4b4b;
}

/* Override FEP's uppercase labels */
#fep-content label,
#fep-content-single label {
    text-transform: none;
    letter-spacing: normal;
}

.fep-form input[type="text"] {
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 15px;
    font-family: inherit;
    transition: border-color 0.2s;
    margin-bottom: 12px;
}

.fep-form input[type="text"]:focus {
    border-color: #00afdb;
    outline: none;
}

.fep-form textarea {
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 12px 14px;
    font-size: 15px;
    font-family: inherit;
    min-height: 80px;
    height: 80px;
    resize: vertical;
    transition: border-color 0.2s;
    margin-bottom: 12px;
}

.fep-form textarea:focus {
    border-color: #00afdb;
    outline: none;
}

.fep-form .description {
    font-size: 13px;
    color: #999;
    font-style: normal;
}

/* ── Attachment Area ── */

/* Wrapper for upload section */
#fep_upload {
    margin-top: 4px;
    padding: 12px;
    border: 1px dashed #ddd;
    border-radius: 6px;
    background: #fafafa;
}

/* "Datei hinzufügen" header via pseudo-element */
#fep_upload::before {
    content: 'Datei hinzufügen';
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #4b4b4b;
    margin-bottom: 8px;
}

/* Individual file row */
.fep-attachment-field-div {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.fep-attachment-field-input {
    font-size: 14px;
    font-family: inherit;
}

/* "Entfernen" link */
.fep-attachment-field-a {
    font-size: 13px;
    color: #999 !important;
    text-decoration: none !important;
}

.fep-attachment-field-a:hover {
    color: #ff4757 !important;
}

/* "Weitere Datei hinzufügen" link — replaces "Add more files" */
#fep-attachment-field-add {
    display: inline-block;
    margin-top: 8px;
    font-size: 13px;
    color: #00afdb !important;
    text-decoration: none !important;
    font-weight: 500;
    visibility: hidden;
}

#fep-attachment-field-add::before {
    content: '+ Weitere Datei hinzufügen';
    visibility: visible;
}

/* Attachment note */
#fep-attachment-note {
    font-size: 12px;
    color: #999;
    margin-top: 4px;
}

/* Submit button spacing */
.fep-form .fep-button,
.fep-form input[type="submit"] {
    margin-top: 12px;
    border-radius: 4px;
}

/* Attachments in messages */
.fep-attachments {
    border-top: 1px solid #f0f0f0;
    padding: 12px 0 4px;
    margin-top: 12px;
}

.fep-attachments-heading {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
}

/* ── Pagination ── */
.fep-pagination > li > a,
.fep-pagination > li > span {
    border-radius: 4px;
    margin: 0 2px;
    font-size: 14px;
    padding: 8px 14px;
}

.fep-pagination > .active > a,
.fep-pagination > .active > span {
    background-color: #00afdb;
    border-color: #00afdb;
}

/* ── Notifications ── */
.fep-error {
    border-radius: 6px;
    font-size: 14px;
    padding: 12px 16px;
}

.fep-success {
    background-color: #d4edda;
    border-color: #28a745;
    border-radius: 6px;
    font-size: 14px;
    padding: 12px 16px;
}

/* ── Footer ── */
#fep-footer {
    display: none;
}

/* ── Avatars ── */
#fep-wrapper .avatar,
#fep-wrapper .fernarbeit-resume-avatar,
.fep-avatar-p img {
    border-radius: 50%;
    border: 2px solid #f0f0f0;
    object-fit: cover;
}

/* Fallback avatar: subtle appearance */
#fep-wrapper .fernarbeit-avatar-fallback {
    opacity: 0.15;
}

/* Hide ghost avatar background images (group/more icons) */
#fep-wrapper .fep-avatar-group-60,
#fep-wrapper .fep-avatar-more-60 {
    display: none;
}

/* Hide avatar containers that have no images */
#fep-wrapper .fep-avatar-p:not(:has(img)) {
    display: none;
}

/* Only show the first participant's avatar, hide the second overlay */
#fep-wrapper .fep-avatar-2 {
    display: none;
}

/* Ensure avatar containers don't overflow */
.fep-avatar-p {
    overflow: hidden;
}

/* ── Toggle button (all messages) ── */
.fep-message-toggle-all {
    font-size: 14px;
    color: #00afdb;
    font-weight: 500;
}

/* ── Loading ── */
.fep-loader {
    border-radius: 8px;
}

/* ── Responsive ── */
@media screen and (max-width: 768px) {
    #fep-table .fep-table-row {
        padding: 12px;
        flex-wrap: wrap;
        gap: 8px;
    }

    #fep-table .fep-column-author {
        flex: 0 0 auto;
    }

    #fep-table .fep-column-title {
        flex: 1 1 100%;
    }

    .fep-message .fep-message-title-heading {
        font-size: 16px;
        padding: 12px;
    }

    .fep-per-message {
        padding: 12px;
    }

    .fep-per-message .fep-message-title {
        flex-direction: column;
        gap: 4px;
    }

    .fep-form textarea {
        min-height: 120px;
    }
}

@media screen and (max-width: 480px) {
    #fep-menu .fep-button,
    .fep-button,
    .fep-button-active {
        width: 100%;
        text-align: center;
        margin-right: 0;
    }

    #fep-table .fep-column-fep-cb {
        display: none;
    }
}
