:root {
    --bg-dark: #0f131f;
    --bg-card: #181d2f;
    --bg-nav: #141928;
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
    --primary: #2ecc71;
    --primary-hover: #27ae60;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --border: #2a3143;
    --input-bg: #0f131f;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
}

/* NAVBAR */
.navbar {
    background-color: var(--bg-nav);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
}

.tabs {
    display: flex;
    gap: 1rem;
}

.tab-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    background-color: var(--primary);
    border-color: var(--primary);
    color: #000;
}

/* CONTAINER */
.container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* CARDS */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.2);
}

.card h3 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
    color: white;
}

.card h4 {
    margin-bottom: 0.5rem;
    font-size: 1rem;
    color: white;
}

/* FORMS */
.flex-form {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
    min-width: 200px;
}

.form-group label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

input, select, textarea {
    background-color: var(--input-bg);
    border: 1px solid var(--border);
    color: white;
    padding: 0.6rem 0.8rem;
    border-radius: 6px;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
}

.mt-auto {
    margin-top: auto;
}
.mt-2 {
    margin-top: 1rem;
}
.mb-2 {
    margin-bottom: 1rem;
}

/* BUTTONS */
.btn {
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background-color: var(--primary);
    color: #000;
}
.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-danger {
    background-color: var(--danger);
    color: white;
}
.btn-danger:hover {
    background-color: var(--danger-hover);
}

.btn-secondary {
    background-color: var(--border);
    color: white;
}
.btn-secondary:hover {
    background-color: #3b4256;
}

.hidden {
    display: none !important;
}

/* FILTERS */
.filters {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}
.filter-group {
    flex: 1;
    min-width: 150px;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

/* LISTS & TABLES */
.list-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--input-bg);
    padding: 0.8rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    transition: border-color 0.2s;
}

.list-item:hover {
    border-color: var(--primary);
}

.item-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}
.item-title {
    font-weight: 600;
    color: white;
}
.item-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
}
.item-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

select.status-select {
    padding: 0.4rem;
    background-color: var(--bg-card);
}

/* TEMPLATES */
.toolbar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.btn-var {
    background-color: var(--border);
    border: none;
    color: white;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
}
.btn-var:hover {
    background-color: var(--primary);
    color: black;
}
.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

/* AJUSTES */
.ajustes-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}
.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.tag {
    background-color: var(--input-bg);
    border: 1px solid var(--border);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.tag span {
    cursor: pointer;
    color: var(--danger);
    font-weight: bold;
}
.tag span:hover {
    color: white;
}

/* ALERTS */
.alert-warning {
    background-color: rgba(245, 158, 11, 0.1);
    border: 1px solid #f59e0b;
    color: #fcd34d;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.envio-preview {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 0.3rem;
}

@media (max-width: 768px) {
    .ajustes-grid {
        grid-template-columns: 1fr;
    }
    .flex-form {
        flex-direction: column;
        align-items: stretch;
    }
    .tabs {
        overflow-x: auto;
    }
}

/* BADGES DE ESTADO WHATSAPP */
.status-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    font-weight: 600;
    margin-left: 1rem;
    display: inline-block;
}

.state-connected {
    background-color: rgba(46, 204, 113, 0.15);
    color: #2ecc71;
    border: 1px solid #2ecc71;
}

.state-disconnected {
    background-color: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid #ef4444;
}

#wa-qr-image img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Modal Styles */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
}
.modal.hidden {
    display: none !important;
}
.modal-content {
    background-color: var(--bg-card);
    padding: 2rem;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    position: relative;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    border: 1px solid var(--border);
}
.close-modal {
    position: absolute;
    right: 1.5rem;
    top: 1rem;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-muted);
}
.close-modal:hover {
    color: var(--text-main);
}

/* Estilos de Ventana de Chat */
.chat-messages-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 380px;
    min-height: 250px;
    overflow-y: auto;
    padding: 15px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.15);
    margin: 1rem 0;
}

.chat-msg {
    padding: 8px 12px;
    border-radius: 12px;
    max-width: 80%;
    word-wrap: break-word;
    font-size: 0.9rem;
    line-height: 1.4;
    position: relative;
}

.chat-msg.inbound {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    border-bottom-left-radius: 2px;
}

.chat-msg.outbound {
    align-self: flex-end;
    background: #00a884;
    color: #ffffff;
    border-bottom-right-radius: 2px;
}

.chat-msg-time {
    display: block;
    font-size: 0.7rem;
    margin-top: 4px;
    text-align: right;
    opacity: 0.65;
}

.chat-badge-bot {
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: #5c6bc0;
    color: white;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-left: 5px;
}

.chat-badge-bot.off {
    background: var(--text-muted);
}

/* Estilos de la barra lateral de chats dedicados */
.chat-sidebar-item {
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-sidebar-item:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.15);
}

.chat-sidebar-item.active-chat-item {
    background: rgba(0, 168, 132, 0.12);
    border-color: #00a884;
}

.chat-sidebar-item-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.chat-sidebar-item-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-sidebar-item-sub {
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Glassmorphism Login Overlay and Security Adjustments */
#login-overlay {
    background-color: rgba(15, 19, 31, 0.93) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

#login-overlay .modal-content {
    background: rgba(24, 29, 47, 0.75) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6) !important;
}

#login-overlay input {
    background-color: rgba(15, 19, 31, 0.6) !important;
    border: 1px solid var(--border) !important;
}

#login-overlay input:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 10px rgba(46, 204, 113, 0.2);
}
