/* =============================================================================
   GRIDIRON COMMAND - Shared Messaging Styles
   Build: 2026-02-05
   Prefix: .gcm-* (Sideline Command Messaging)
   Replaces duplicated CSS in theme.css (.msg-center-*, .coach-chat-*, etc.)
   and parent/portal.html (.parent-chat-*, .chat-*)
   ============================================================================= */

/* =============================================================================
   CSS CUSTOM PROPERTIES (scoped to messaging)
   Inherits from design system tokens; role-specific overrides below
   ============================================================================= */
.gcm-modal-inner {
    --gcm-bg-base: var(--gc-bg-app, #0d1117);
    --gcm-bg-panel: var(--gc-bg-panel, #151b28);
    --gcm-bg-elevated: var(--gc-bg-elevated, #1e2433);
    --gcm-text-primary: var(--gc-text-color-primary, #fff);
    --gcm-text-secondary: var(--gc-text-color-secondary, #94a3b8);
    --gcm-text-muted: var(--gc-text-color-muted, #64748b);
    --gcm-accent: var(--gc-accent-primary, #22c55e);
    --gcm-accent-shadow: rgba(34, 197, 94, 0.3);
    --gcm-border: var(--gc-border-subtle, rgba(255, 255, 255, 0.08));
    --gcm-radius-sm: 8px;
    --gcm-radius-md: 12px;
    --gcm-radius-lg: 18px;
    --gcm-radius-pill: 24px;
    --gcm-radius-circle: 50%;
    --gcm-font-display: 'Rajdhani', sans-serif;
    --gcm-font-body: 'Rajdhani', sans-serif;
    --gcm-bubble-own-bg: var(--gc-accent-primary, #22c55e);
    --gcm-bubble-own-color: #fff;
    --gcm-bubble-other-bg: var(--gc-bg-elevated, #1e2433);
    --gcm-bubble-other-color: var(--gc-text-color-primary, #fff);

    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    overflow: hidden;
    font-family: var(--gcm-font-body);
}

/* Parent role overrides — lighter palette via --team-primary */
[data-role="parent"] .gcm-modal-inner {
    --gcm-accent: var(--team-primary, #22c55e);
    --gcm-accent-shadow: rgba(var(--team-primary-rgb, 34, 197, 94), 0.3);
    --gcm-bg-base: #fafafa;
    --gcm-bg-panel: #fff;
    --gcm-bg-elevated: #f3f4f6;
    --gcm-text-primary: #1f2937;
    --gcm-text-secondary: #6b7280;
    --gcm-text-muted: #9ca3af;
    --gcm-border: #e5e7eb;
    --gcm-bubble-other-bg: #fff;
    --gcm-bubble-other-color: #1f2937;
}

/* Dark mode parent override (if data-theme="dark" on parent) */
[data-role="parent"][data-theme="dark"] .gcm-modal-inner,
html[data-theme="dark"] [data-role="parent"] .gcm-modal-inner {
    --gcm-bg-base: var(--gc-bg-app, #0d1117);
    --gcm-bg-panel: var(--gc-bg-panel, #151b28);
    --gcm-bg-elevated: var(--gc-bg-elevated, #1e2433);
    --gcm-text-primary: #fff;
    --gcm-text-secondary: #94a3b8;
    --gcm-text-muted: #64748b;
    --gcm-border: rgba(255, 255, 255, 0.08);
    --gcm-bubble-other-bg: var(--gc-bg-elevated, #1e2433);
    --gcm-bubble-other-color: #fff;
}

/* Coach light mode override */
html[data-theme="light"] [data-role="coach"] .gcm-modal-inner {
    --gcm-bg-base: #f8fafc;
    --gcm-bg-panel: #fff;
    --gcm-bg-elevated: #f1f5f9;
    --gcm-text-primary: #1e293b;
    --gcm-text-secondary: #64748b;
    --gcm-text-muted: #94a3b8;
    --gcm-border: #e2e8f0;
    --gcm-bubble-other-bg: #fff;
    --gcm-bubble-other-color: #1e293b;
}

/* =============================================================================
   HEADER
   ============================================================================= */
.gcm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 2px solid var(--gcm-accent);
    background: linear-gradient(180deg,
        color-mix(in srgb, var(--gcm-accent) 8%, var(--gcm-bg-elevated)) 0%,
        var(--gcm-bg-elevated) 100%);
    flex-shrink: 0;
}

.gcm-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.gcm-header-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--gcm-radius-md);
    background: var(--gcm-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
}

.gcm-header-titles {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.gcm-header-title {
    margin: 0;
    font-family: var(--gcm-font-display);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--gcm-text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1.2;
}

.gcm-header-subtitle {
    margin: 0;
    font-size: 0.75rem;
    color: var(--gcm-text-muted);
    font-weight: 500;
}

.gcm-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.gcm-back-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--gcm-radius-md);
    background: var(--gcm-bg-panel);
    border: 1px solid var(--gcm-border);
    color: var(--gcm-text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.gcm-back-btn:hover {
    background: var(--gcm-accent);
    border-color: var(--gcm-accent);
    color: #fff;
}

.gcm-compose-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--gcm-radius-md);
    background: var(--gcm-accent);
    border: none;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px var(--gcm-accent-shadow);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.gcm-compose-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px var(--gcm-accent-shadow);
}

.gcm-close-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--gcm-radius-sm);
    background: transparent;
    border: none;
    color: var(--gcm-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.gcm-close-btn:hover {
    background: var(--gcm-bg-panel);
    color: var(--gcm-text-primary);
}

/* =============================================================================
   TAB NAVIGATION
   ============================================================================= */
.gcm-tabs {
    display: flex;
    gap: 0;
    padding: 0 16px;
    background: var(--gcm-bg-panel);
    border-bottom: 1px solid var(--gcm-border);
    flex-shrink: 0;
}

.gcm-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 16px;
    border: none;
    background: transparent;
    color: var(--gcm-text-muted);
    font-family: var(--gcm-font-display);
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.gcm-tab::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: transparent;
    transition: background 0.2s;
}

.gcm-tab:hover {
    color: var(--gcm-text-primary);
    background: color-mix(in srgb, var(--gcm-text-primary) 3%, transparent);
}

.gcm-tab.active {
    color: var(--gcm-accent);
}

.gcm-tab.active::after {
    background: var(--gcm-accent);
}

.gcm-tab svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Tab badge */
.gcm-tab-badge {
    display: none;
    background: var(--gcm-accent);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 999px;
    min-width: 18px;
    text-align: center;
    line-height: 1.3;
}

.gcm-tab-badge:not(:empty) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* =============================================================================
   CONTENT AREA (shared)
   ============================================================================= */
.gcm-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--gcm-bg-base);
}

.gcm-view {
    flex: 1;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.gcm-view[style*="display: flex"],
.gcm-view[style*="display:flex"] {
    display: flex !important;
}

/* Loading spinner */
.gcm-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
    flex: 1;
}

.gcm-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--gcm-border);
    border-top-color: var(--gcm-accent);
    border-radius: 50%;
    animation: gcm-spin 0.8s linear infinite;
}

@keyframes gcm-spin {
    to { transform: rotate(360deg); }
}

/* Empty states */
.gcm-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
    color: var(--gcm-text-muted);
    flex: 1;
}

.gcm-empty-icon {
    margin-bottom: 16px;
    opacity: 0.4;
}

.gcm-empty-icon svg {
    width: 48px;
    height: 48px;
}

.gcm-empty-title {
    margin: 0 0 8px;
    font-size: 1rem;
    font-weight: 700;
    color: var(--gcm-text-secondary);
}

.gcm-empty-desc {
    margin: 0;
    font-size: 0.85rem;
    color: var(--gcm-text-muted);
}

/* =============================================================================
   MESSAGES CONTAINER (shared between team chat & DM)
   ============================================================================= */
.gcm-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 0;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* Date divider */
.gcm-date-divider {
    text-align: center;
    font-size: 0.75rem;
    color: var(--gcm-text-muted);
    padding: 12px 0;
    font-weight: 600;
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
}

.gcm-date-divider::before,
.gcm-date-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--gcm-border);
}

.gcm-date-divider span {
    white-space: nowrap;
}

/* =============================================================================
   MESSAGE BUBBLE
   ============================================================================= */
.gcm-msg {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    margin-bottom: 10px;
    animation: gcm-bubbleFadeIn 0.2s ease-out;
}

.gcm-msg.own {
    align-self: flex-end;
    align-items: flex-end;
}

.gcm-msg:not(.own) {
    align-self: flex-start;
    align-items: flex-start;
}

@keyframes gcm-bubbleFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Sender line (hidden for own messages) */
.gcm-msg-sender {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 4px;
    padding-left: 12px;
    font-size: 0.75rem;
}

.gcm-msg.own .gcm-msg-sender {
    display: none;
}

.gcm-msg-sender-name {
    font-weight: 600;
    color: var(--gcm-text-primary);
}

.gcm-msg-sender-relation {
    color: var(--gcm-text-muted);
    font-weight: 500;
}

.gcm-msg-sender-time {
    color: var(--gcm-text-muted);
    margin-left: 6px;
}

/* The bubble itself */
.gcm-msg-bubble {
    display: inline-block;
    width: fit-content;
    max-width: 100%;
    padding: 10px 14px;
    border-radius: var(--gcm-radius-lg);
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.45;
    word-break: break-word;
    position: relative;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    touch-action: manipulation;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.2s;
}

/* Other's bubbles */
.gcm-msg:not(.own) .gcm-msg-bubble {
    background: var(--gcm-bubble-other-bg);
    color: var(--gcm-bubble-other-color);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Own bubbles */
.gcm-msg.own .gcm-msg-bubble {
    background: var(--gcm-bubble-own-bg);
    color: var(--gcm-bubble-own-color);
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px var(--gcm-accent-shadow);
}

/* Timestamp line inside bubble (DM view) */
.gcm-msg-time {
    font-size: 0.7rem;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--gcm-text-muted);
}

.gcm-msg.own .gcm-msg-time {
    justify-content: flex-end;
    color: rgba(255, 255, 255, 0.7);
}

/* Message status (checkmarks) */
.gcm-msg-status {
    display: inline-flex;
    align-items: center;
    margin-left: 4px;
    vertical-align: middle;
    color: rgba(255, 255, 255, 0.6);
}

.gcm-msg-status svg {
    width: 12px;
    height: 12px;
}

.gcm-msg-status.read {
    color: #60a5fa;
}

/* Delete button on bubbles */
.gcm-msg-delete {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    border-radius: var(--gcm-radius-circle);
    background: #ef4444;
    border: 2px solid var(--gcm-bg-base);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.3);
    z-index: 2;
    line-height: 1;
}

/* Show delete on hover (desktop) */
@media (hover: hover) and (pointer: fine) {
    .gcm-msg-bubble:hover .gcm-msg-delete {
        opacity: 1;
        pointer-events: auto;
    }
}

/* Show delete on long-press (mobile) */
.gcm-msg-bubble.show-actions .gcm-msg-delete {
    opacity: 1;
    pointer-events: auto;
}

.gcm-msg-delete:hover {
    transform: scale(1.1);
    background: #dc2626;
}

/* =============================================================================
   REACTION PILLS (below bubbles)
   ============================================================================= */
.gcm-msg-reactions {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.gcm-msg.own .gcm-msg-reactions {
    justify-content: flex-end;
}

.gcm-reaction-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: color-mix(in srgb, var(--gcm-text-primary) 8%, transparent);
    border: 1px solid color-mix(in srgb, var(--gcm-text-primary) 8%, transparent);
    border-radius: var(--gcm-radius-md);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s;
    -webkit-user-select: none;
    user-select: none;
}

.gcm-reaction-pill:hover {
    background: color-mix(in srgb, var(--gcm-text-primary) 14%, transparent);
    transform: scale(1.05);
}

.gcm-reaction-pill.mine {
    background: color-mix(in srgb, var(--gcm-accent) 20%, transparent);
    border-color: var(--gcm-accent);
}

.gcm-reaction-emoji {
    font-size: 0.85rem;
    line-height: 1;
}

.gcm-reaction-count {
    font-weight: 600;
    color: var(--gcm-text-primary);
}

/* =============================================================================
   REACTION PICKER (floating)
   ============================================================================= */
.gcm-reaction-picker {
    position: absolute;
    background: var(--gcm-bg-panel);
    border: 1px solid var(--gcm-border);
    border-radius: 28px;
    padding: 8px 12px;
    display: flex;
    gap: 4px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    z-index: 100;
}

.gcm-reaction-btn {
    font-size: 24px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 10px;
    transition: all 0.15s ease;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.gcm-reaction-btn:hover {
    background: color-mix(in srgb, var(--gcm-accent) 15%, transparent);
    transform: scale(1.15);
}

.gcm-reaction-btn:active {
    transform: scale(0.95);
}

/* =============================================================================
   INPUT BAR (shared)
   ============================================================================= */
.gcm-input-bar {
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--gcm-border);
    background: var(--gcm-bg-elevated);
    align-items: flex-end;
    flex-shrink: 0;
}

/* Parent portal: container already accounts for safe area via fixed bottom offset */
[data-role="parent"] .gcm-input-bar {
    padding-bottom: 12px;
}

.gcm-input-wrapper {
    flex: 1;
    display: flex;
}

.gcm-input {
    width: 100%;
    padding: 12px 18px;
    background: var(--gcm-bg-panel);
    border: 1px solid var(--gcm-border);
    border-radius: var(--gcm-radius-pill);
    color: var(--gcm-text-primary);
    font-size: 1rem;
    font-family: var(--gcm-font-body);
    min-height: 48px;
    max-height: 120px;
    resize: none;
    line-height: 1.5;
    transition: border-color 0.2s, box-shadow 0.2s;
    overflow-y: auto;
}

.gcm-input::placeholder {
    color: var(--gcm-text-muted);
}

.gcm-input:focus {
    outline: none;
    border-color: var(--gcm-accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--gcm-accent) 15%, transparent);
}

/* Send button */
.gcm-send-btn {
    width: 48px;
    height: 48px;
    border-radius: var(--gcm-radius-circle);
    background: var(--gcm-accent);
    border: none;
    color: #fff;
    display: flex;
    align-items: center;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    box-shadow: 0 2px 8px var(--gcm-accent-shadow);
}

.gcm-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px var(--gcm-accent-shadow);
}

.gcm-send-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.gcm-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

.gcm-send-btn svg {
    width: 18px;
    height: 18px;
}

/* =============================================================================
   TYPING INDICATOR
   ============================================================================= */
.gcm-typing-indicator {
    padding: 4px 20px;
    flex-shrink: 0;
}

.gcm-typing-bubble {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--gcm-bg-elevated);
    border-radius: var(--gcm-radius-lg);
    font-size: 0.8rem;
    color: var(--gcm-text-secondary);
    animation: gcm-bubbleFadeIn 0.2s ease-out;
}

