/* 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: 150px;
    max-width: 46%;
    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;
}

/* SLA Juju: chats en cola con correo @juju.com.co */
.conversation-item.juju-sla-item {
    background: #fff5f5;
    border-left: 4px solid #dc3545;
    box-shadow: 0 0 0 1px rgba(220, 53, 69, 0.25);
}
.conversation-item.juju-sla-item:hover {
    background: #ffe8e8;
}
.conversation-item.juju-sla-item .conversation-name {
    color: #dc3545;
}
.conversation-item.juju-sla-item.active {
    background: linear-gradient(135deg, #ffe8e8 0%, #fff0f0 100%);
    border-left: 4px solid #dc3545;
}
.conversation-item.juju-sla-item.active .conversation-name {
    color: #b02a37;
}
.juju-sla-timer,
.juju-sla-timer-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 52px;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: #fff;
    background: #dc3545;
    letter-spacing: 0.02em;
}
.juju-sla-timer.juju-sla-overdue,
.juju-sla-timer-badge.juju-sla-overdue {
    background: #a71d2a;
}
.juju-sla-separator {
    margin: 12px;
    padding: 8px 10px;
    border-top: 2px solid #dc3545;
    border-bottom: 2px solid #dc3545;
    background: #fff5f5;
    text-align: center;
    color: #dc3545;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Cola normal: más visible + cronómetro ascendente (tiempo en espera) */
.conversation-item.queue-wait-item {
    background: linear-gradient(135deg, #fff0f8 0%, #ffe0f2 50%, #ffd6ee 100%);
    border-left: 5px solid #e85aa8;
    box-shadow:
        0 0 0 2px rgba(232, 90, 168, 0.45),
        0 4px 14px rgba(232, 90, 168, 0.28);
    animation: queue-wait-pulse 2s ease-in-out infinite;
    border-radius: 10px;
    margin: 6px 8px;
}
.conversation-item.queue-wait-item:hover {
    background: linear-gradient(135deg, #ffe8f5 0%, #ffd0eb 100%);
    box-shadow:
        0 0 0 3px rgba(232, 90, 168, 0.55),
        0 6px 18px rgba(232, 90, 168, 0.35);
}
.conversation-item.queue-wait-item .conversation-name {
    color: #c2187a;
    font-weight: 700;
}
.conversation-item.queue-wait-item.active {
    background: linear-gradient(135deg, #ffd6ee 0%, #ffc4e8 100%);
    border-left: 5px solid #d81b7a;
    box-shadow:
        0 0 0 3px rgba(216, 27, 122, 0.4),
        0 4px 16px rgba(232, 90, 168, 0.35);
}
.conversation-item.queue-wait-item.active .conversation-name {
    color: #9c145c;
}
@keyframes queue-wait-pulse {
    0%, 100% { box-shadow: 0 0 0 2px rgba(232, 90, 168, 0.4), 0 4px 12px rgba(232, 90, 168, 0.22); }
    50% { box-shadow: 0 0 0 4px rgba(232, 90, 168, 0.65), 0 6px 20px rgba(232, 90, 168, 0.38); }
}
.queue-wait-timer,
.queue-wait-timer-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 56px;
    padding: 3px 10px;
    margin-right: 4px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: #fff;
    background: linear-gradient(135deg, #e85aa8 0%, #d63384 100%);
    letter-spacing: 0.03em;
    box-shadow: 0 2px 6px rgba(214, 51, 132, 0.45);
}
.queue-wait-timer-badge::before,
.queue-wait-timer::before {
    content: '▲ ';
    font-size: 9px;
    opacity: 0.9;
}
.queue-wait-timer.queue-wait-long,
.queue-wait-timer-badge.queue-wait-long {
    background: linear-gradient(135deg, #c2187a 0%, #9c145c 100%);
    animation: queue-wait-timer-blink 1.2s ease-in-out infinite;
}
@keyframes queue-wait-timer-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.85; }
}
.queue-wait-separator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 14px 10px 8px;
    padding: 10px 12px;
    border-top: 3px solid #e85aa8;
    border-bottom: 3px solid #e85aa8;
    background: linear-gradient(90deg, #fff5fb 0%, #ffe8f5 50%, #fff5fb 100%);
    color: #c2187a;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(232, 90, 168, 0.2);
}
.queue-wait-separator-icon {
    font-size: 16px;
    line-height: 1;
}

.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-template-session-banner {
    flex-shrink: 0;
    padding: 12px 16px;
    margin: 0;
    background: linear-gradient(135deg, #fff4e0 0%, #ffe8cc 100%);
    border-bottom: 1px solid #e8c066;
    color: #5c3d00;
    font-size: 13px;
    line-height: 1.45;
    box-shadow: 0 2px 6px rgba(180, 120, 0, 0.12);
}

.chat-template-session-banner__row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.chat-template-session-banner__icon {
    flex-shrink: 0;
    font-size: 1.25rem;
    line-height: 1.2;
}

.chat-template-session-banner__text {
    flex: 1;
    min-width: 0;
}

.chat-template-session-banner__text strong {
    display: block;
    margin-bottom: 4px;
    color: #3d2800;
    font-size: 0.95rem;
}

.chat-template-session-banner__text span {
    display: block;
    font-weight: 500;
    opacity: 0.95;
}

.chat-input.chat-input--locked {
    opacity: 0.65;
    pointer-events: none;
}

.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);
}

#startChatFromContactModal {
    z-index: 10050;
}

/* Modal: iniciar chat desde contacto (solo plantilla Meta) */
.modal-content--start-chat {
    max-width: 460px;
    overflow: hidden;
    border-radius: 14px;
    box-shadow: 0 24px 48px rgba(15, 23, 42, 0.18), 0 0 0 1px rgba(15, 23, 42, 0.06);
}

.modal-header.modal-header--start-chat {
    background: linear-gradient(135deg, #0d9488 0%, #0f766e 45%, #115e59 100%);
    padding: 18px 20px;
    align-items: flex-start;
    border-radius: 14px 14px 0 0;
}

.modal-header.modal-header--start-chat h3 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.modal-header-sub {
    margin: 6px 0 0 0;
    font-size: 0.82rem;
    opacity: 0.92;
    font-weight: 400;
}

.start-chat-body {
    padding: 18px 20px 8px;
    background: linear-gradient(180deg, #f8fafc 0%, #fff 28%);
}

.start-chat-contact-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    margin-bottom: 16px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    font-size: 0.95rem;
    font-weight: 600;
    color: #0f172a;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
    max-width: 100%;
    word-break: break-word;
}

.start-chat-field {
    margin-bottom: 16px;
}

.start-chat-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
    margin-bottom: 8px;
}

.start-chat-select {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 14px;
    background: #fff;
    color: #0f172a;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.start-chat-select:focus {
    outline: none;
    border-color: #0d9488;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.2);
}

.start-chat-hint {
    margin: 8px 0 0 0;
    font-size: 0.8rem;
    color: #64748b;
    line-height: 1.45;
}

.start-chat-hint--muted {
    color: #94a3b8;
    font-size: 0.78rem;
}

.start-chat-template-panel {
    margin-top: 4px;
    padding: 16px;
    background: #f0fdfa;
    border: 1px solid #99f6e4;
    border-radius: 12px;
}

.start-chat-template-panel__head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.start-chat-badge-meta {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: #0d9488;
    color: #fff;
}

.start-chat-template-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: #134e4a;
}

