/* ============================================ */
/* WHATSAPP DASHBOARD - ESTILOS COMPLETOS       */
/* ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
    background: #f5f5f7;
    color: #1d1d1f;
    line-height: 1.5;
    min-height: 100vh;
}

/* ============================================ */
/* NAVBAR */
/* ============================================ */
.navbar {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(15px);
    padding: 15px 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    flex-wrap: wrap;
    gap: 10px;
}

.navbar-brand {
    font-size: 20px;
    font-weight: 700;
    color: #1d1d1f;
    display: flex;
    align-items: center;
    gap: 10px;
}

.navbar-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #86868b;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #34c759;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ============================================ */
/* CONTAINER Y LAYOUT */
/* ============================================ */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.main-layout {
    display: flex;
    gap: 20px;
    height: calc(100vh - 160px);
    min-height: 500px;
}

/* ============================================ */
/* TABS */
/* ============================================ */
.tabs {
    display: flex;
    border-bottom: 1px solid #d2d2d7;
    margin-bottom: 20px;
    background: white;
    border-radius: 16px 16px 0 0;
    padding: 0 10px;
}

.tab {
    padding: 14px 24px;
    background: none;
    border: none;
    font-size: 14px;
    font-weight: 500;
    color: #86868b;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab:hover {
    color: #1d1d1f;
    background: rgba(0, 113, 227, 0.03);
}

.tab.active {
    color: #0071e3;
    border-bottom-color: #0071e3;
    font-weight: 600;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

/* ============================================ */
/* SIDEBAR */
/* ============================================ */
.sidebar {
    width: 350px;
    min-width: 300px;
    background: white;
    border-radius: 18px;
    border: 1px solid #e5e5e7;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid #e5e5e7;
    background: #fbfbfd;
}

.sidebar-header input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d2d2d7;
    border-radius: 10px;
    font-size: 13px;
    background: white;
    outline: none;
    transition: 0.2s;
}

.sidebar-header input:focus {
    border-color: #0071e3;
    box-shadow: 0 0 0 3px rgba(0,113,227,0.1);
}

.conversations-list {
    flex: 1;
    overflow-y: auto;
}

.conversation {
    display: flex;
    padding: 14px 16px;
    border-bottom: 1px solid #f2f2f7;
    cursor: pointer;
    transition: all 0.15s;
    align-items: center;
    gap: 12px;
}

.conversation:hover {
    background: #fbfbfd;
}

.conversation.active {
    background: #e8f5e9;
    border-left: 3px solid #34c759;
}

.conv-avatar {
    width: 42px;
    height: 42px;
    background: #0071e3;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 15px;
    flex-shrink: 0;
}

.conv-info {
    flex: 1;
    min-width: 0;
}

.conv-name {
    font-weight: 600;
    font-size: 14px;
    color: #1d1d1f;
    margin-bottom: 2px;
}

.conv-preview {
    font-size: 12px;
    color: #86868b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-meta {
    text-align: right;
    flex-shrink: 0;
}

.conv-time {
    font-size: 11px;
    color: #86868b;
}

.conv-badge {
    background: #0071e3;
    color: white;
    border-radius: 10px;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 600;
    margin-top: 4px;
    display: inline-block;
}

/* ============================================ */
/* CHAT AREA */
/* ============================================ */
.chat-area {
    flex: 1;
    background: white;
    border-radius: 18px;
    border: 1px solid #e5e5e7;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    padding: 14px 20px;
    border-bottom: 1px solid #e5e5e7;
    display: flex;
    align-items: center;
    gap: 12px;
    background: #fbfbfd;
}

.chat-header-info h3 {
    font-size: 15px;
    font-weight: 600;
}