.gcm-typing-dots {
    display: flex;
    gap: 3px;
}

.gcm-typing-dot {
    width: 6px;
    height: 6px;
    background: var(--gcm-text-muted);
    border-radius: 50%;
    animation: gcm-typingBounce 1.4s ease-in-out infinite;
}

.gcm-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.gcm-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes gcm-typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

/* =============================================================================
   DM HEADER (inside direct chat view)
   ============================================================================= */
.gcm-dm-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--gcm-border);
    background: var(--gcm-bg-elevated);
    flex-shrink: 0;
}

.gcm-dm-avatar {
    width: 44px;
    height: 44px;
    border-radius: var(--gcm-radius-circle);
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.gcm-dm-info {
    flex: 1;
}

.gcm-dm-name {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--gcm-text-primary);
}

.gcm-dm-role {
    font-size: 0.8rem;
    color: var(--gcm-text-muted);
    font-weight: 500;
}

/* =============================================================================
   CONVERSATIONS LIST
   ============================================================================= */

/* Horizontal contacts row */
.gcm-contacts-row {
    display: flex;
    gap: 16px;
    padding: 16px 20px 8px;
    overflow-x: auto;
    flex-shrink: 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.gcm-contacts-row::-webkit-scrollbar {
    display: none;
}

.gcm-contact-bubble {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.2s;
}

.gcm-contact-bubble:hover {
    transform: translateY(-2px);
}

.gcm-contact-avatar {
    width: 52px;
    height: 52px;
    border-radius: var(--gcm-radius-circle);
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.2rem;
    color: #fff;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    border: 2px solid transparent;
    transition: border-color 0.2s;
}

.gcm-contact-avatar.has-unread {
    border-color: var(--gcm-accent);
    box-shadow: 0 0 0 2px var(--gcm-accent), 0 4px 12px rgba(59, 130, 246, 0.3);
}

.gcm-contact-name {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--gcm-text-secondary);
    max-width: 60px;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Conversation list items */
.gcm-convos-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.gcm-convo-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--gcm-bg-panel);
    border-radius: var(--gcm-radius-md);
    border: 1px solid var(--gcm-border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    position: relative;
}