.start-chat-template-desc {
    margin: 0 0 12px 0;
    font-size: 0.85rem;
    color: #475569;
    line-height: 1.45;
}

.start-chat-template-fields {
    display: block;
}

.start-chat-template-vars {
    margin-top: 10px;
}

.start-chat-template-vars .form-group {
    margin-bottom: 10px;
    padding: 0;
}

.modal-actions--start-chat {
    padding: 16px 20px 20px;
    margin: 0;
    gap: 12px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
}

.btn--start-chat-confirm {
    min-width: 140px;
    padding: 10px 18px;
    border-radius: 10px;
    font-weight: 600;
    background: linear-gradient(135deg, #0d9488, #0f766e);
    border: none;
}

.btn--start-chat-confirm:hover {
    filter: brightness(1.05);
}

.btn--start-chat-cancel {
    border-radius: 10px;
    padding: 10px 16px;
}

.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);
}

.message-edit-btn {
    position: absolute;
    top: 6px;
    left: 36px;
    right: auto;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    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: rgba(255, 255, 255, 0.85);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

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

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

.message-edit-btn:hover {
    background: rgba(255, 255, 255, 0.35);
    color: #fff;
    transform: scale(1.1);
}

.edit-message-hint {
    margin: 0 0 12px;
    font-size: 13px;
    color: #666;
    line-height: 1.4;
}

#editMessageTextarea {
    width: 100%;
    resize: vertical;
    min-height: 100px;
}

/* 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;
}
