/* ═══════════════════════════════════════════════════════════════
   friends.css – Friends list + messaging styles
   ═══════════════════════════════════════════════════════════════ */

/* ── Friends screen layout ───────────────────────────────────── */
#friendsScreen {
    max-width: 480px;
    margin: 0 auto;
    padding: 12px;
}

#friendsScreen h1 {
    font-size: 1.3rem;
    margin-bottom: 8px;
}

/* ── Search bar ──────────────────────────────────────────────── */
.friend-search-box {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
}

.friend-search-box input {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.friend-search-box input:focus {
    border-color: var(--red, #cc0000);
}

.friend-search-box button {
    padding: 8px 16px;
    background: var(--red, #cc0000);
    color: white;
    border: none;
    border-radius: 10px;
    font-weight: bold;
    font-size: 0.85rem;
    cursor: pointer;
    white-space: nowrap;
}

/* ── Friend request rows ─────────────────────────────────────── */
.friend-request-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    background: #fff8e1;
    border-radius: 10px;
    margin-bottom: 6px;
    border: 1px solid #f0c040;
}

.friend-request-name {
    font-size: 0.9rem;
    font-weight: 600;
}

.friend-request-actions {
    display: flex;
    gap: 4px;
}

.friend-request-actions button {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 6px;
    transition: background 0.15s;
}

.friend-request-actions button:hover {
    background: rgba(0, 0, 0, 0.06);
}

/* ── Friend list rows ────────────────────────────────────────── */
.friend-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: white;
    border-radius: 12px;
    margin-bottom: 6px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    border: 1px solid #eee;
}

.friend-row-name {
    font-size: 0.92rem;
    font-weight: 600;
}

.friend-row-actions {
    display: flex;
    gap: 4px;
}

.friend-row-actions button {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    transition: background 0.15s;
}

.friend-row-actions button:hover {
    background: rgba(0, 0, 0, 0.06);
}

/* ── Chat panel ──────────────────────────────────────────────── */
#chatPanel {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 140px);
    max-height: 600px;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
    margin-bottom: 8px;
}

.chat-header h2 {
    font-size: 1rem;
    margin: 0;
    flex: 1;
}

.chat-back-btn {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
}

.chat-back-btn:hover {
    background: rgba(0, 0, 0, 0.06);
}

.chat-challenge-inline-btn {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    title: "Défi";
}

.chat-challenge-inline-btn:hover {
    background: rgba(0, 0, 0, 0.06);
}

/* ── Messages area ───────────────────────────────────────────── */
#chatMessages {
    flex: 1;
    overflow-y: auto;
    padding: 8px 4px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chat-bubble {
    max-width: 78%;
    padding: 8px 12px;
    border-radius: 14px;
    font-size: 0.88rem;
    line-height: 1.4;
    word-wrap: break-word;
    position: relative;
}

.chat-mine {
    align-self: flex-end;
    background: var(--red, #cc0000);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-theirs {
    align-self: flex-start;
    background: #f0f0f0;
    color: #222;
    border-bottom-left-radius: 4px;
}

.chat-time {
    display: block;
    font-size: 0.65rem;
    opacity: 0.6;
    margin-top: 2px;
    text-align: right;
}

.chat-challenge {
    font-weight: bold;
    font-size: 0.9rem;
}

.chat-challenge-btn {
    display: block;
    margin-top: 6px;
    padding: 4px 12px;
    background: var(--green, #00c853);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    font-size: 0.8rem;
    cursor: pointer;
}

/* ── Chat input bar ──────────────────────────────────────────── */
.chat-input-bar {
    display: flex;
    gap: 6px;
    padding: 8px 0 4px;
    border-top: 1px solid #eee;
}

.chat-input-bar input {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-size: 0.9rem;
    outline: none;
}

.chat-input-bar input:focus {
    border-color: var(--red, #cc0000);
}

.chat-input-bar button {
    padding: 8px 14px;
    background: var(--red, #cc0000);
    color: white;
    border: none;
    border-radius: 10px;
    font-weight: bold;
    font-size: 0.85rem;
    cursor: pointer;
}

/* ── Friends badge ───────────────────────────────────────────── */
.friends-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--red, #cc0000);
    color: white;
    font-size: 0.65rem;
    font-weight: bold;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* ── Dark mode ───────────────────────────────────────────────── */
[data-theme="dark"] .friend-row {
    background: #2a2a2a;
    border-color: #444;
    color: #eee;
}

[data-theme="dark"] .friend-request-row {
    background: #3a3020;
    border-color: #665520;
    color: #eee;
}

[data-theme="dark"] .chat-theirs {
    background: #333;
    color: #eee;
}

[data-theme="dark"] .friend-search-box input,
[data-theme="dark"] .chat-input-bar input {
    background: #2a2a2a;
    border-color: #555;
    color: #eee;
}

[data-theme="dark"] .chat-header {
    border-color: #444;
}

[data-theme="dark"] .chat-input-bar {
    border-color: #444;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 480px) {
    #friendsScreen {
        padding: 8px;
    }

    .chat-bubble {
        max-width: 85%;
    }

    #chatPanel {
        height: calc(100vh - 120px);
    }
}

/* ── Async duel picker ───────────────────────────────────────── */
#asyncDuelPicker {
    max-width: 480px;
    margin: 0 auto;
    padding: 12px;
}

#asyncDuelFriendsList {
    margin-top: 8px;
}

.fr-duel-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    transition: background 0.15s;
}

.fr-duel-btn:hover {
    background: rgba(0, 0, 0, 0.08);
}