.gcm-convo-item:hover {
    background: var(--gcm-bg-elevated);
    border-color: var(--gcm-accent);
    box-shadow: 0 4px 12px color-mix(in srgb, var(--gcm-accent) 12%, transparent);
    transform: translateY(-1px);
}

.gcm-convo-item.unread {
    background: color-mix(in srgb, var(--gcm-accent) 6%, var(--gcm-bg-panel));
    border-color: var(--gcm-accent);
    border-left: 3px solid var(--gcm-accent);
}

.gcm-convo-item.unread:hover {
    background: color-mix(in srgb, var(--gcm-accent) 10%, var(--gcm-bg-panel));
}

.gcm-convo-unread-dot {
    position: absolute;
    top: 50%;
    left: 8px;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    background: var(--gcm-accent);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--gcm-accent-shadow);
}

.gcm-convo-avatar {
    width: 48px;
    height: 48px;
    border-radius: var(--gcm-radius-circle);
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25);
}

.gcm-convo-avatar.has-unread {
    box-shadow: 0 0 0 2px var(--gcm-accent), 0 2px 8px rgba(59, 130, 246, 0.25);
}

.gcm-convo-content {
    flex: 1;
    min-width: 0;
}

.gcm-convo-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 4px;
    gap: 8px;
}

.gcm-convo-name-group {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.gcm-convo-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--gcm-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gcm-convo-item.unread .gcm-convo-name {
    font-weight: 700;
}

.gcm-convo-player {
    font-size: 0.72rem;
    color: var(--gcm-accent);
    font-weight: 600;
    margin-top: 1px;
}

.gcm-convo-time {
    font-size: 0.72rem;
    color: var(--gcm-text-muted);
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

.gcm-convo-preview {
    font-size: 0.85rem;
    color: var(--gcm-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.gcm-convo-item.unread .gcm-convo-preview {
    color: var(--gcm-text-primary);
    font-weight: 500;
}

.gcm-convo-arrow {
    color: var(--gcm-text-muted);
    flex-shrink: 0;
    opacity: 0.5;
}

.gcm-convo-arrow svg {
    width: 16px;
    height: 16px;
}

/* =============================================================================
   COMPOSE MODAL (coach only)
   ============================================================================= */
.gcm-compose-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.gcm-compose-modal {
    background: var(--gcm-bg-panel);
    border: 1px solid var(--gcm-border);
    border-radius: var(--gcm-radius-md);
    width: 100%;
    max-width: 460px;
    display: flex;
    flex-direction: column;
    max-height: 80%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.gcm-compose-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--gcm-border);
}

.gcm-compose-header h4 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gcm-text-primary);
}

.gcm-compose-close {
    background: transparent;
    border: none;
    color: var(--gcm-text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    transition: color 0.2s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.gcm-compose-close:hover {
    color: var(--gcm-text-primary);
}

.gcm-compose-body {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    flex: 1;
    overflow-y: auto;
}

.gcm-compose-select {
    width: 100%;
    padding: 12px 16px;
    background: var(--gcm-bg-elevated);
    border: 1px solid var(--gcm-border);
    border-radius: var(--gcm-radius-md);
    color: var(--gcm-text-primary);
    font-size: 0.95rem;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
}

.gcm-compose-select:focus {
    outline: none;
    border-color: var(--gcm-accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--gcm-accent) 15%, transparent);
}

.gcm-compose-textarea {
    width: 100%;
    padding: 14px 16px;
    background: var(--gcm-bg-elevated);
    border: 1px solid var(--gcm-border);
    border-radius: var(--gcm-radius-md);
    color: var(--gcm-text-primary);
    font-size: 0.95rem;
    font-family: var(--gcm-font-body);
    resize: none;
    line-height: 1.5;
    min-height: 120px;
}

.gcm-compose-textarea::placeholder {
    color: var(--gcm-text-muted);
}

.gcm-compose-textarea:focus {
    outline: none;
    border-color: var(--gcm-accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--gcm-accent) 15%, transparent);
}

.gcm-compose-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--gcm-border);
    display: flex;
    justify-content: flex-end;
}

