/* ───── Model-Request frontend styles ───── */

.mr-wrapper {
    max-width: 860px;
}

/* ── Header ── */
.mr-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}
.mr-header h2 {
    flex: 1;
    margin: 0;
    font-size: 1.4em;
}
.mr-back-link {
    font-size: .9em;
    text-decoration: none;
    color: #555;
    display: block;
    width: 100%;
    margin-bottom: 4px;
}
.mr-back-link:hover { color: #000; }
.mr-meta { color: #777; font-size: .88em; margin: 4px 0 0; }

/* ── Buttons ── */
.mr-btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 5px;
    border: 2px solid transparent;
    cursor: pointer;
    font-size: .9em;
    font-weight: 600;
    text-decoration: none;
    transition: opacity .15s, box-shadow .15s;
    line-height: 1.4;
    white-space: nowrap;
}
.mr-btn:hover { opacity: .85; }
.mr-btn--primary  { background: #1a1a2e; color: #fff; border-color: #1a1a2e; }
.mr-btn--success  { background: #28a745; color: #fff; border-color: #28a745; }
.mr-btn--danger   { background: #dc3545; color: #fff; border-color: #dc3545; }
.mr-btn--link     { background: none; color: #dc3545; border: none; padding: 8px 0; text-decoration: underline; }
.mr-btn--sm       { padding: 5px 12px; font-size: .82em; }
.mr-btn--lg       { padding: 12px 28px; font-size: 1em; }
.mr-btn:disabled  { opacity: .5; cursor: not-allowed; }

/* ── Badges ── */
.mr-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: .78em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    white-space: nowrap;
}
.mr-badge--pending   { background: #fff3cd; color: #856404; }
.mr-badge--replied   { background: #cce5ff; color: #004085; }
.mr-badge--validated { background: #d4edda; color: #155724; }
.mr-badge--refused   { background: #f8d7da; color: #721c24; }
.mr-badge--finished  { background: #d1ecf1; color: #0c5460; }
.mr-badge--cancelled { background: #e2e3e5; color: #383d41; }

/* ── Unread dot ── */
.mr-unread-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #e74c3c;
    vertical-align: middle;
    margin-left: 6px;
}

/* ── Table ── */
.mr-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .92em;
}
.mr-table th,
.mr-table td {
    padding: 10px 14px;
    border-bottom: 1px solid #eee;
    text-align: left;
    vertical-align: middle;
}
.mr-table th { background: #f9f9f9; font-weight: 700; }
.mr-table tr:hover td { background: #fafafa; }
.mr-row--unread td { font-weight: 600; }
.mr-row--unread td:first-child { border-left: 3px solid #e74c3c; }

/* ── Empty state ── */
.mr-empty {
    background: #f9f9f9;
    border: 2px dashed #ddd;
    border-radius: 8px;
    padding: 32px;
    text-align: center;
    color: #777;
}

/* ── Card ── */
.mr-card {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    padding: 20px 24px;
    margin-bottom: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,.04);
}
.mr-card h3 {
    margin-top: 0;
    margin-bottom: 16px;
    font-size: 1em;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #555;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

/* ── Notices ── */
.mr-notice {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: .9em;
    line-height: 1.6;
}
.mr-notice--info { background: #e8f4fd; border-left: 4px solid #2196F3; }
.mr-notice--warn { background: #fff8e1; border-left: 4px solid #FFC107; }
.mr-notice--success { background: #e8f5e9; border-left: 4px solid #4CAF50; color: #1b5e20; }
.mr-notice--error   { background: #fce4ec; border-left: 4px solid #E91E63; color: #880e4f; }

/* ── Form ── */
.mr-form .mr-field {
    margin-bottom: 18px;
}
.mr-form label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: .9em;
}
.mr-form label small {
    font-weight: 400;
    color: #777;
    display: block;
    margin-top: 2px;
}
.mr-form input[type="text"],
.mr-form textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: .95em;
    font-family: inherit;
    box-sizing: border-box;
    transition: border-color .15s;
}
.mr-form input[type="text"]:focus,
.mr-form textarea:focus {
    outline: none;
    border-color: #1a1a2e;
    box-shadow: 0 0 0 2px rgba(26,26,46,.12);
}
.mr-field--actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    padding-top: 8px;
}

/* ── File upload area ── */
.mr-file-area {
    border: 2px dashed #ccc;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    position: relative;
    transition: border-color .2s, background .2s;
}
.mr-file-area:hover,
.mr-file-area.dragover {
    border-color: #1a1a2e;
    background: #f5f7ff;
}
.mr-file-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}
.mr-file-label {
    display: block;
    cursor: pointer;
    font-size: .9em;
    color: #555;
    font-weight: 400;
    margin: 0;
}
.mr-file-icon { font-size: 2em; display: block; margin-bottom: 6px; }

/* ── File preview grid ── */
.mr-file-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
    justify-content: flex-start;
}
.mr-preview-item {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #ddd;
    background: #f9f9f9;
    display: flex;
    align-items: center;
    justify-content: center;
}
.mr-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.mr-preview-item__name {
    font-size: .7em;
    text-align: center;
    padding: 4px;
    word-break: break-all;
    color: #555;
}
.mr-preview-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(220,53,69,.85);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
}

/* ── Thread / conversation ── */
.mr-thread {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
}
.mr-thread__empty { color: #888; font-style: italic; }

/* Wrap: positions bubble + time side by side */
.mr-message-wrap {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 88%;
}
.mr-message-wrap--admin { align-self: flex-start; }
.mr-message-wrap--user  { align-self: flex-end; flex-direction: row-reverse; }

/* Bubble */
.mr-message {
    flex: 1;
    min-width: 0;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: .9em;
    line-height: 1.6;
}
.mr-message--user  { background: #eef2ff; border-bottom-right-radius: 2px; }
.mr-message--admin { background: #f0fdf4; border-bottom-left-radius: 2px; }
.mr-message__author {
    display: block;
    font-weight: 700;
    font-size: .78em;
    color: #888;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.mr-message__body { color: #222; }

/* Time beside the bubble */
.mr-message__time {
    flex-shrink: 0;
    font-size: .72em;
    color: #bbb;
    white-space: nowrap;
    line-height: 1.2;
}

/* System event marker */
.mr-event-marker {
    align-self: stretch;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: .76em;
    color: #bbb;
    font-style: italic;
    padding: 2px 0;
}
.mr-event-marker::before,
.mr-event-marker::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #ebebeb;
}
.mr-event-marker time {
    font-style: normal;
    color: #ccc;
    white-space: nowrap;
}

.mr-message__body { color: #222; }

/* ── Attachments grid ── */
.mr-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}
.mr-attachments--inline { margin-top: 12px; }
.mr-attachment {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    max-width: 100px;
}
.mr-attachment__thumb {
    width: 90px;
    height: 90px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #ddd;
    display: block;
}
.mr-attachment__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.mr-attachment__icon {
    width: 60px;
    height: 60px;
    border-radius: 6px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6em;
}
.mr-attachment__name {
    font-size: .76em;
    text-align: center;
    word-break: break-word;
    text-decoration: none;
    color: #1a1a2e;
}
.mr-attachment__name:hover { text-decoration: underline; }

/* ── STL decision ── */
.mr-stl-decision {
    background: #fff8e1;
    border: 2px solid #FFC107;
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 16px;
}
.mr-stl-decision p { margin: 0 0 12px; font-size: .9em; }
.mr-stl-decision .mr-btn { margin-right: 8px; }

/* ── Reply form inside card ── */
.mr-reply-form { margin-top: 24px; border-top: 1px solid #eee; padding-top: 20px; }

/* ── Responsive ── */
@media (max-width: 600px) {
    .mr-table { font-size: .82em; }
    .mr-table th:nth-child(4),
    .mr-table td:nth-child(4),
    .mr-table th:nth-child(5),
    .mr-table td:nth-child(5) { display: none; }
    .mr-message-wrap { max-width: 100%; }
    .mr-header { flex-direction: column; align-items: flex-start; }
}
