* {
    box-sizing: border-box;
    font-family: "Cairo", Tahoma, Arial, sans-serif;
}


.chat-shell {
    display: grid;
    grid-template-columns: 360px 1fr;
    height: 100vh;
}

.chat-sidebar {
    display: flex;
    flex-direction: column;
    border-left: 1px solid #e5e7eb;
    background: #fff;
    overflow: hidden;
}

.chat-sidebar-header {
    padding: 16px;
    border-bottom: 1px solid #eef0f3;
    display: grid;
    gap: 10px;
}

.chat-search {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #d9dde5;
    border-radius: 12px;
    outline: none;
}

.chat-list-scroll {
    height: 100%;
    overflow-y: auto;
    padding: 10px;
}

.chat-list-empty {
    padding: 24px;
    text-align: center;
    color: #6b7280;
}

.chat-list-item {
    display: grid;
    grid-template-columns: 52px 1fr auto;
    gap: 12px;
    padding: 12px;
    border-radius: 14px;
    cursor: pointer;
    transition: .15s ease;
    margin-bottom: 8px;
}

    .chat-list-item:hover {
        background: #f8fafc;
    }

    .chat-list-item.active {
        background: #eff6ff;
        border: 1px solid #dbeafe;
    }

.chat-list-avatar,
.chat-header-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    object-fit: cover;
    background: #e5e7eb;
}

.chat-list-content {
    min-width: 0;
}

.chat-list-top,
.chat-list-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.chat-list-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    min-width: 0;
}

.chat-list-time,
.chat-list-order,
.chat-list-last-message {
    color: #6b7280;
    font-size: 13px;
}

.chat-list-last-message {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 170px;
}

.chat-list-order {
    margin-top: 5px;
}

.chat-list-actions {
    display: flex;
    align-items: start;
    gap: 6px;
}

.chat-badge {
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #16a34a;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
}

.icon-btn {
    border: none;
    background: #f3f4f6;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    cursor: pointer;
}

    .icon-btn:hover {
        background: #e5e7eb;
    }

    .icon-btn.danger {
        background: #fee2e2;
    }

.icon-mini {
    font-size: 12px;
}

.chat-main {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-empty {
    margin: auto;
    text-align: center;
    color: #64748b;
}

.chat-empty-icon {
    font-size: 56px;
    margin-bottom: 12px;
}

.chat-room {
    display: grid;
    grid-template-rows: 72px 36px 1fr auto auto;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    border-bottom: 1px solid #eef0f3;
    padding: 12px 18px;
}

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

.chat-header-title {
    font-weight: 700;
}

.chat-header-subtitle,
.header-order {
    color: #6b7280;
    font-size: 13px;
}

.chat-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.connection-banner {
    display: flex;
    align-items: center;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
}

    .connection-banner.success {
        background: #ecfdf5;
        color: #166534;
    }

    .connection-banner.warning {
        background: #fef3c7;
        color: #92400e;
    }

    .connection-banner.danger {
        background: #fee2e2;
        color: #991b1b;
    }

.chat-messages {
    overflow-y: auto;
    padding: 16px;
    background: linear-gradient(rgba(255,255,255,.85), rgba(255,255,255,.85)), url('/images/chat-bg.png');
    background-size: cover;
}

.chat-loading,
.load-older-indicator {
    text-align: center;
    color: #6b7280;
    padding: 12px;
}

.message-row {
    display: flex;
    margin-bottom: 10px;
}

    .message-row.mine {
        justify-content: flex-end;
    }

    .message-row.theirs {
        justify-content: flex-start;
    }

.message-bubble {
    max-width: 100%;
    padding: 10px 12px;
    border-radius: 18px;
    box-shadow: 0 1px 2px rgba(0,0,0,.06);
    background: #fff;
    word-wrap: anywhere;
}

.message-row.mine .message-bubble {
    background: #dcfce7;
}

.message-text,
.message-caption {
    white-space: pre-wrap;
    line-height: 1.5;
}

.message-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    font-size: 12px;
    color: #6b7280;
    margin-top: 6px;
}

.message-checks {
    color: #0ea5e9;
}

.message-image,
.message-video {
    width: 100%;
    max-width: 280px;
    border-radius: 12px;
    display: block;
}

.message-file {
    display: grid;
    gap: 6px;
}

    .message-file a {
        color: #2563eb;
        text-decoration: none;
    }

.message-file-icon {
    font-size: 22px;
}

.message-deleted {
    color: #6b7280;
    font-style: italic;
}

.typing-indicator {
    min-height: 34px;
    padding: 6px 16px 10px;
    color: #2563eb;
    font-size: 13px;
    background: #fff;
}

.composer {
    display: grid;
    grid-template-columns: 56px 1fr 96px;
    gap: 10px;
    padding: 12px;
    background: #fff;
    border-top: 1px solid #eef0f3;
}

.composer-center {
    display: grid;
    gap: 8px;
}

.composer-textarea {
    width: 100%;
    min-height: 52px;
    max-height: 120px;
    resize: vertical;
    border: 1px solid #d9dde5;
    border-radius: 14px;
    padding: 12px 14px;
    outline: none;
}

