/* URR Chat - Apple Design UI & Fluid Layout */
.app-shell {
    display: grid;
    grid-template-rows: auto 1fr;
    min-height: 100vh;
    background: var(--bg);
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem 1.2rem;
    border-bottom: 1px solid var(--glass-border);
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    position: sticky;
    top: 0;
    z-index: 20;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.chat-header .brand {
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.chat-tools {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chat-tools .online-count {
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 500;
}

.chat-tools .me {
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 500;
}

.chat-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    height: calc(100vh - 61px);
    min-height: 0;
}

.chat-sidebar {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border-right: 1px solid var(--glass-border);
    overflow-y: auto;
    padding: 1rem 0.8rem;
}

.chat-sidebar h3 {
    margin: 0.4rem 0.5rem 0.7rem;
    color: var(--muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
}

.room-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.room-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius);
    background: transparent;
    border: 1px solid transparent;
    color: var(--text);
    font-weight: 500;
    font-size: 0.95rem;
    transition: transform var(--transition-fast), background-color var(--transition), border-color var(--transition);
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.room-item:hover {
    background: var(--glass-highlight);
}

.room-item:active {
    transform: scale(0.97);
}

.room-item.active {
    background: var(--primary-light);
    border-color: rgba(124, 58, 237, 0.4);
    color: var(--text);
    font-weight: 600;
    box-shadow: inset 0 0 12px rgba(124, 58, 237, 0.15);
}

.chat-main {
    display: grid;
    grid-template-rows: 1fr auto auto;
    min-height: 0;
    position: relative;
}

.chat-scroll {
    overflow-y: auto;
    padding: 1.2rem 1.4rem;
    scroll-behavior: smooth;
}

.messages {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

/* Fluid Message Animation (Apple Principle 4) */
@keyframes msgAppear {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.msg {
    display: grid;
    grid-template-columns: 42px 1fr;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius);
    transition: background-color var(--transition);
    animation: msgAppear 0.3s var(--ease-spring);
}

.msg:hover {
    background: var(--glass-highlight);
}

.msg .avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--bg-3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #fff;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.msg .avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.msg .body {
    min-width: 0;
}

.msg .head {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
    flex-wrap: wrap;
    margin-bottom: 0.2rem;
}

.msg .username {
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: -0.01em;
}

.msg .role {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    background: var(--bg-3);
    color: var(--muted);
    letter-spacing: 0.02em;
}

.msg .role.editor {
    color: #60a5fa;
    background: rgba(96, 165, 250, 0.15);
}

.msg .role.moderator {
    color: #6ee7b7;
    background: rgba(16, 185, 129, 0.15);
}

.msg .role.admin {
    color: #fbbf24;
    background: rgba(245, 158, 11, 0.15);
}

.msg .role.owner {
    color: #f472b6;
    background: rgba(244, 114, 182, 0.15);
}

/* Animated Staff Star (Apple Glow Effect) */
@keyframes starGlow {
    0% {
        transform: scale(1) rotate(0deg);
        filter: drop-shadow(0 0 3px rgba(245, 158, 11, 0.7));
    }
    50% {
        transform: scale(1.18) rotate(12deg);
        filter: drop-shadow(0 0 10px rgba(245, 158, 11, 1)) drop-shadow(0 0 15px rgba(251, 191, 36, 0.8));
    }
    100% {
        transform: scale(1) rotate(0deg);
        filter: drop-shadow(0 0 3px rgba(245, 158, 11, 0.7));
    }
}

.staff-star {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 0.3rem;
    font-size: 0.95rem;
    color: #fbbf24;
    animation: starGlow 2.5s infinite ease-in-out;
    cursor: default;
    user-select: none;
    vertical-align: middle;
}

/* User Country Flag */
.user-flag {
    display: inline-block;
    width: 18px;
    height: 13px;
    object-fit: cover;
    border-radius: 2px;
    margin-right: 0.35rem;
    vertical-align: middle;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.msg .time {
    color: var(--muted);
    font-size: 0.78rem;
    margin-left: auto;
}

.msg .content {
    word-break: break-word;
    overflow-wrap: anywhere;
    line-height: 1.5;
    font-size: 0.95rem;
}

.msg.deleted .content {
    color: var(--muted);
    font-style: italic;
}

.reply-block {
    border-left: 3px solid var(--primary);
    padding: 0.3rem 0.6rem;
    margin: 0.25rem 0 0.4rem;
    background: var(--primary-light);
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--muted);
}

.msg-actions {
    display: inline-flex;
    gap: 0.3rem;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.msg:hover .msg-actions {
    opacity: 1;
}

.msg-actions button {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.2rem 0.5rem;
    color: var(--muted);
    font-size: 0.75rem;
    transition: transform var(--transition-fast), background-color var(--transition-fast), color var(--transition-fast);
}

.msg-actions button:active {
    transform: scale(0.9);
}

.msg-actions button:hover {
    color: var(--text);
    background: var(--bg-3);
}

.load-more {
    text-align: center;
    padding: 0.75rem;
}

.reply-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border-top: 1px solid var(--glass-border);
    padding: 0.5rem 1rem;
    font-size: 0.88rem;
    color: var(--muted);
}

.composer {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    padding: 0.85rem 1rem;
    border-top: 1px solid var(--glass-border);
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    position: sticky;
    bottom: 0;
    z-index: 10;
}

.composer input[type=text] {
    flex: 1;
}

.composer.disabled {
    color: var(--muted);
    padding: 1rem;
}

/* Apple Popover Panel - Spatial Entrance & Bounce Easing */
@keyframes panelPopIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(12px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.emoji-panel[hidden], .gif-panel[hidden] {
    display: none !important;
}

.emoji-panel {
    position: absolute;
    bottom: 70px;
    left: 1rem;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 0.6rem;
    box-shadow: var(--shadow);
    width: 290px;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 0.2rem;
    max-height: 220px;
    overflow-y: auto;
    z-index: 50;
    transform-origin: bottom left;
    animation: panelPopIn 0.25s var(--ease-bounce);
}

.emoji-panel button {
    background: transparent;
    border: 0;
    font-size: 1.3rem;
    padding: 0.25rem;
    cursor: pointer;
    border-radius: 8px;
    transition: transform 0.15s var(--ease-bounce), background-color 0.15s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.emoji-panel button:hover {
    background: var(--glass-highlight);
    transform: scale(1.25);
}

.emoji-panel button:active {
    transform: scale(0.9);
}

/* Apple Popover GIF Panel */
.gif-panel {
    position: absolute;
    bottom: 70px;
    left: 1rem;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 0.75rem;
    box-shadow: var(--shadow);
    width: 340px;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    max-height: 330px;
    z-index: 50;
    transform-origin: bottom left;
    animation: panelPopIn 0.25s var(--ease-bounce);
}

.gif-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
}

.gif-tabs {
    display: flex;
    gap: 0.3rem;
    background: var(--bg-2);
    padding: 0.2rem;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.gif-tab-btn {
    background: transparent;
    border: 0;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.gif-tab-btn.active {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.3);
}

.gif-search-input {
    font-size: 0.85rem;
    padding: 0.45rem 0.7rem;
    border-radius: var(--radius);
    background: var(--bg-2);
    border: 1px solid var(--border);
    color: var(--text);
    outline: none;
    width: 100%;
}
.gif-search-input:focus {
    border-color: var(--primary);
}

.gif-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.45rem;
    max-height: 220px;
    overflow-y: auto;
    padding-right: 0.15rem;
}

.gif-panel .gif-item {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.25rem;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    transition: transform 0.15s var(--ease-bounce), border-color 0.15s ease, background-color 0.15s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.gif-panel .gif-item:hover {
    background: var(--glass-highlight);
    border-color: var(--primary);
    transform: scale(1.04);
}

.gif-panel .gif-item:active {
    transform: scale(0.95);
}

.gif-panel .gif-item img {
    width: 100%;
    height: 72px;
    object-fit: cover;
    border-radius: 8px;
}

.gif-panel .gif-item span {
    font-size: 0.7rem;
    color: var(--muted);
    font-weight: 500;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Responsive Layout */
@media (max-width: 720px) {
    .chat-layout {
        grid-template-columns: 1fr;
    }
    .chat-sidebar {
        display: none;
    }
    .emoji-panel, .gif-panel {
        left: 0.75rem;
        right: 0.75rem;
        bottom: 70px;
        width: auto;
        max-height: 310px;
        z-index: 50;
    }
}




