/* Main Interface Styles */
.main-interface {
    display: none;
    width: 100%;
    height: 100vh;
    background: #f8f9fa;
}

.main-header {
    background: white;
    padding: 6px 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e1e5e9;
}

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

.header-left img {
    width: 140px;
    height: auto;
}

.header-left h2 {
    color: #1b68d8;
    font-size: 1.1em;
}

.agent-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9em;
}

.logout-btn {
    padding: 6px 12px;
    background: #e85aa8;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #4ab8a6;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* Tabs */
.tabs-container {
    background: white;
    border-bottom: 1px solid #e1e5e9;
}

.tabs {
    display: flex;
    max-width: 1200px;
    margin: 0 auto;
}

.tab {
    padding: 10px 20px;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
    font-weight: 500;
    font-size: 0.9em;
}

.tab.active {
    border-bottom-color: #1b68d8;
    color: #1b68d8;
    background: #f8f9fa;
}

.tab:hover {
    background: #f8f9fa;
}

.tab-icon {
    margin-right: 8px;
}

/* Content Area */
.content-area {
    display: flex;
    height: calc(100vh - 100px);
    overflow: hidden;
}

/* Chat Interface */
.chat-interface {
    display: none;
    width: 100%;
    height: 100%;
}

.chat-container {
    display: flex;
    height: 100%;
}

.conversations-list {
    width: 400px;
    background: white;
    border-right: 1px solid #e1e5e9;
    overflow-y: auto;
}

.conversations-header {
    padding: 15px;
    border-bottom: 1px solid #e1e5e9;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.conversations-header-title-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    width: 100%;
}

.conversations-campaign-filter {
    flex-shrink: 0;
    min-width: 160px;
    max-width: 100%;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    cursor: pointer;
    color: #333;
}

.conversations-header-title-row h3 {
    margin: 0;
    flex: 1;
    min-width: 120px;
}

.new-chat-btn {
    padding: 8px 15px;
    background: #4ab8a6;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
}

.conversation-item {
    padding: 16px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.conversation-item:hover {
    background: #f8f9fa;
    transform: translateX(2px);
}

.conversation-item.active {
    background: linear-gradient(135deg, #e3f2fd 0%, #f0f7ff 100%);
    border-left: 4px solid #1b68d8;
    box-shadow: 0 2px 8px rgba(30, 60, 114, 0.15);
    font-weight: 500;
}
.conversation-item.active .conversation-name {
    color: #1b68d8;
    font-weight: 600;
}

.conversation-header {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.conversation-avatar {
    position: relative;
    flex-shrink: 0;
}

.avatar-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1b68d8 0%, #2a5298 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 1.1em;
    box-shadow: 0 2px 8px rgba(30, 60, 114, 0.2);
}

.status-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.status-dot.status-open {
    background: #4ab8a6;
}

.status-dot.status-closed {
    background: #e85aa8;
}

.conversation-info {
    flex: 1;
    min-width: 0;
}

.conversation-name-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.conversation-name {
    font-weight: 600;
    color: #1b68d8;
    font-size: 1em;
    display: flex;
    align-items: center;
    gap: 6px;
}

.conversation-time {
    font-size: 0.75em;
    color: #999;
    white-space: nowrap;
    margin-left: 8px;
}

.conversation-preview {
    font-size: 0.85em;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 8px;
    line-height: 1.4;
}

.conversation-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
}

.conversation-phone {
    font-size: 0.8em;
    color: #666;
    display: flex;
    align-items: center;
    gap: 4px;
}

.message-count-badge {
    background: linear-gradient(135deg, #1b68d8 0%, #2a5298 100%);
    color: white;
    border-radius: 12px;
    padding: 3px 8px;
    font-size: 0.7em;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(30, 60, 114, 0.2);
}

.unread-badge {
    background: #e85aa8;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7em;
    font-weight: bold;
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    position: relative;
}

.chat-header {
    background: white;
    padding: 15px 20px;
    border-bottom: 1px solid #e1e5e9;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.chat-client-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.client-avatar {
    width: 40px;
    height: 40px;
    background: #1b68d8;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

.client-details h3 {
    color: #333;
    font-size: 1.1em;
}

.client-details p {
    color: #666;
    font-size: 0.9em;
}

.chat-actions {
    display: flex;
    gap: 10px;
}

.action-btn {
    padding: 8px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background 0.3s;
}

.close-chat-btn {
    background: #e85aa8;
    color: white;
}

.template-btn {
    background: #17a2b8;
    color: white;
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8f9fa;
    min-height: 0;
}

.message {
    margin-bottom: 15px;
    display: flex;
    align-items: flex-end;
}

.message.client {
    justify-content: flex-start;
}

.message.agent {
    justify-content: flex-end;
}

.message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 18px;
    position: relative;
}

.message.client .message-content {
    background: white;
    border: 1px solid #e1e5e9;
    border-bottom-left-radius: 5px;
}

.message.agent .message-content {
    background: #1b68d8;
    color: white;
    border-bottom-right-radius: 5px;
}

.message-time {
    font-size: 0.7em;
    color: #999;
    margin-top: 5px;
    text-align: right;
}

.message.client .message-time {
    text-align: left;
}

.message-status {
    margin-left: 5px;
    font-size: 0.8em;
}

.message.agent .message-status {
    color: rgba(255, 255, 255, 0.8);
}

.message.client .message-status {
    color: #999;
}

.chat-input {
    background: white;
    padding: 15px 20px;
    border-top: 1px solid #e1e5e9;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
    z-index: 100;
    box-shadow: 0 -2px 4px rgba(0,0,0,0.05);
    margin: 0;
}

.chat-input input {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid #e1e5e9;
    border-radius: 25px;
    font-size: 14px;
    outline: none;
}

.chat-input input:focus {
    border-color: #1b68d8;
}

.send-btn {
    padding: 12px 20px;
    background: #1b68d8;
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.3s;
}

.send-btn:hover {
    background: #2a5298;
}

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

.no-conversation {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #666;
    font-size: 1.2em;
}

/* Calls Interface */
.calls-interface {
    display: none;
    width: 100%;
    height: 100%;
    padding: 20px;
}

.calls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.call-card {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    border-left: 4px solid #1b68d8;
}

.call-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.call-status {
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.8em;
    font-weight: bold;
}

.status-incoming {
    background: #fff3cd;
    color: #856404;
}

.status-ongoing {
    background: #d4edda;
    color: #155724;
}

.status-completed {
    background: #d1ecf1;
    color: #0c5460;
}

.call-info h3 {
    color: #1b68d8;
    margin-bottom: 10px;
}

.call-info p {
    color: #666;
    margin-bottom: 5px;
}

.call-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.call-btn {
    padding: 8px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background 0.3s;
}

.answer-btn {
    background: #4ab8a6;
    color: white;
}

.hangup-btn {
    background: #e85aa8;
    color: white;
}

.transfer-btn {
    background: #ffc107;
    color: #333;
}

/* Contacts Interface */
.contacts-interface {
    display: none;
    width: 100%;
    height: 100%;
    padding: 20px;
    background: #f8f9fa;
}

.contacts-container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow: hidden;
}

.contacts-header {
    background: #1b68d8;
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.contacts-header h3 {
    margin: 0;
    font-size: 1.5em;
}

.contacts-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.contacts-actions .btn {
    padding: 8px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 500;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.contacts-actions .btn-primary {
    background: #4ab8a6;
    color: white;
}

.contacts-actions .btn-primary:hover {
    background: #3a9d8a;
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(74, 184, 166, 0.3);
}

.contacts-actions .btn-secondary {
    background: #6c757d;
    color: white;
}

.contacts-actions .btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(108, 117, 125, 0.3);
}

.contacts-search {
    padding: 20px;
    border-bottom: 1px solid #e1e5e9;
    background: #f8f9fa;
}

.contacts-search input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e1e5e9;
    border-radius: 25px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s;
}

.contacts-search input:focus {
    border-color: #1b68d8;
}

/* Estilos para el switch de vista de contactos */
.view-toggle-container {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 10px;
}

.view-toggle-container .btn-sm {
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: 8px;
    transition: all 0.3s ease;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e1e5e9;
}

.view-toggle-container .btn-sm i {
    font-size: 1.1em;
    color: #666;
}

.view-toggle-container .btn-sm:hover {
    opacity: 0.8;
    transform: translateY(-1px);
}

/* Estado activo - fondo verde */
.view-toggle-container .btn-sm.active {
    background: #4ab8a6;
}

.view-toggle-container .btn-sm.active i {
    color: white;
}

/* Estilos para vista de lista de contactos */
.contacts-list-container {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow-x: auto;
    max-height: calc(100vh - 300px);
    overflow-y: auto;
}

.contacts-list-table-wrapper {
    width: 100%;
    overflow-x: auto;
}

.contacts-list-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.contacts-list-table thead {
    background: #f2f5fb;
    position: sticky;
    top: 0;
    z-index: 10;
}

.contacts-list-table thead th {
    padding: 12px 15px;
    text-align: left;
    font-weight: 600;
    color: #1b68d8;
    border-bottom: 2px solid #e1e5e9;
    white-space: nowrap;
}

.contacts-list-table tbody td {
    padding: 12px 15px;
    border-bottom: 1px solid #eef2f7;
    vertical-align: middle;
    color: #333;
}

.contacts-list-table tbody tr {
    transition: background-color 0.2s;
}

.contacts-list-table tbody tr:hover {
    background: #f8fafc;
}

.contact-avatar-small {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #1b68d8;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.85em;
    flex-shrink: 0;
}

.contacts-grid {
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    max-height: calc(100vh - 300px);
    overflow-y: auto;
}

.contact-card {
    background: white;
    border: 1px solid #e1e5e9;
    border-radius: 10px;
    padding: 20px;
    transition: all 0.3s;
    position: relative;
}

.contact-card:hover {
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.contact-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

.contact-info {
    flex: 1;
}

.contact-avatar {
    width: 50px;
    height: 50px;
    background: #1b68d8;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 1.2em;
    margin-bottom: 10px;
}

.contact-name {
    font-size: 1.2em;
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
}

.contact-phone {
    color: #666;
    font-size: 0.9em;
    margin-bottom: 5px;
}

.contact-email {
    color: #666;
    font-size: 0.9em;
    margin-bottom: 5px;
}

.contact-company {
    color: #1b68d8;
    font-size: 0.9em;
    font-weight: 500;
    margin-bottom: 10px;
}

.contact-notes {
    color: #666;
    font-size: 0.8em;
    font-style: italic;
    margin-bottom: 15px;
    max-height: 40px;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.contact-btn {
    padding: 8px 12px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.8em;
    font-weight: 500;
    transition: all 0.3s;
    flex: 1;
    min-width: 80px;
}

.chat-btn {
    background: #4ab8a6;
    color: white;
}

.chat-btn:hover {
    background: #4ab8a6;
}

.call-btn {
    background: #17a2b8;
    color: white;
}

.call-btn:hover {
    background: #138496;
}

.edit-btn {
    background: #ffc107;
    color: #333;
}

.edit-btn:hover {
    background: #e0a800;
}

.contact-edit-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 1.2em;
    padding: 5px;
    border-radius: 3px;
    transition: all 0.3s;
}

.contact-edit-btn:hover {
    background: #f8f9fa;
    color: #1b68d8;
}

.no-contacts {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.no-contacts-icon {
    font-size: 4em;
    margin-bottom: 20px;
    opacity: 0.5;
}

.no-contacts h3 {
    margin-bottom: 10px;
    color: #333;
}

.no-contacts p {
    margin-bottom: 20px;
}

/* Button Styles */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 500;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: #1b68d8;
    color: white;
}

.btn-primary:hover {
    background: #2a5298;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-danger {
    background: #e85aa8;
    color: white;
}

.btn-danger:hover {
    background: #e85aa8;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    background: #1b68d8;
    color: white;
    padding: 20px;
    border-radius: 10px 10px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.3em;
}

.close-modal {
    background: none;
    border: none;
    color: white;
    font-size: 1.5em;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.3s;
}

.close-modal:hover {
    background: rgba(255,255,255,0.2);
}

.form-group {
    margin-bottom: 20px;
    padding: 0 20px;
}

.form-group:first-of-type {
    padding-top: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e1e5e9;
    border-radius: 5px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s;
    box-sizing: border-box;
}

.form-group input:focus,
.form-group textarea:focus {
    border-color: #1b68d8;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* Radios de plantilla de cierre: .form-group input { width:100% } no debe aplastarlos */
#closingTemplatesList input[type="radio"] {
    width: auto;
    max-width: none;
    padding: 0;
    margin: 3px 0 0 0;
    flex-shrink: 0;
    border: none;
    box-sizing: content-box;
}

#closingTemplatesList label .closing-template-text {
    flex: 1;
    min-width: 0;
}

.modal-actions {
    padding: 20px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    border-top: 1px solid #e1e5e9;
    background: #f8f9fa;
    border-radius: 0 0 10px 10px;
}

/* Audio Preview Modal Styles */
#audioPreviewModal .modal-content {
    max-width: 500px;
}

#audioPreviewPlayer {
    width: 100%;
    max-width: 400px;
    border-radius: 8px;
    outline: none;
}