.composer-actions,
.composer-send {
    display: flex;
    align-items: flex-end;
}

.send-btn,
.file-btn {
    width: 100%;
    height: 52px;
    border: none;
    border-radius: 14px;
    background: #16a34a;
    color: white;
    cursor: pointer;
    font-weight: 700;
}

.file-btn {
    background: #2563eb;
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

.hidden-file-input {
    display: none;
}

.file-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #eff6ff;
    border: 1px solid #dbeafe;
    border-radius: 12px;
    padding: 8px 10px;
    color: #1d4ed8;
}

@media (max-width: 900px) {
    .chat-shell {
        grid-template-columns: 1fr;
    }

    .chat-sidebar {
        display: none;
    }

    .message-bubble {
        max-width: 88%;
    }
}


.tg-composer {
    grid-template-columns: 56px 1fr 96px;
    align-items: end;
}

.file-btn-modern {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #2563eb;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 20px;
}

.mic-btn {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    background: #16a34a;
    color: white;
    cursor: pointer;
    font-size: 20px;
}

/*.voice-recorder,
.composer-right {
    display: flex;
    align-items: center;
    justify-content: end;
}*/

.recording-shell {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #f8fafc;
    border: 1px solid #dbeafe;
    border-radius: 16px;
    padding: 10px 12px;
    min-width: 280px;
}

.recording-live {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 100%;
}

.record-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ef4444;
    display: inline-block;
    animation: pulse 1s infinite;
}

.record-time {
    font-weight: 700;
    color: #ef4444;
    min-width: 45px;
}

.record-hint {
    color: #64748b;
    font-size: 12px;
}

.record-locked-actions {
    display: flex;
    gap: 8px;
}

.cancel-record-btn,
.send-record-btn {
    border: none;
    border-radius: 10px;
    padding: 7px 8px;
    cursor: pointer;
}

.cancel-record-btn {
    background: #fee2e2;
    color: #991b1b;
}

.send-record-btn {
    background: #dcfce7;
    color: #166534;
}

.wave-bars,
.voice-wave-static,
.mini-wave {
    display: flex;
    align-items: end;
    gap: 2px;
    min-height: 24px;
    flex-wrap: nowrap;
}

.bar {
    width: 3px;
    border-radius: 999px;
    background: #0ea5e9;
    display: inline-block;
}

.upload-queue {
    background: #fff;
    border-top: 1px solid #e5e7eb;
    padding: 10px;
    display: grid;
    gap: 8px;
    max-height: 220px;
    overflow-y: auto;
}

.upload-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 10px 12px;
    display: grid;
    gap: 8px;
}

.upload-card-top,
.upload-card-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.upload-title {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 260px;
}

.upload-size,
.upload-error {
    color: #64748b;
    font-size: 13px;
}

.upload-progress-line {
    width: 100%;
    height: 7px;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
}

.upload-progress-value {
    height: 100%;
    background: linear-gradient(90deg, #0ea5e9, #16a34a);
}

.upload-actions {
    display: flex;
    gap: 8px;
}

    .upload-actions button {
        border: none;
        border-radius: 10px;
        padding: 6px 10px;
        cursor: pointer;
    }

.audio-bubble,
.video-bubble,
.document-bubble {
    display: grid;
    gap: 8px;
}

.voice-player,
.chat-video {
    width: 100%;
    max-width: 320px;
}

.voice-meta,
.video-meta-row,
.doc-meta {
    display: flex;
    gap: 10px;
    align-items: center;
    color: #64748b;
    font-size: 12px;
    flex-wrap: wrap;
}

.video-actions {
    display: flex;
    gap: 8px;
}

.document-bubble {
    grid-template-columns: 40px 1fr;
    align-items: center;
}

.doc-icon {
    font-size: 28px;
}

.doc-name {
    color: #2563eb;
    text-decoration: none;
    word-break: break-word;
}

.media-viewer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
}

.media-viewer-dialog {
    width: min(95vw, 1100px);
    height: min(92vh, 860px);
    background: #0f172a;
    color: white;
    border-radius: 18px;
    overflow: hidden;
    display: grid;
    grid-template-rows: 60px 1fr;
}

.media-viewer-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(255,255,255,.06);
}

.media-viewer-actions {
    display: flex;
    gap: 8px;
}

.media-viewer-body {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
}

.viewer-image,
.viewer-video {
    max-width: 100%;
    max-height: 100%;
    border-radius: 12px;
}

.clickable {
    cursor: pointer;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.15);
        opacity: .7;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}
/************************************/
.message-status {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    margin-left: 8px;
    min-width: 20px;
}

.sending-dots {
    display: flex;
    gap: 2px;
}

    .sending-dots span {
        width: 6px;
        height: 6px;
        background: #999;
        border-radius: 50%;
        animation: sending-bounce 1.4s infinite ease-in-out both;
    }

        .sending-dots span:nth-child(1) {
            animation-delay: -0.32s;
        }

        .sending-dots span:nth-child(2) {
            animation-delay: -0.16s;
        }