.gcm-compose-send-btn {
    padding: 12px 24px;
    border-radius: var(--gcm-radius-md);
    background: var(--gcm-accent);
    color: #fff;
    border: none;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.2s;
    box-shadow: 0 2px 8px var(--gcm-accent-shadow);
}

.gcm-compose-send-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--gcm-accent-shadow);
}

.gcm-compose-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* =============================================================================
   RESPONSIVE (iPad + Mobile)
   ============================================================================= */

/* iPad landscape — mount point inside gc-modal-backdrop */
#messagingMount {
    width: 100%;
    height: 100%;
    max-width: 640px;
    max-height: 90vh;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

@media (max-width: 767px) {
    #messagingMount {
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
    }
}

@media (min-width: 768px) and (max-width: 1366px) {
    .gcm-modal-inner {
        margin: 0 auto;
    }
}

/* Mobile phones */
@media (max-width: 767px) {
    .gcm-header {
        padding: 12px 16px;
    }

    .gcm-header-title {
        font-size: 0.95rem;
    }

    .gcm-messages {
        padding: 12px 14px;
    }

    .gcm-msg {
        max-width: 88%;
    }

    .gcm-msg-bubble {
        font-size: 0.95rem;
    }

    .gcm-convo-item {
        padding: 12px 14px;
    }

    .gcm-convo-avatar {
        width: 42px;
        height: 42px;
        font-size: 1rem;
    }

    .gcm-input-bar {
        padding: 10px 12px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    }

    .gcm-send-btn {
        width: 44px;
        height: 44px;
    }

    .gcm-compose-modal {
        max-width: 100%;
        margin: 0 8px;
    }
}

/* Small phones */
@media (max-width: 375px) {
    .gcm-header-icon {
        display: none;
    }

    .gcm-tab span {
        font-size: 0.8rem;
    }
}