#audioPreviewPlayer::-webkit-media-controls-panel {
    background-color: #f8f9fa;
    border-radius: 8px;
}

#audioPreviewDuration {
    font-weight: 600;
    color: #1b68d8;
}

#audioPreviewModal .modal-body {
    text-align: center;
    padding: 30px 20px;
}

#audioPreviewModal .modal-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 1em;
}

#audioPreviewModal .modal-actions .btn i {
    font-size: 0.9em;
}

/* Responsive */
@media (max-width: 768px) {
    .conversations-list {
        width: 300px;
    }
    
    .chat-header {
        padding: 10px 15px;
    }
    
    .chat-input {
        padding: 15px;
    }
    
    .calls-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .tabs {
        flex-direction: column;
    }
    
    .tab {
        text-align: center;
    }
    
    .contacts-grid {
        grid-template-columns: 1fr;
        gap: 15px;
        padding: 15px;
    }
    
    .contacts-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .contacts-actions {
        width: 100%;
        justify-content: center;
    }
    
    .contact-actions {
        flex-direction: column;
    }
    
    .contact-btn {
        flex: none;
        width: 100%;
    }
    
    .modal-content {
        width: 95%;
        margin: 10% auto;
    }
    
    .modal-actions {
        flex-direction: column;
    }
    
    .modal-actions .btn {
        width: 100%;
    }
}