@keyframes sending-bounce {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.sent-checks {
    color: #4CAF50;
    font-weight: bold;
}

.failed-icon {
    color: #f44336;
    cursor: pointer;
    font-weight: bold;
}

    .failed-icon:hover {
        color: #d32f2f;
    }

/****/
.message-content {
    flex-direction: column;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    margin: 0 8px;
    align-self: flex-start;
}

.message-sender {
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 4px;
    margin-right: 8px;
}

.message-row.theirs {
    align-items: flex-start;
}

/******/



.scroll-to-bottom-btn {
    position: absolute;
    right: 16px;
    bottom: 90px;
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 50%;
    background: var(--mud-palette-primary);
    color: #fff;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
}

    .scroll-to-bottom-btn:hover {
        background: var(--mud-palette-primary);
    }



/******** Voice *********/


.voice-recorder {
    position: relative;
    display: flex;
    align-items: center;
    height: 64px;
    padding: 12px 16px;
    gap: 12px;
}

.mic-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #f0f2f5;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #667781;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

    .mic-btn:hover {
        background: #e8eaed;
    }

    .mic-btn:active {
        transform: scale(0.95);
        background: #dde1e6;
    }

.recording-container {
    position: relative;
    flex: 1;
    height: 64px;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* الشريط الأحمر المتحرك */
.recording-slide-bar {
    position: absolute;
    top: 8px;
    left: 12px;
    right: 76px; /* مسافة للأزرار */
    height: 4px;
    background: linear-gradient(90deg, #ff3b30 0%, #ff9500 50%, #ff3b30 100%);
    background-size: 200% 100%;
    animation: slide-glow 2s ease-in-out infinite;
    border-radius: 2px;
    box-shadow: 0 2px 8px rgba(255,59,48,0.4);
}

@keyframes slide-glow {
    0% {
        background-position: 200% 0;
    }

    50% {
        background-position: 0% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.recording-shell {
    flex: 1;
    height: 56px;
    background: linear-gradient(135deg, #f8f9fa 0%, #f0f2f5 100%);
    border-radius: 28px;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    padding: 0 20px;
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.6);
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.recording-gradient {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 20% 50%, rgba(255,59,48,0.15) 0%, transparent 70%);
    border-radius: 28px;
}

.recording-live {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.record-dot-container {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 14px;
}

.record-dot {
    width: 10px;
    height: 10px;
    background: radial-gradient(circle, #ff3b30 40%, #e63946 100%);
    border-radius: 50%;
    animation: pulse-telegram 1.6s ease-in-out infinite;
    box-shadow: 0 0 12px rgba(255,59,48,0.6);
}

@keyframes pulse-telegram {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
        box-shadow: 0 0 12px rgba(255,59,48,0.6);
    }

    50% {
        transform: scale(1.2);
        opacity: 0.8;
        box-shadow: 0 0 20px rgba(255,59,48,0.8);
    }
}

.record-time {
    font-size: 16px;
    font-weight: 600;
    color: #1c1e21;
    min-width: 44px;
    text-align: center;
    font-variant-numeric: tabular-nums;
    padding-top: 14px;
}

.wave-bars {
    flex: 1;
    height: 0px;
    display: flex;
    align-items: flex-end;
    gap: 0.2px;
    padding: 0 4px;
}

.bar {
    flex: 1;
    max-width: 2.5px;
    background: linear-gradient(to top, #667781, #9ca3af);
    border-radius: 1.5px 1.5px 0 0;
    transition: all 0.15s ease;
}

.record-pause-icon {
    font-size: 22px;
    color: #667781;
    flex-shrink: 0;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.1));
}

/* أزرار بجانب التسجيل */
.recording-actions {
    display: flex;
    gap: 8px;
    height: 56px;
}

.cancel-record-btn, .send-record-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.cancel-record-btn {
    background: rgba(255,59,48,0.12);
    color: #ff3b30;
    backdrop-filter: blur(10px);
}

    .cancel-record-btn:hover {
        background: rgba(255,59,48,0.2);
        transform: scale(1.05);
    }

    .cancel-record-btn:active {
        transform: scale(0.98);
    }

.send-record-btn {
    background: linear-gradient(135deg, #34c759 0%, #30d158 100%);
    color: white;
    box-shadow: 0 4px 16px rgba(52,199,89,0.4), 0 2px 8px rgba(0,0,0,0.1);
}

    .send-record-btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 24px rgba(52,199,89,0.5), 0 4px 12px rgba(0,0,0,0.15);
    }

    .send-record-btn:active {
        transform: translateY(-1px);
    }

/* تأثيرات إضافية */
.recording-shell::before {
    content: '';
    position: absolute;
    top: 4px;
    left: 12px;
    right: 12px;
    height: 2px;
    background: rgba(255,255,255,0.5);
    border-radius: 1px;
}

/* Mobile */
@media (max-width: 480px) {
    .voice-recorder {
        padding: 12px;
        gap: 8px;
    }

    .recording-actions {
        gap: 4px;
    }

    .cancel-record-btn, .send-record-btn {
        width: 44px;
        height: 44px;
    }
}
