:root {
    --fed-blue: #002b66;
    --fed-blue-dark: #001b44;
    --fed-blue-light: #0d47a1;
    --fed-red: #ce1126;
    --fed-red-hover: #b00d1e;
    --fed-gold: #f59e0b;
    --wa-green: #25D366;
    --wa-green-dark: #128C7E;
    
    --bg-main: #f0f2f5;
    --bg-chat: #efeae2;
    --panel-bg: #ffffff;
    --border-color: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    
    --bubble-in: #ffffff;
    --bubble-out: #dcf8c6;
    --bubble-out-fed: #e8f0fe;
    
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -1px rgba(0,0,0,0.04);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ==========================================================================
   TOP BAR (HEADER FEDOVOLI)
   ========================================================================== */
.top-header {
    background: linear-gradient(135deg, var(--fed-blue-dark) 0%, var(--fed-blue) 100%);
    color: #ffffff;
    height: 60px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
    z-index: 20;
    border-bottom: 3px solid var(--fed-red);
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo {
    height: 42px;
    width: auto;
    object-fit: contain;
    background: #ffffff;
    padding: 3px 6px;
    border-radius: 6px;
}

.brand-info h1 {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-info p {
    font-size: 11px;
    color: #cbd5e1;
}

.status-badge {
    background: rgba(37, 211, 102, 0.15);
    border: 1px solid var(--wa-green);
    color: #a7f3d0;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--wa-green);
    box-shadow: 0 0 8px var(--wa-green);
}

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

.btn-header {
    background: rgba(255,255,255,0.1);
    color: #ffffff;
    border: 1px solid rgba(255,255,255,0.2);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-header:hover {
    background: rgba(255,255,255,0.2);
    border-color: #ffffff;
}

.btn-new-chat {
    background: var(--fed-red);
    border-color: var(--fed-red);
    font-weight: 600;
}

.btn-new-chat:hover {
    background: var(--fed-red-hover);
}

/* ==========================================================================
   APP CONTAINER LAYOUT
   ========================================================================== */
.app-container {
    display: flex;
    flex: 1;
    height: calc(100vh - 60px);
    overflow: hidden;
}

/* SIDEBAR IZQUIERDA (LISTA DE CHATS) */
.sidebar {
    width: 380px;
    background: var(--panel-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.sidebar-search-box {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background: #f8fafc;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input-wrapper i {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    font-size: 14px;
}

.search-input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 13.5px;
    background: #ffffff;
    outline: none;
    transition: border-color 0.2s;
}

.search-input:focus {
    border-color: var(--fed-blue);
    box-shadow: 0 0 0 2px rgba(0, 43, 102, 0.1);
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    list-style: none;
}

.chat-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    gap: 12px;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    transition: background 0.15s;
    position: relative;
}

.chat-item:hover {
    background: #f8fafc;
}

.chat-item.active {
    background: #eef2ff;
    border-left: 4px solid var(--fed-blue);
}

.chat-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--fed-blue);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    flex-shrink: 0;
}

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

.chat-info-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 4px;
}

.chat-name {
    font-size: 14.5px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-time {
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.chat-info-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-snippet {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.unread-badge {
    background: var(--wa-green);
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
}

/* ÁREA PRINCIPAL DE CHAT */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    background-color: var(--bg-chat);
    background-image: radial-gradient(#d1d5db 1px, transparent 1px);
    background-size: 20px 20px;
    position: relative;
}

.chat-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.chat-empty-state img {
    max-width: 130px;
    margin-bottom: 20px;
    opacity: 0.85;
}

.chat-empty-state h2 {
    font-size: 20px;
    color: var(--fed-blue);
    margin-bottom: 8px;
}

.chat-header {
    height: 60px;
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    z-index: 10;
}

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

.chat-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--fed-blue);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.chat-header-details h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.chat-header-details p {
    font-size: 12px;
    color: var(--wa-green-dark);
    font-weight: 500;
}

/* MENSAJES Y BURBUJAS */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px 25px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.message-row {
    display: flex;
    width: 100%;
}

.message-row.recibido {
    justify-content: flex-start;
}

.message-row.enviado {
    justify-content: flex-end;
}

.message-bubble {
    max-width: 65%;
    padding: 8px 12px;
    border-radius: 8px;
    position: relative;
    box-shadow: 0 1px 1px rgba(0,0,0,0.08);
    font-size: 14px;
    line-height: 1.45;
    word-break: break-word;
}

.message-row.recibido .message-bubble {
    background: var(--bubble-in);
    color: var(--text-primary);
    border-top-left-radius: 0;
}

.message-row.enviado .message-bubble {
    background: var(--bubble-out);
    color: #111827;
    border-top-right-radius: 0;
}

.message-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin-top: 4px;
    font-size: 11px;
    color: var(--text-muted);
}

.message-meta i {
    font-size: 13px;
    color: #3b82f6; /* Doble check azul */
}

/* BARRA DE PLANTILLAS RÁPIDAS */
.quick-templates-bar {
    background: #f8fafc;
    padding: 8px 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 8px;
    overflow-x: auto;
    white-space: nowrap;
}

.template-pill {
    background: #ffffff;
    border: 1px solid var(--border-color);
    color: var(--fed-blue);
    padding: 5px 12px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.template-pill:hover {
    background: var(--fed-blue);
    color: #ffffff;
    border-color: var(--fed-blue);
}

/* ÁREA DE ENTRADA DE TEXTO */
.chat-input-area {
    background: #ffffff;
    border-top: 1px solid var(--border-color);
    padding: 12px 20px;
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

.chat-textarea {
    flex: 1;
    min-height: 44px;
    max-height: 120px;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 22px;
    resize: none;
    outline: none;
    font-size: 14px;
    line-height: 1.4;
    background: #f8fafc;
    transition: border-color 0.2s;
}

.chat-textarea:focus {
    border-color: var(--fed-blue);
    background: #ffffff;
}

.btn-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--fed-blue);
    color: #ffffff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    flex-shrink: 0;
}

.btn-send:hover {
    background: var(--fed-blue-light);
    transform: scale(1.05);
}

.btn-send:active {
    transform: scale(0.95);
}

/* MODAL NUEVO CHAT */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: #ffffff;
    width: 420px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    overflow: hidden;
    transform: translateY(-20px);
    transition: transform 0.2s;
}

.modal-overlay.active .modal-card {
    transform: translateY(0);
}

.modal-header {
    background: var(--fed-blue);
    color: #ffffff;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 20px;
    cursor: pointer;
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    outline: none;
}

.form-control:focus {
    border-color: var(--fed-blue);
}

.modal-footer {
    padding: 14px 20px;
    background: #f8fafc;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.btn-secondary {
    background: #e2e8f0;
    color: var(--text-primary);
    border: none;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
}

.btn-primary {
    background: var(--fed-blue);
    color: #ffffff;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.btn-primary:hover {
    background: var(--fed-blue-light);
}
