/* «الإبلاغ عن عطل فني» — the floating button and its dialog.
 *
 * Deliberately namespaced `br-` and NOT built on `.modal`: modal-motion.js
 * holds `display` non-none for ~180ms on close, and this dialog is opened and
 * closed from a button that sits above every page's own layers. It carries its
 * own open/close transition instead.
 *
 * Colours come from the page's variables (--white, --text-primary, …) so a
 * teacher-themed dashboard recolours it for free; the fallbacks are what keep
 * it readable on a page that never loaded base.css.
 */

.br-fab {
    position: fixed;
    /* Logical, not physical: the AI chat widget (ai-chat.js) pins itself to
       `inset-inline-start`, so this has to sit on the *other* logical side or
       the two collide the moment a page's `dir` is `ltr` (a teacher's English
       dashboard_language) -- in `rtl` (the default) inset-inline-end is still
       physically bottom-left, so nothing moves for the common case. The
       safe-area inset is for the app's WebView, where a hardware gesture bar
       would otherwise sit on the button. */
    inset-inline-end: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    z-index: 9500;

    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 16px;
    border: none;
    border-radius: 999px;
    cursor: pointer;

    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #e05252, #c0392b);
    box-shadow: 0 6px 18px rgba(192, 57, 43, 0.35);
    transition: transform .2s ease, box-shadow .2s ease, opacity .2s ease;
}

.br-fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(192, 57, 43, 0.45);
}

.br-fab:active { transform: translateY(0); }

.br-fab i { font-size: 1rem; }

/* On a narrow screen the label would cover a third of the row, so the button
   collapses to its icon — the dialog's own title says the rest. */
@media (max-width: 520px) {
    .br-fab { padding: 12px; }
    .br-fab .br-fab-label { display: none; }
}

@media print {
    .br-fab, .br-overlay { display: none !important; }
}

/* ---------- dialog ---------- */

.br-overlay {
    position: fixed;
    inset: 0;
    z-index: 9600;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;

    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    visibility: hidden;
    transition: opacity .18s ease, visibility .18s ease;
}

.br-overlay.br-open {
    opacity: 1;
    visibility: visible;
}

.br-dialog {
    width: 100%;
    max-width: 520px;
    max-height: 92vh;
    overflow-y: auto;
    border-radius: 16px;
    background: var(--white, #fff);
    color: var(--text-primary, #333);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);

    transform: translateY(18px) scale(.98);
    transition: transform .2s ease;
}

.br-overlay.br-open .br-dialog { transform: none; }

.br-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border-color, #ddd);
}

.br-head h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-primary, #333);
    display: flex;
    align-items: center;
    gap: 8px;
}

.br-head h3 i { color: #c0392b; }

.br-close {
    border: none;
    background: transparent;
    color: var(--text-secondary, #666);
    font-size: 1.2rem;
    line-height: 1;
    padding: 6px;
    cursor: pointer;
    border-radius: 8px;
}

.br-close:hover { background: var(--hover-bg, rgba(0, 0, 0, .05)); }

.br-body { padding: 18px; }

.br-field { margin-bottom: 16px; }

.br-field label {
    display: block;
    margin-bottom: 6px;
    font-size: .88rem;
    font-weight: 700;
    color: var(--text-primary, #333);
}

.br-field .br-hint {
    display: block;
    margin-top: 5px;
    font-size: .76rem;
    font-weight: 400;
    color: var(--text-secondary, #666);
}

.br-field input[type="text"],
.br-field textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 11px 12px;
    border: 1px solid var(--border-color, #ddd);
    border-radius: 10px;
    background: var(--input-bg, #fff);
    color: var(--text-primary, #333);
    font-family: inherit;
    font-size: .92rem;
}

.br-field textarea { min-height: 110px; resize: vertical; }

.br-field input:focus,
.br-field textarea:focus {
    outline: none;
    border-color: var(--accent-color, #137980);
    box-shadow: 0 0 0 3px rgba(19, 121, 128, .15);
}

.br-file {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border: 1px dashed var(--border-color, #ddd);
    border-radius: 10px;
    cursor: pointer;
    color: var(--text-secondary, #666);
    font-size: .88rem;
}

.br-file:hover { border-color: var(--accent-color, #137980); }

.br-file input[type="file"] { display: none; }

.br-preview {
    display: none;
    margin-top: 10px;
    position: relative;
}

.br-preview img {
    max-width: 100%;
    max-height: 180px;
    border-radius: 10px;
    border: 1px solid var(--border-color, #ddd);
    display: block;
}

.br-preview button {
    position: absolute;
    top: 6px;
    left: 6px;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    cursor: pointer;
    background: rgba(0, 0, 0, .6);
    color: #fff;
}

.br-msg {
    display: none;
    margin-bottom: 14px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: .85rem;
    font-weight: 600;
}

.br-msg.br-error { display: block; background: rgba(220, 53, 69, .12); color: #c0392b; }
.br-msg.br-ok { display: block; background: rgba(40, 167, 69, .12); color: #1e8449; }

.br-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 0 18px 18px;
}

.br-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: .9rem;
    font-weight: 700;
    cursor: pointer;
}

.br-btn-cancel {
    background: var(--light-gray, #f0f0f0);
    color: var(--text-primary, #333);
}

.br-btn-send {
    background: linear-gradient(135deg, #e05252, #c0392b);
    color: #fff;
}

.br-btn:disabled { opacity: .6; cursor: not-allowed; }