/* Estilos para respuesta a mensajes */
.message-content {
    position: relative;
}

.message-reply-btn {
    position: absolute;
    top: 6px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    width: 22px;
    height: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s, transform 0.2s;
    z-index: 10;
    padding: 0;
    color: #666;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.message-reply-btn svg {
    width: 12px;
    height: 12px;
}

.message:hover .message-reply-btn {
    opacity: 1;
}

.message-reply-btn:hover {
    background: rgba(255, 255, 255, 1);
    color: #1b68d8;
    transform: scale(1.1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

/* Posición para mensajes entrantes (cliente) - esquina superior derecha */
.reply-btn-incoming {
    right: 8px;
    left: auto;
}

/* Posición para mensajes salientes (agente) - esquina superior izquierda */
.reply-btn-outgoing {
    left: 8px;
    right: auto;
}

.message.client .message-reply-btn {
    background: rgba(255, 255, 255, 0.95);
}

.message.client .message-reply-btn:hover {
    background: rgba(255, 255, 255, 1);
    color: #1b68d8;
}

.message.agent .message-reply-btn {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.8);
}

.message.agent .message-reply-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 1);
}

/* Vista previa de respuesta en el input */
.reply-preview-container {
    width: 100%;
    margin-bottom: 8px;
    padding: 8px 12px;
    background: #f0f7ff;
    border-left: 3px solid #1b68d8;
    border-radius: 8px;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.reply-preview-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.reply-preview-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.reply-preview-label {
    font-size: 0.75em;
    color: #666;
    font-weight: 500;
}

.reply-preview-message {
    font-size: 0.85em;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reply-preview-cancel {
    background: transparent;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 16px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s, color 0.2s;
    flex-shrink: 0;
}

.reply-preview-cancel:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #333;
}

/* Mensaje respondido montado sobre el mensaje original */
.message-reply-preview {
    margin-bottom: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    display: flex;
    gap: 8px;
    align-items: flex-start;
    opacity: 0.7;
    border-left: 3px solid;
}

.message-reply-preview.reply-incoming {
    background: rgba(255, 255, 255, 0.3);
    border-left-color: #1b68d8;
}

.message-reply-preview.reply-outgoing {
    background: rgba(255, 255, 255, 0.2);
    border-left-color: rgba(255, 255, 255, 0.6);
}

.message.agent .message-reply-preview.reply-incoming {
    background: rgba(255, 255, 255, 0.15);
    border-left-color: rgba(255, 255, 255, 0.6);
}

.message.agent .message-reply-preview.reply-outgoing {
    background: rgba(255, 255, 255, 0.1);
    border-left-color: rgba(255, 255, 255, 0.4);
}

.reply-indicator {
    font-size: 14px;
    flex-shrink: 0;
    opacity: 0.8;
}

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

.reply-author {
    font-size: 0.75em;
    font-weight: 600;
    margin-bottom: 2px;
    opacity: 0.9;
}

.message.client .message-reply-preview .reply-author {
    color: #1b68d8;
}

.message.agent .message-reply-preview .reply-author {
    color: rgba(255, 255, 255, 0.9);
}

.reply-text {
    font-size: 0.85em;
    opacity: 0.8;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message.client .message-reply-preview .reply-text {
    color: #333;
}

.message.agent .message-reply-preview .reply-text {
    color: rgba(255, 255, 255, 0.9);
}

/* Separador de fecha entre mensajes por día */
.chat-date-separator {
    text-align: center;
    margin: 16px 0 12px;
    padding: 6px 0;
}
.chat-date-separator-text {
    display: inline-block;
    padding: 4px 14px;
    border-radius: 12px;
    background: #e8ecf0;
    color: #555;
    font-size: 12px;
    font-weight: 600;
}

/* ===== Media modal (imagen/video en grande) ===== */
.chat-media-preview {
    cursor: pointer;
}

.media-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
}

.media-modal.is-open {
    display: block;
}

.media-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
}

