/* =====================================
   ADMIN CHAT MANAGEMENT
===================================== */
.chat-admin-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px;
}

.chat-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
    background: #fff;
    padding: 15px 20px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

.chat-header-bar h2 {
    margin: 0;
    font-size: 24px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-badge {
    background: #dc3545;
    color: white;
    border-radius: 50%;
    padding: 3px 9px;
    font-size: 13px;
    font-weight: bold;
}

.back-btn {
    background: #333;
    color: white;
    padding: 10px 18px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: bold;
    font-size: 14px;
    transition: background 0.3s;
}

.back-btn:hover {
    background: #555;
}

/* TABLE STYLES (DESKTOP) */
.table-wrapper {
    background: #fff;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    overflow-x: auto;
}

#chatTable {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

#chatTable th, 
#chatTable td {
    padding: 12px 15px;
    border: 1px solid #e0e0e0;
    text-align: left;
    vertical-align: top;
}

#chatTable th {
    background-color: #f8f9fa;
    color: #333;
    font-weight: bold;
}

#chatTable tr:hover {
    background-color: #f8f9fa;
}

.admin-reply-box {
    background: #e9ecef;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 8px;
    font-size: 13px;
    color: #333;
    word-break: break-word;
}

.reply-form {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.reply-form textarea {
    width: 100%;
    min-height: 60px;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 13px;
    resize: vertical;
    box-sizing: border-box;
}

.send-btn {
    background: #0d6efd;
    color: white;
    border: none;
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    font-size: 13px;
    align-self: flex-start;
    transition: background 0.3s;
}

.send-btn:hover {
    background: #0b5ed7;
}

.status-badge {
    font-size: 13px;
    font-weight: bold;
    white-space: nowrap;
}

.status-badge.answered { color: #198754; }
.status-badge.pending { color: #dc3545; }

.delete-btn {
    color: #dc3545;
    text-decoration: none;
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 4px;
    background: #f8d7da;
    display: inline-block;
}

/* Pagination */
.pagination-container {
    text-align: center;
    margin: 30px 0;
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.page-btn {
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: bold;
    font-size: 14px;
}

.prev-btn { background: #6c757d; }
.next-btn { background: #212529; }

/* =====================================
   FRONTEND USER CHAT WIDGET
===================================== */
#chat-button {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 55px;
    height: 55px;
    background: #1976d2;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    cursor: pointer;
    z-index: 9999;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    transition: transform 0.2s;
}

#chat-button:hover {
    transform: scale(1.08);
}

#chat-box {
    display: none; /* JS-ով բացվելուց flex կդառնա */
    position: fixed;
    right: 20px;
    bottom: 85px;
    width: 340px;
    max-width: calc(100vw - 40px);
    height: 480px;
    max-height: calc(100vh - 110px);
    background: white;
    border-radius: 15px;
    box-shadow: 0 5px 30px rgba(0,0,0,0.2);
    z-index: 9999;
    overflow: hidden;
    flex-direction: column;
}

/* JS-ով չատը բացելիս display: flex; տուր */
#chat-box.open, #chat-box[style*="display: block"] {
    display: flex !important;
}

.chat-header {
    background: #1976d2;
    color: white;
    padding: 14px 18px;
    font-size: 16px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#chat-close {
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
}

#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    background: #f9f9f9;
}

.user-msg {
    background: #e3f2fd;
    color: #0d47a1;
    padding: 10px 12px;
    border-radius: 12px 12px 2px 12px;
    margin: 8px 0 8px auto;
    max-width: 85%;
    font-size: 14px;
    word-break: break-word;
}

.admin-msg {
    background: #ffffff;
    color: #333;
    padding: 10px 12px;
    border-radius: 12px 12px 12px 2px;
    margin: 8px 0;
    max-width: 85%;
    font-size: 14px;
    word-break: break-word;
    border: 1px solid #e2e8f0;
}

/* Chat User Info Inputs (Անուն, Հեռախոս) */
.chat-user {
    display: flex;
    gap: 6px;
    padding: 8px 10px;
    background: #f1f3f5;
    border-top: 1px solid #e0e0e0;
}

.chat-user input {
    flex: 1;
    width: 50%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 12px;
    outline: none;
    box-sizing: border-box;
}

/* Chat Message Input & Send */
.chat-input {
    display: flex;
    padding: 10px;
    border-top: 1px solid #eee;
    background: #fff;
}

.chat-input input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 8px;
    outline: none;
    font-size: 14px;
}

.chat-input button {
    background: #1976d2;
    color: white;
    border: none;
    padding: 0 16px;
    margin-left: 8px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.2s;
}

.chat-input button:hover {
    background: #1565c0;
}

/* =====================================
   RESPONSIVE MOBILE VIEW
===================================== */
@media (max-width: 768px) {
    .chat-header-bar {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }

    .back-btn {
        text-align: center;
        width: 100%;
        box-sizing: border-box;
    }

    #chatTable, #chatTable thead, #chatTable tbody, #chatTable th, #chatTable td, #chatTable tr {
        display: block;
    }

    #chatTable thead {
        display: none;
    }

    #chatTable tr {
        background: #fff;
        margin-bottom: 15px;
        border-radius: 10px;
        padding: 12px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.06);
        border: 1px solid #e0e0e0;
    }

    #chatTable td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        padding: 8px 0;
        border: none;
        border-bottom: 1px solid #f0f0f0;
        text-align: right;
    }

    #chatTable td:last-child {
        border-bottom: none;
    }

    #chatTable td::before {
        content: attr(data-label);
        font-weight: bold;
        color: #555;
        text-align: left;
        padding-right: 15px;
        min-width: 100px;
    }

    .msg-cell, .reply-cell {
        flex-direction: column;
        align-items: flex-start !important;
        text-align: left !important;
    }

    .reply-form {
        width: 100%;
        margin-top: 5px;
    }

    .send-btn {
        width: 100%;
    }

    #chat-box {
        right: 10px;
        bottom: 75px;
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
    }
}