.chat-header-info span {
    font-size: 11px;
    color: #86868b;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f5f5f7;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Mensajes */
.msg-bubble {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.msg-in {
    background: white;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    border: 1px solid #e5e5e7;
}

.msg-out {
    background: #0071e3;
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.msg-time {
    font-size: 10px;
    opacity: 0.7;
    text-align: right;
    margin-top: 3px;
}

/* Respuesta del envío (HTTP status) */
.chat-response {
    padding: 12px 16px;
    margin: 0 16px;
    border-radius: 10px;
    font-size: 12px;
    display: none;
    animation: slideDown 0.3s;
}

.chat-response.show {
    display: block;
}

.chat-response.success {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #a5d6a7;
}

.chat-response.error {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ef9a9a;
}

.chat-response pre {
    margin-top: 6px;
    font-size: 11px;
    background: rgba(0,0,0,0.04);
    padding: 8px;
    border-radius: 6px;
    overflow-x: auto;
    max-height: 120px;
    overflow-y: auto;
}

/* Input de chat */
.chat-input-area {
    padding: 14px 16px;
    border-top: 1px solid #e5e5e7;
    display: flex;
    gap: 10px;
    background: white;
}

.chat-input-area input {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid #d2d2d7;
    border-radius: 24px;
    font-size: 14px;
    background: #fbfbfd;
    outline: none;
    transition: 0.2s;
}

.chat-input-area input:focus {
    border-color: #0071e3;
    background: white;
    box-shadow: 0 0 0 4px rgba(0,113,227,0.1);
}

.chat-input-area button {
    width: 42px;
    height: 42px;
    background: #0071e3;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-input-area button:hover {
    background: #005bb5;
    transform: scale(1.05);
}

.chat-input-area button:disabled {
    background: #d2d2d7;
    cursor: not-allowed;
    transform: none;
}

/* ============================================ */
/* SECCIONES Y TARJETAS */
/* ============================================ */
.section-card {
    background: white;
    padding: 25px;
    border-radius: 18px;
    border: 1px solid #e5e5e7;
    margin-bottom: 20px;
}

.section-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #f2f2f7;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ============================================ */
/* FORMULARIOS */
/* ============================================ */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #1d1d1f;
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #d2d2d7;
    border-radius: 10px;
    font-size: 14px;
    background: #fbfbfd;
    outline: none;
    transition: 0.2s;
}

.form-input:focus {
    border-color: #0071e3;
    background: white;
    box-shadow: 0 0 0 4px rgba(0,113,227,0.1);
}

textarea.form-input {
    resize: vertical;
    min-height: 70px;
    font-family: inherit;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.form-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #0071e3;
}

.form-check label {
    font-size: 14px;
    cursor: pointer;
}

/* ============================================ */
/* BOTONES */
/* ============================================ */
.btn {
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 12px;
    border-radius: 20px;
}

.btn-primary {
    background: #0071e3;
    color: white;
}

.btn-primary:hover {
    background: #005bb5;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,113,227,0.2);
}

.btn-success {
    background: #34c759;
    color: white;
}

.btn-success:hover {
    background: #2db84e;
}

.btn-danger {
    background: #ff3b30;
    color: white;
}

.btn-danger:hover {
    background: #e0352b;
}

.btn-secondary {
    background: #f5f5f7;
    color: #1d1d1f;
    border: 1px solid #d2d2d7;
}

.btn-secondary:hover {
    background: #e5e5e7;
}

.btn-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ============================================ */
/* BADGES Y ETIQUETAS */
/* ============================================ */
.badge {
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 600;
}

.badge-success {
    background: #e8f5e9;
    color: #2e7d32;
}

.badge-error {
    background: #ffebee;
    color: #c62828;
}

.badge-info {
    background: #e3f2fd;
    color: #1565c0;
}

.http-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    font-family: 'SF Mono', 'Menlo', monospace;
}

.http-200 { background: #e8f5e9; color: #2e7d32; }
.http-400 { background: #fff3e0; color: #e65100; }
.http-401 { background: #ffebee; color: #c62828; }
.http-500 { background: #ffebee; color: #c62828; }

/* ============================================ */
/* CONFIGURACIÓN */
/* ============================================ */
.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 12px;
}

.config-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: #fbfbfd;
    border-radius: 10px;
    border: 1px solid #e5e5e7;
}

.config-label {
    font-size: 13px;
    font-weight: 600;
    color: #1d1d1f;
}

.config-value {
    font-family: 'SF Mono', 'Menlo', monospace;
    font-size: 12px;
    color: #0071e3;
    background: white;
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid #e5e5e7;
}

/* ============================================ */
/* MODALES */
/* ============================================ */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(8px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 20px;
    width: 90%;
    max-width: 460px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    animation: slideUp 0.3s;
}

.modal-content h3 {
    margin-bottom: 20px;
    font-size: 20px;
    color: #1d1d1f;
}

@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes slideDown {
    from { transform: translateY(-10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ============================================ */
/* ESTADOS VACÍOS */
/* ============================================ */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 50px 30px;
    color: #86868b;
    text-align: center;
    height: 100%;
}

.empty-state-icon {
    font-size: 56px;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state h3 {
    color: #1d1d1f;
    margin-bottom: 6px;
    font-size: 18px;
}

.empty-state p {
    font-size: 13px;
    max-width: 300px;
}

/* ============================================ */
/* LOGS */
/* ============================================ */
.log-box {
    background: #1d1d1f;
    color: #00ff00;
    padding: 20px;
    border-radius: 16px;
    font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
    font-size: 12px;
    height: 450px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
    line-height: 1.5;
}

/* ============================================ */
/* LOADING SPINNER */
/* ============================================ */
.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================ */
/* UTILIDADES */
/* ============================================ */
.mt-10 { margin-top: 10px; }
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }
.text-center { text-align: center; }
.text-muted { color: #86868b; }
.text-small { font-size: 12px; }

/* ============================================ */
/* SCROLLBAR */
/* ============================================ */
::-webkit-scrollbar {
    width: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #d2d2d7;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #b0b0b5;
}

/* ============================================ */
/* RESPONSIVE */
/* ============================================ */
@media (max-width: 900px) {
    .main-layout {
        flex-direction: column;
        height: auto;
    }
    
    .sidebar {
        width: 100%;
        max-height: 250px;
    }
    
    .chat-area {
        min-height: 400px;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .config-grid {
        grid-template-columns: 1fr;
    }
    
    .navbar {
        padding: 12px 15px;
    }
    
    .navbar-brand {
        font-size: 16px;
    }
    
    .tabs {
        overflow-x: auto;
    }
    
    .tab {
        padding: 12px 16px;
        font-size: 13px;
        white-space: nowrap;
    }
}