.media-modal__dialog {
    position: relative;
    margin: 6vh auto;
    width: min(1100px, 92vw);
    max-height: 88vh;
    background: #0f1115;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.media-modal__close {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 28px;
    line-height: 40px;
    cursor: pointer;
}

.media-modal__close:hover {
    background: rgba(255, 255, 255, 0.18);
}

.media-modal__body {
    padding: 54px 16px 16px;
    display: grid;
    place-items: center;
    max-height: 88vh;
}

.media-modal__body img,
.media-modal__body video {
    max-width: 100%;
    max-height: calc(88vh - 90px);
    border-radius: 10px;
    background: #000;
}

/* SIP Dialer Styles */
.dialer-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.dialpad button:active {
    background-color: #e2e6ea !important;
    transform: scale(0.95);
}

.call-btn {
    transition: transform 0.1s, opacity 0.2s;
    border: none;
    color: white;
    cursor: pointer;
}

.call-btn:hover {
    opacity: 0.9;
    transform: scale(1.05);
}

.status-ongoing {
    background-color: #28a745;
    color: white;
}

.status-incoming {
    background-color: #ffc107;
    color: #333;
}

/* Pantalla de carga (logo Canalium) */
.app-loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99999;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
.app-loading-screen.hiding {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.app-loading-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}
.app-loading-logo {
    max-width: 200px;
    height: auto;
    object-fit: contain;
}
.app-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e1e5e9;
    border-top-color: #1b68d8;
    border-radius: 50%;
    animation: app-loading-spin 0.9s linear infinite;
}
@keyframes app-loading-spin {
    to { transform: rotate(360deg); }
}
.app-loading-text {
    margin: 0;
    font-size: 14px;
    color: #666;
    font-weight: 500;
}
