/* Variables de Color y Sombra Refinadas */
:root {
    --primary-green: #25D366; /* WhatsApp Green */
    --dark-green: #128C7E;
    --accent-purple: #764ba2; /* More distinct accent */
    --light-purple: #667eea;

    /* Neutral Palette for text and backgrounds */
    --gray-900: #1a202c; /* Darkest text/headings */
    --gray-700: #4a5568; /* Body text */
    --gray-500: #718096; /* Secondary text/icons */
    --gray-300: #e2e8f0; /* Borders, light lines */
    --gray-100: #f7fafc; /* Light backgrounds */

    /* Backgrounds */
    --bg-body: linear-gradient(135deg, #e0f2f7 0%, #d4eaf0 100%); /* Lighter, subtle gradient */
    --bg-card: rgba(255, 255, 255, 0.98); /* Slightly less opaque for better backdrop blur */
    --bg-chat: #f0f2f5; /* WhatsApp chat background */

    /* Shadows - More sophisticated and layered */
    --shadow-sm: rgba(0, 0, 0, 0.04) 0px 1px 3px, rgba(0, 0, 0, 0.08) 0px 1px 2px;
    --shadow-md: rgba(0, 0, 0, 0.05) 0px 6px 24px 0px, rgba(0, 0, 0, 0.08) 0px 0px 0px 1px;
    --shadow-lg: rgba(0, 0, 0, 0.1) 0px 10px 15px -3px, rgba(0, 0, 0, 0.05) 0px 4px 6px -2px;

    /* Alerts & Status */
    --red-error: #ef4444;
    --orange-alert: #f97316;
    --blue-info: #3b82f6;
    --green-success: #22c55e;
    --yellow-warning: #facc15;

    /* Nuevas variables para alturas de layout */
    --header-height-base: 6rem; /* Altura base del header en desktop */
    --nav-height-base: 4rem; /* Altura base del nav en desktop */
    --container-margin-vertical: 1.5rem; /* Margen vertical del contenedor */
}

/* Base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-body);
    min-height: 100vh;
    color: var(--gray-700);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start; /* Align to top */
}

.container {
    max-width: 90rem; /* 1440px */
    margin: var(--container-margin-vertical) auto; /* More vertical spacing */
    padding: 1.5rem; /* 24px */
    width: 100%;
    flex-grow: 1; /* Allow container to grow and fill space */
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: var(--bg-card);
    backdrop-filter: blur(12px); /* Slightly more blur */
    border-radius: 1.5rem; /* Larger border-radius */
    padding: 1.5rem 2rem; /* More padding */
    margin-bottom: 1.5rem; /* 24px */
    box-shadow: var(--shadow-md); /* Consistent shadow */
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.25rem; /* 20px */
}

.header h1 {
    color: var(--gray-900); /* Darker for professionalism */
    font-size: 2rem; /* Larger title */
    font-weight: 800; /* Bolder */
    display: flex;
    align-items: center;
    gap: 0.75rem; /* More space for icon */
}

.header h1 .bx {
    font-size: 2.5rem; /* Larger icon */
    color: var(--primary-green);
}

.header-search {
    flex: 1;
    max-width: 30rem; /* Wider search bar */
    position: relative;
}

.search-input {
    width: 100%;
    padding: 0.875rem 2.8rem 0.875rem 1.25rem; /* More padding, space for button */
    border: 1px solid var(--gray-300);
    border-radius: 2rem; /* More rounded */
    font-size: 0.9375rem; /* Slightly larger text */
    transition: all 0.3s ease-in-out;
    background-color: white;
    color: var(--gray-700);
}

.search-input::placeholder {
    color: var(--gray-500);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-green);
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.15); /* Stronger focus ring */
}

.search-button {
    position: absolute;
    right: 0.5rem; /* 8px */
    top: 50%;
    transform: translateY(-50%);
    background: var(--primary-green);
    border: none;
    border-radius: 50%;
    width: 2.25rem; /* 36px */
    height: 2.25rem; /* 36px */
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease-in-out;
    box-shadow: var(--shadow-sm);
}

.search-button:hover {
    background-color: var(--dark-green);
    transform: translateY(-50%) scale(1.05); /* Slight scale on hover */
    box-shadow: var(--shadow-md);
}

.search-button i {
    font-size: 1.25rem; /* Larger icon */
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem; /* 16px */
}

.notifications-icon {
    position: relative;
    background: var(--gray-100);
    border: none;
    border-radius: 50%;
    width: 2.75rem; /* 44px */
    height: 2.75rem; /* 44px */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease-in-out;
    box-shadow: var(--shadow-sm);
}

.notifications-icon:hover {
    background: var(--gray-300);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.notifications-icon i {
    font-size: 1.5rem; /* Larger icon */
    color: var(--gray-700);
}

.notification-badge {
    position: absolute;
    top: -0.375rem; /* -6px */
    right: -0.375rem; /* -6px */
    background: var(--red-error);
    color: white;
    border-radius: 50%;
    width: 1.25rem; /* 20px */
    height: 1.25rem; /* 20px */
    font-size: 0.75rem; /* 12px */
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    border: 2px solid white; /* White border for pop */
}

#userDisplay {
    font-weight: 600;
    color: var(--gray-900);
}

.role-badge {
    padding: 0.4rem 0.9rem; /* More padding */
    border-radius: 1.5rem; /* More rounded */
    font-size: 0.8rem; /* Slightly larger */
    font-weight: 700; /* Bolder */
    text-transform: uppercase;
    letter-spacing: 0.05em; /* Spacing for uppercase */
    box-shadow: var(--shadow-sm);
}

.role-admin { background: var(--red-error); color: white; }
.role-supervisor { background: var(--orange-alert); color: white; }
.role-agent { background: var(--primary-green); color: white; }

.status-indicator {
    width: 0.875rem; /* 14px */
    height: 0.875rem; /* 14px */
    border-radius: 50%;
    background: var(--red-error); /* Disconnected default */
    animation: pulse 2s infinite;
    border: 2px solid white; /* White border */
}

.status-indicator.connected {
    background: var(--primary-green);
}

@keyframes pulse {
    0% { transform: scale(0.9); opacity: 0.8; }
    50% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(0.9); opacity: 0.8; }
}

/* Navigation Tabs */
.nav-tabs {
    display: flex;
    background: var(--bg-card);
    border-radius: 1rem; /* 16px */
    padding: 0.5rem; /* 8px */
    margin-bottom: 1.5rem; /* 24px */
    box-shadow: var(--shadow-md);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 0.5rem; /* Gap between tabs */
    flex-shrink: 0; /* Prevent tabs from shrinking */
}

.nav-tab {
    flex: 1;
    min-width: 8.5rem; /* 136px - slightly wider */
    padding: 0.8rem 1.5rem; /* More padding */
    text-align: center;
    border-radius: 0.75rem; /* 12px */
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1); /* Smoother transition */
    font-weight: 600; /* Bolder text */
    color: var(--gray-700);
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem; /* More space for icon */
}

.nav-tab.active {
    background: var(--primary-green);
    color: white;
    box-shadow: 0 4px 15px rgba(37, 211, 102, 0.35); /* Stronger shadow for active */
    transform: translateY(-2px); /* Slight lift */
}

.nav-tab:hover:not(.active) {
    background: rgba(37, 211, 102, 0.08); /* Lighter hover background */
    color: var(--dark-green); /* Darker green on hover */
    transform: translateY(-1px); /* Slight lift */
}

.nav-tab .bx {
    font-size: 1.3rem; /* Slightly larger icons */
}

/* Tab Content */
.tab-content {
    display: none;
    flex-grow: 1; /* Allow tab content to fill remaining space */
}

.tab-content.active {
    display: block;
}

/* Main Layout (Tickets Tab) */
.main-layout {
    display: grid;
    grid-template-columns: 1fr; /* Default to single column for small screens */
    gap: 1.5rem; /* 24px */
    /* MODIFICADO: Ajustes de altura para que el chat-panel pueda usar 100% de su padre */
    height: calc(100vh - (var(--header-height-base) + var(--nav-height-base) + (var(--container-margin-vertical) * 2))); /* Altura total disponible en la vista */
    min-height: 0; /* Permite que se contraiga si el contenido es menor */
}

.sidebar, .chat-panel, .details-panel {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border-radius: 1.5rem; /* Consistent border-radius */
    overflow: hidden;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    border: 1px solid var(--gray-300); /* Subtle border */
    height: 100%; /* Fill parent grid cell */
    min-height: 0; /* Permite a los paneles ser flexibles en altura */
}
    
/* Specific height for chat panel to fit well within its area */
.chat-panel {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.sidebar-header, .details-header {
    background: linear-gradient(135deg, var(--primary-green) 0%, var(--dark-green) 100%); /* Green gradient for sidebar/details header */
    color: white;
    padding: 1.25rem 1.5rem; /* More padding */
    font-weight: 700; /* Bolder */
    font-size: 1.2rem; /* Larger text */
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255,255,255,0.2); /* Subtle line */
}

.details-header {
    background: linear-gradient(135deg, var(--light-purple) 0%, var(--accent-purple) 100%); /* Purple gradient for details */
}

.sidebar-header i, .details-header i {
    font-size: 1.75rem; /* Larger icons */
    margin-right: 0.6rem;
}

.filters {
    padding: 1.25rem 1.5rem; /* More padding */
    border-bottom: 1px solid var(--gray-300);
    flex-shrink: 0;
    position: relative;
    z-index: 10;
    display: grid;
    gap: 0.75rem; /* Gap between filters */
}

.filter-group label {
    display: block;
    margin-bottom: 0.3rem; /* 5px */
    font-weight: 600; /* Bolder label */
    color: var(--gray-700);
    font-size: 0.875rem;
}

.filter-select, .form-input, .form-textarea {
    width: 100%;
    padding: 0.75rem; /* 12px */
    border: 1px solid var(--gray-300);
    border-radius: 0.75rem; /* 12px */
    background: white;
    font-size: 0.9rem; /* 14px */
    color: var(--gray-900);
    transition: border-color 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
}

.filter-select:focus, .form-input:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--primary-green);
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.15); /* Stronger focus ring */
}

.tickets-list {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1rem; 
    -webkit-overflow-scrolling: touch;
    scroll-behavior: auto; 
}

.ticket-item {
    background: white;
    border-radius: 1rem; /* 16px */
    padding: 1rem; /* 16px */
    margin-bottom: 0.75rem; /* 12px */
    cursor: pointer;
    /* MODIFICADO: Transición más suave y específica */
    transition: box-shadow 0.2s ease, transform 0.1s ease;
    border: 1px solid var(--gray-300); /* Subtle border */
    box-shadow: var(--shadow-sm);
    position: relative;
}

.ticket-item:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px); /* Movimiento muy sutil */
}

/* AGREGADO: Estado activo sin transiciones bruscas */
.ticket-item.active {
    border-color: var(--primary-green);
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
    /* NO agregamos transform aquí para evitar saltos */
}

.ticket-item:hover {
    transform: translateY(-3px); /* Stronger lift */
    box-shadow: var(--shadow-md);
}

.ticket-item.active {
    border-color: var(--primary-green);
    background: #e9ffee; /* Lighter shade of green for active */
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.2); /* Active state ring */
}

.ticket-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.6rem; /* 10px */
}

.customer-name {
    font-weight: 700; /* Bolder */
    color: var(--gray-900);
    display: flex;
    align-items: center;
    gap: 0.6rem; /* 10px */
    font-size: 1.05rem; /* Slightly larger */
}

.customer-avatar {
    width: 2.25rem; /* 36px */
    height: 2.25rem; /* 36px */
    border-radius: 50%;
    background: var(--primary-green);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.9rem; /* 14px */
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.priority-badge {
    padding: 0.3rem 0.6rem; /* 5px 10px */
    border-radius: 1rem; /* More rounded */
    font-size: 0.7rem; /* 11px */
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.priority-urgent { background: #fee2e2; color: var(--red-error); }
.priority-high { background: #fef3c7; color: var(--orange-alert); }
.priority-medium { background: #dcfce7; color: var(--green-success); }
.priority-low { background: #f3f4f6; color: var(--gray-700); }

.ticket-meta {
    display: flex;
    gap: 0.75rem; /* 12px */
    font-size: 0.8rem; /* 13px */
    color: var(--gray-500);
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 0.6rem;
}
.ticket-meta i {
    font-size: 0.9rem;
    margin-right: 0.15rem;
    color: var(--gray-600);
}

.status-badge {
    padding: 0.2rem 0.6rem; /* 4px 10px */
    border-radius: 0.6rem; /* 10px */
    font-size: 0.7rem; /* 11px */
    font-weight: 600;
}

.status-open { background: #dbeafe; color: #1d4ed8; }
.status-assigned { background: #fef3c7; color: var(--orange-alert); }
.status-closed { background: #f3f4f6; color: var(--gray-600); }

.ticket-preview {
    font-size: 0.875rem; /* 14px */
    color: var(--gray-700);
    margin-bottom: 0.6rem;
    max-height: 2.5rem; /* Limit preview height */
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2; /* Show maximum 2 lines */
    -webkit-box-orient: vertical;
}

.ticket-tags {
    display: flex;
    gap: 0.3rem; /* 5px */
    flex-wrap: wrap;
}

.tag {
    background: #e0f2fe;
    color: #0277bd;
    padding: 0.15rem 0.5rem; /* 3px 8px */
    border-radius: 0.75rem; /* 12px */
    font-size: 0.65rem; /* 10px */
    font-weight: 600;
}

/* Chat Panel */
.chat-panel {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%; /* MODIFICADO: Asegura que el panel ocupe toda la altura disponible */
    min-height: 0; /* Permite que el contenido interno se encoja si es necesario */
}

.chat-header {
    background: linear-gradient(135deg, var(--dark-green) 0%, var(--primary-green) 100%);
    color: white;
    padding: 1.25rem 1.5rem; /* 20px 24px */
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem; /* 12px */
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255,255,255,0.2);
}

.chat-info h3 {
    font-size: 1.25rem; /* 20px */
    margin-bottom: 0.2rem; /* 3px */
    font-weight: 700;
}

.chat-info p {
    font-size: 0.875rem; /* 14px */
    color: rgba(255, 255, 255, 0.9);
}

.chat-actions {
    display: flex;
    gap: 0.625rem; /* 10px */
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    padding: 0.6rem 1.2rem; /* 10px 18px */
    border: none;
    border-radius: 0.6rem; /* 10px */
    cursor: pointer;
    font-weight: 600; /* Bolder */
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem; /* 6px */
    font-size: 0.875rem; /* 14px */
    box-shadow: var(--shadow-sm);
}

.btn i {
    font-size: 1.125rem; /* 18px */
}

.btn-primary { background: var(--primary-green); color: white; }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); border: 1px solid var(--gray-300); }
.btn-danger { background: var(--red-error); color: white; }
.btn-warning { background: var(--orange-alert); color: white; }
.btn-info { background: var(--blue-info); color: white; }

.btn-small {
    padding: 0.3rem 0.6rem; /* 5px 10px */
    font-size: 0.75rem; /* 12px */
    border-radius: 0.5rem; /* 8px */
}
.btn-sm {
    padding: 0.35rem 0.7rem; /* 6px 11px */
    font-size: 0.8rem; /* 13px */
    border-radius: 0.5rem;
}
.btn-outline {
    background: transparent;
    color: var(--blue-info);
    border: 1px solid var(--blue-info);
    box-shadow: none;
}
.btn-outline:hover {
    background: var(--blue-info);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.messages-container {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1.5rem; /* 24px */
    background: var(--bg-chat);
    display: flex;
    flex-direction: column;
    gap: 1rem; /* 16px */
    border-top: 1px solid var(--gray-300);
    scroll-behavior: auto; 
    overscroll-behavior: contain; 
}

.message {
    display: flex;
    gap: 0.75rem; /* 12px */
    position: relative;
    align-items: flex-end;
    animation: none;
    transition: none;
}

.message.from-customer { flex-direction: row; }
.message.from-agent { flex-direction: row-reverse; }

.message-avatar {
    width: 2.5rem; /* 40px */
    height: 2.5rem; /* 40px */
    border-radius: 50%;
    background: var(--accent-purple); /* Different color for avatars */
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    flex-shrink: 0;
    font-size: 1rem;
    box-shadow: var(--shadow-sm);
}
.message.from-customer .message-avatar { background: var(--blue-info); }

.message-content {
    max-width: 75%; /* Slightly wider messages */
    background: white;
    padding: 0.8rem 1.2rem; /* More padding */
    border-radius: 1.25rem; /* 20px - more rounded */
    box-shadow: var(--shadow-sm);
    position: relative;
    word-wrap: break-word;
    font-size: 0.9375rem; /* 15px */
    line-height: 1.5;
}

.message.from-agent .message-content {
    background: #dcf8c6; /* WhatsApp sent message color */
    border-bottom-right-radius: 0.3rem; /* Tapered corner for agent messages */
}
.message.from-customer .message-content {
    border-bottom-left-radius: 0.3rem; /* Tapered corner for customer messages */
}


.message-text {
    margin-bottom: 0.3rem; /* 5px */
    line-height: 1.4;
    color: var(--gray-900);
}

.message-time {
    font-size: 0.6875rem; /* 11px */
    color: var(--gray-500);
    text-align: right;
    opacity: 0.9;
}

.message-sentiment {
    position: absolute;
    top: -0.4rem; /* -6px */
    right: -0.4rem; /* -6px */
    width: 1rem; /* 16px */
    height: 1rem; /* 16px */
    border-radius: 50%;
    font-size: 0.5rem; /* 8px */
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    z-index: 5;
}

.sentiment-positive { background: var(--green-success); }
.sentiment-negative { background: var(--red-error); }
.sentiment-neutral { background: var(--gray-500); }

.message-actions {
    position: absolute;
    top: 0.2rem;
    right: -2.5rem; /* -40px */
    display: none;
    gap: 0.2rem; /* 3px */
    opacity: 0;
    transform: translateX(10px);
    transition: all 0.2s ease-out;
}
.message.from-agent .message-actions {
    left: -2.5rem;
    right: auto;
    transform: translateX(-10px);
}


.message:hover .message-actions {
    display: flex;
    opacity: 1;
    transform: translateX(0);
}
.message.from-agent:hover .message-actions {
    transform: translateX(0);
}


.message-input {
    padding: 1.25rem 1.5rem; /* 20px 24px */
    background: white;
    border-top: 1px solid var(--gray-300);
    flex-shrink: 0;
}

.input-group {
    display: flex;
    gap: 0.75rem; /* 12px */
    align-items: flex-end;
}

.message-textarea {
    flex: 1;
    padding: 0.75rem 1rem; /* 12px 16px */
    border: 1px solid var(--gray-300);
    border-radius: 1.5rem; /* More rounded */
    resize: none;
    min-height: 2.8rem; /* 45px - taller input */
    max-height: 8rem; /* 128px */
    font-family: inherit;
    font-size: 0.9375rem; /* 15px */
    transition: all 0.3s ease-in-out;
    color: var(--gray-900);
}

.message-textarea:focus {
    border-color: var(--primary-green);
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.15);
}

.template-selector { position: relative; }

.template-dropdown {
    position: absolute;
    bottom: 110%; /* Above the button */
    left: 0;
    background: white;
    border: 1px solid var(--gray-300);
    border-radius: 0.75rem; /* 12px */
    box-shadow: var(--shadow-md);
    max-height: 15rem; /* 240px */
    overflow-y: auto;
    z-index: 100;
    display: none;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.template-dropdown.active {
    display: block !important; 
    opacity: 1;
    transform: translateY(0);
}

.template-item {
    padding: 0.75rem 1rem; /* 12px 16px */
    cursor: pointer;
    border-bottom: 1px solid var(--gray-100);
    transition: background 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.template-item:last-child { border-bottom: none; }
.template-item:hover { background: var(--gray-100); }
.template-item strong { color: var(--gray-900); font-size: 0.9rem; }
.template-item small { color: var(--gray-500); font-size: 0.75rem; }


/* Details Panel */
.details-content {
    padding: 1.5rem; /* 24px */
    height: 100%; /* Fill parent flex/grid item */
    overflow-y: auto;
}

.detail-section {
    margin-bottom: 1.8rem; /* 30px */
    padding-bottom: 1.5rem; /* 24px */
    border-bottom: 1px solid var(--gray-300);
}

.detail-section:last-child { border-bottom: none; }

.detail-title {
    font-weight: 700;
    margin-bottom: 1rem; /* 16px */
    color: var(--gray-900);
    display: flex;
    align-items: center;
    gap: 0.6rem; /* 10px */
    font-size: 1.1rem;
}
.detail-title i {
    font-size: 1.5rem; /* Larger icon */
    color: var(--accent-purple);
}

.form-group { margin-bottom: 1rem; /* 16px */ }

.form-label {
    display: block;
    margin-bottom: 0.4rem; /* 6px */
    font-weight: 600;
    color: var(--gray-700);
    font-size: 0.9rem;
}
.form-text {
    font-size: 0.8rem; /* 13px */
    color: var(--gray-500);
    margin-top: 0.3rem; /* 5px */
    display: block;
    line-height: 1.4;
}

.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem; /* 6px */
    margin-top: 0.75rem; /* 12px */
}

.tag-removable {
    background: #e0f2fe;
    color: #0277bd;
    padding: 0.3rem 0.6rem; /* 5px 10px */
    border-radius: 1rem; /* 16px */
    font-size: 0.8rem; /* 13px */
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.2rem; /* 4px */
}

.tag-remove {
    background: none;
    border: none;
    color: #0277bd;
    cursor: pointer;
    font-size: 1rem; /* 16px */
    line-height: 1;
    padding: 0;
    margin: 0;
    transition: color 0.2s ease;
}
.tag-remove:hover { color: var(--red-error); }

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6); /* Darker overlay */
    backdrop-filter: blur(8px); /* Less blur for faster appearance */
    z-index: 1000;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--bg-card);
    border-radius: 1.5rem; /* Larger border-radius */
    padding: 2rem 2.5rem; /* More padding */
    max-width: 55rem; /* 880px - slightly wider */
    width: 95%; /* Responsive width */
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg); /* Stronger shadow */
    transform: translateY(20px) scale(0.9); /* Starts slightly off-screen and smaller */
    opacity: 0;
    animation: modalAppear 0.4s forwards cubic-bezier(0.2, 0.8, 0.2, 1); /* Bouncier animation */
}

.modal.active .modal-content {
    transform: translateY(0) scale(1);
    opacity: 1;
}

@keyframes modalAppear {
    from { transform: translateY(20px) scale(0.9); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem; /* 24px */
    padding-bottom: 1rem; /* 16px */
    border-bottom: 1px solid var(--gray-300);
}

.modal-header h3 {
    font-size: 1.5rem; /* 24px */
    color: var(--gray-900);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.modal-header h3 .bx {
    font-size: 1.8rem;
    color: var(--primary-green);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.8rem; /* Larger close icon */
    cursor: pointer;
    color: var(--gray-500);
    transition: color 0.2s ease, transform 0.2s ease;
}

.modal-close:hover {
    color: var(--red-error);
    transform: rotate(90deg); /* Spin on hover */
}

/* Login Page */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--light-purple) 0%, var(--accent-purple) 100%); /* Fondo degradado vibrante */
    padding: 1.5rem; /* Padding para evitar que el contenido toque los bordes en móvil */
}

.login-form {
    background: var(--bg-card); /* Usa la variable de fondo de tarjeta para consistencia */
    backdrop-filter: blur(12px); /* Efecto de desenfoque sutil */
    border-radius: 1.5rem; /* Borde redondeado consistente con el resto de la app */
    padding: 3rem; /* Espaciado interno generoso */
    box-shadow: var(--shadow-lg); /* Sombra fuerte para un efecto flotante */
    width: 100%;
    max-width: 28rem; /* Ancho máximo del formulario */
    text-align: center;
    border: 1px solid var(--gray-300); /* Borde sutil */
    animation: fadeIn 0.8s ease-out; /* Animación de aparición suave */
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-header {
    text-align: center;
    margin-bottom: 2.5rem; /* Espacio debajo del encabezado */
}

.login-header h1 {
    color: var(--primary-green); /* Color principal de WhatsApp */
    font-size: 2.25rem; /* Título grande */
    font-weight: 800; /* Extra bold */
    margin-bottom: 0.75rem;
    display: flex; /* Para alinear el icono y el texto */
    align-items: center;
    justify-content: center; /* Centrar el título y el icono */
    gap: 0.75rem; /* Espacio entre el icono y el texto */
}
.login-header h1 .bx {
    font-size: 2.8rem; /* Icono más grande */
}
.login-header p {
    color: var(--gray-700); /* Texto secundario */
    font-size: 1rem;
    max-width: 20rem; /* Limita el ancho del subtítulo */
    margin: 0 auto; /* Centra el subtítulo */
}

/* Reutilizando estilos de formulario existentes para consistencia */
.form-group {
    margin-bottom: 1.5rem; /* Más espacio entre campos de formulario */
}

.form-label {
    display: block;
    margin-bottom: 0.6rem; /* Más espacio entre label e input */
    font-weight: 600;
    color: var(--gray-700);
    font-size: 0.95rem; /* Texto de label ligeramente más grande */
    text-align: left; /* Alinea los labels a la izquierda */
}

.form-input {
    width: 100%;
    padding: 0.875rem 1.25rem; /* Más padding en los inputs */
    border: 1px solid var(--gray-300);
    border-radius: 0.75rem; /* Bordes más redondeados */
    background-color: white;
    font-size: 1rem; /* Tamaño de fuente estándar */
    color: var(--gray-900);
    transition: border-color 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
}

.form-input::placeholder {
    color: var(--gray-500);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-green);
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.15); /* Efecto de foco sutil pero claro */
}

.btn-primary {
    padding: 0.8rem 1.5rem; /* Más padding para el botón */
    font-size: 1rem; /* Tamaño de fuente estándar */
    border-radius: 0.75rem; /* Bordes más redondeados */
    box-shadow: var(--shadow-md); /* Sombra más pronunciada */
    display: inline-flex; /* Para alinear el icono y el texto */
    align-items: center;
    justify-content: center;
    gap: 0.75rem; /* Espacio entre icono y texto */
    text-transform: uppercase; /* Texto en mayúsculas */
    letter-spacing: 0.05em; /* Espaciado entre letras */
}

.btn-primary:hover {
    transform: translateY(-3px); /* Levantamiento más notable al pasar el mouse */
    box-shadow: var(--shadow-lg); /* Sombra más grande al pasar el mouse */
}

.error {
    color: var(--red-error);
    margin-top: 1.5rem; /* Más espacio para el mensaje de error */
    font-size: 0.9rem; /* Tamaño de fuente para errores */
    font-weight: 600;
}

.hidden {
    display: none !important;
}

/* Media Queries para responsividad */
@media (max-width: 480px) { /* Pantallas muy pequeñas */
    .login-form {
        padding: 2rem 1.5rem; /* Reducir padding en pantallas pequeñas */
        border-radius: 1rem;
    }
    .login-header h1 {
        font-size: 1.8rem;
    }
    .login-header h1 .bx {
        font-size: 2.2rem;
    }
    .login-header p {
        font-size: 0.9rem;
    }
    .form-label {
        font-size: 0.9rem;
    }
    .form-input {
        font-size: 0.95rem;
        padding: 0.75rem 1rem;
    }
    .btn-primary {
        font-size: 0.95rem;
        padding: 0.7rem 1.25rem;
        gap: 0.5rem;
    }
    .error {
        font-size: 0.85rem;
    }
}

.qr-container {
    text-align: center;
    padding: 1.5rem; /* 24px */
    background: var(--gray-100); /* Light background for QR */
    border-radius: 1rem; /* 16px */
    margin: 1.5rem 0; /* 24px */
    border: 1px dashed var(--gray-300); /* Dashed border for visual interest */
}
#qrCode canvas { /* Target the canvas element within qrCode div */
    border-radius: 0.5rem; /* Slightly rounded QR code */
    box-shadow: var(--shadow-sm);
}

/* Dashboard Stats */
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); /* 208px - slightly wider */
    gap: 1.25rem; /* 20px */
    margin-bottom: 1.5rem; /* 24px */
}

.stat-card {
    background: var(--bg-card);
    border-radius: 1rem; /* 16px */
    padding: 1.5rem; /* 24px */
    text-align: center;
    box-shadow: var(--shadow-sm);
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), box-shadow 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--gray-300);
}

.stat-card:hover {
    transform: translateY(-5px); /* More pronounced lift */
    box-shadow: var(--shadow-md);
}

.stat-card i {
    font-size: 3rem; /* Larger icons */
    color: var(--primary-green);
    margin-bottom: 0.75rem; /* 12px */
}

.stat-number {
    font-size: 2.5rem; /* Larger numbers */
    font-weight: 800; /* Extra bold */
    color: var(--gray-900); /* Darker number */
    margin-bottom: 0.3rem; /* 5px */
    letter-spacing: -0.02em; /* Tighter spacing for numbers */
}

.stat-label {
    color: var(--gray-500);
    font-size: 0.9375rem; /* 15px */
    font-weight: 500;
}

/* General Card */
.content-grid {
    display: grid;
    grid-template-columns: 1fr; /* Default to single column */
    gap: 1.5rem; /* 24px */
    flex-grow: 1; /* Allow content grid to grow if in a tab */
}

@media (min-width: 768px) {
    .content-grid {
        grid-template-columns: repeat(auto-fit, minmax(25rem, 1fr)); /* Larger min-width for cards */
    }
}
@media (min-width: 1024px) {
    .content-grid {
        grid-template-columns: repeat(auto-fit, minmax(28rem, 1fr)); /* Even larger for desktop */
    }
}


.card {
    background: var(--bg-card);
    border-radius: 1.5rem; /* Consistent large border-radius */
    padding: 1.75rem; /* 28px */
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    border: 1px solid var(--gray-300); /* Subtle border */
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem; /* 24px */
    padding-bottom: 1rem; /* 16px */
    border-bottom: 1px solid var(--gray-300);
    flex-wrap: wrap;
    gap: 0.75rem;
}

.card-title {
    font-size: 1.35rem; /* 22px */
    font-weight: 700;
    color: var(--gray-900);
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.card-title i {
    font-size: 1.75rem; /* Larger icons */
    color: var(--primary-green);
}

.table {
    width: 100%;
    border-collapse: separate; /* Use separate for rounded corners */
    border-spacing: 0;
    margin-top: 1rem; /* 16px */
    font-size: 0.9rem; /* 14px */
    border-radius: 0.75rem; /* Rounded table corners */
    overflow: hidden; /* Hide overflow for rounded corners */
}

.table th, .table td {
    padding: 0.9rem 1.2rem; /* More padding */
    text-align: left;
    border-bottom: 1px solid var(--gray-200); /* Lighter border */
}

.table th {
    font-weight: 600;
    color: var(--gray-700);
    background: var(--gray-100); /* Light header background */
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
}

.table tr:hover {
    background: var(--gray-100);
    transition: background 0.2s ease;
}

.table tbody tr:last-child td {
    border-bottom: none; /* No border on last row */
}

.comment-item {
    background: var(--gray-100);
    border-radius: 0.75rem; /* 12px */
    padding: 0.9rem 1.2rem; /* 15px 20px */
    margin-bottom: 0.75rem; /* 12px */
    border-left: 0.3rem solid var(--primary-green); /* Thicker border */
    box-shadow: var(--shadow-sm);
}

.comment-author {
    font-weight: 700;
    font-size: 0.85rem; /* 14px */
    color: var(--primary-green);
    margin-bottom: 0.25rem; /* 4px */
}

.comment-text {
    font-size: 0.9rem; /* 14px */
    line-height: 1.5;
    color: var(--gray-700);
}

.comment-time {
    font-size: 0.75rem; /* 12px */
    color: var(--gray-500);
    margin-top: 0.3rem; /* 5px */
    display: block;
}

/* Workflow Visual Editor */
.workflow-canvas {
    width: 100%;
    height: 40rem; /* 640px */
    background: var(--gray-100);
    border-radius: 1rem; /* 16px */
    position: relative;
    overflow: hidden;
    border: 1px solid var(--gray-300);
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1); /* Inner shadow for canvas */
    /* Add a subtle grid pattern */
    background-image: linear-gradient(to right, var(--gray-200) 1px, transparent 1px),
                      linear-gradient(to bottom, var(--gray-200) 1px, transparent 1px);
    background-size: 20px 20px;
}

.workflow-toolbar {
    background: white;
    padding: 1rem 1.5rem; /* 16px 24px */
    border-bottom: 1px solid var(--gray-300);
    display: flex;
    gap: 1rem; /* 16px */
    align-items: center;
    flex-wrap: wrap;
    border-radius: 1rem 1rem 0 0; /* Rounded top for toolbar */
    margin-bottom: 1.5rem; /* Spacing below toolbar */
    box-shadow: var(--shadow-sm);
}

.node-palette {
    display: flex;
    gap: 0.75rem; /* 12px */
    flex-wrap: wrap;
}

.palette-node {
    padding: 0.6rem 1rem; /* 10px 16px */
    background: var(--gray-100);
    border: 1px solid var(--gray-300);
    border-radius: 0.6rem; /* 10px */
    cursor: grab;
    font-size: 0.85rem; /* 14px */
    font-weight: 600;
    transition: all 0.3s ease-in-out;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    box-shadow: var(--shadow-sm);
}
.palette-node i {
    font-size: 1.15rem;
}

.palette-node:hover {
    background: var(--gray-200);
    border-color: var(--primary-green);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.palette-node.trigger { border-left: 4px solid #10b981; }
.palette-node.action { border-left: 4px solid var(--blue-info); }
.palette-node.condition { border-left: 4px solid var(--yellow-warning); }
.palette-node.delay { border-left: 4px solid #8b5cf6; }

.workflow-node {
    position: absolute;
    background: white;
    border: 1px solid var(--gray-300);
    border-radius: 0.75rem; /* 12px */
    padding: 0.75rem; /* 12px */
    min-width: 8rem; /* 128px */
    cursor: grab;
    box-shadow: var(--shadow-md);
    z-index: 10;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.workflow-node.selected {
    border-color: var(--primary-green);
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.25), var(--shadow-md); /* Stronger ring */
}

.workflow-node.trigger { border-left: 4px solid #10b981; }
.workflow-node.action { border-left: 4px solid var(--blue-info); }
.workflow-node.condition { border-left: 4px solid var(--yellow-warning); }
.workflow-node.delay { border-left: 4px solid #8b5cf6; }

.node-header {
    font-weight: 700;
    font-size: 0.85rem; /* 14px */
    margin-bottom: 0.25rem; /* 4px */
    color: var(--gray-900);
}

.node-content {
    font-size: 0.75rem; /* 12px */
    color: var(--gray-700);
}

.node-connector {
    position: absolute;
    width: 0.75rem; /* 12px */
    height: 0.75rem; /* 12px */
    background: var(--primary-green);
    border-radius: 50%;
    border: 2px solid white; /* 2px */
    cursor: crosshair;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}
.node-connector:hover {
    transform: scale(1.3);
    box-shadow: 0 0 0 4px rgba(37, 211, 102, 0.3);
}

.connector-input { top: 50%; left: -0.5rem; /* -8px */ transform: translateY(-50%); }
.connector-output { top: 50%; right: -0.5rem; /* -8px */ transform: translateY(-50%); }

.workflow-connection { position: absolute; z-index: 5; }

.customer-editor {
    background: var(--gray-100);
    border-radius: 0.75rem; /* 12px */
    padding: 1rem; /* 16px */
    margin-bottom: 1rem; /* 16px */
    border: 1px solid var(--gray-300);
}

.customer-form {
    display: grid;
    grid-template-columns: 1fr; /* Default to single column */
    gap: 1rem; /* 16px */
}
@media (min-width: 480px) {
    .customer-form {
        grid-template-columns: 1fr 1fr;
    }
}

.segment-selector {
    display: flex;
    gap: 0.6rem; /* 10px */
    margin-top: 0.75rem; /* 12px */
    flex-wrap: wrap;
}

.segment-option {
    padding: 0.6rem 1rem; /* 10px 16px */
    border: 1px solid var(--gray-300);
    border-radius: 1.5rem; /* 24px */
    cursor: pointer;
    font-size: 0.85rem; /* 14px */
    font-weight: 500;
    transition: all 0.3s ease-in-out;
    white-space: nowrap;
}

.segment-option.active {
    background: var(--primary-green);
    color: white;
    border-color: var(--primary-green);
    box-shadow: var(--shadow-sm);
}

.segment-option:hover:not(.active) {
    background: rgba(37, 211, 102, 0.1);
    color: var(--dark-green);
}

.priority-selector {
    display: flex;
    gap: 0.5rem; /* 8px */
    margin-top: 0.75rem; /* 12px */
    flex-wrap: wrap;
}

.priority-option {
    padding: 0.4rem 0.8rem; /* 7px 13px */
    border: 1px solid var(--gray-300);
    border-radius: 1.25rem; /* 20px */
    cursor: pointer;
    font-size: 0.75rem; /* 12px */
    font-weight: 600;
    text-transform: uppercase;
    transition: all 0.3s ease-in-out;
    white-space: nowrap;
}

.priority-option.urgent { border-color: var(--red-error); color: var(--red-error); }
.priority-option.high { border-color: var(--orange-alert); color: var(--orange-alert); }
.priority-option.medium { border-color: var(--green-success); color: var(--green-success); }
.priority-option.low { border-color: var(--gray-500); color: var(--gray-500); }

.priority-option.active.urgent { background: var(--red-error); color: white; box-shadow: var(--shadow-sm); }
.priority-option.active.high { background: var(--orange-alert); color: white; box-shadow: var(--shadow-sm); }
.priority-option.active.medium { background: var(--green-success); color: white; box-shadow: var(--shadow-sm); }
.priority-option.active.low { background: var(--gray-500); color: white; box-shadow: var(--shadow-sm); }

.hidden { display: none !important; }

.workflow-item, .template-item-list, .user-item, .knowledge-item { /* Added knowledge-item */
    background: white;
    border-radius: 0.75rem; /* 12px */
    padding: 1rem; /* 16px */
    margin-bottom: 0.75rem; /* 12px */
    border: 1px solid var(--gray-300);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: var(--shadow-sm);
}

.workflow-item:hover, .template-item-list:hover, .user-item:hover, .knowledge-item:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.workflow-header, .template-header, .user-header, .knowledge-header { /* Added knowledge-header */
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem; /* 12px */
}

.workflow-title, .template-title, .user-title, .knowledge-title { /* Added knowledge-title */
    font-weight: 700;
    color: var(--gray-900);
    font-size: 1rem;
}

.workflow-actions, .template-actions, .user-actions, .knowledge-actions { /* Added knowledge-actions */
    display: flex;
    gap: 0.3rem; /* 5px */
}

.workflow-metrics {
    display: flex;
    gap: 1rem; /* 16px */
    margin-top: 0.75rem; /* 12px */
    font-size: 0.8rem; /* 13px */
    color: var(--gray-500);
}

.metric-item {
    display: flex;
    align-items: center;
    gap: 0.3rem; /* 5px */
}

.chart-container {
    position: relative;
    height: 20rem; /* 320px */
    margin-top: 1.5rem; /* 24px */
    padding: 1.5rem; /* 24px */
    background: var(--bg-card);
    border-radius: 1rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-300);
}

/* Custom Scrollbar */
.scrollbar-thin {
    scrollbar-width: thin;
    scrollbar-color: var(--gray-400) var(--gray-100);
}

.scrollbar-thin::-webkit-scrollbar { width: 0.5rem; /* 8px */ }
.scrollbar-thin::-webkit-scrollbar-track { background: var(--gray-100); border-radius: 0.5rem; }
.scrollbar-thin::-webkit-scrollbar-thumb {
    background: var(--gray-400);
    border-radius: 0.25rem; /* 4px */
    border: 2px solid var(--gray-100);
}
.scrollbar-thin::-webkit-scrollbar-thumb:hover { background: var(--gray-500); }


/* Alerts and Errors */
.error {
    color: var(--red-error);
    margin-top: 1rem; /* 16px */
    text-align: center;
    font-weight: 600;
}

.alert {
    padding: 0.9rem 1.2rem; /* 15px 20px */
    border-radius: 0.75rem; /* 12px */
    margin-bottom: 1rem; /* 16px */
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-left: 5px solid; /* Thicker border-left */
    box-shadow: var(--shadow-sm);
}
.alert i {
    font-size: 1.25rem;
}

.alert-success { background: #dcfce7; color: #15803d; border-color: var(--green-success); }
.alert-error { background: #fee2e2; color: #b91c1c; border-color: var(--red-error); }
.alert-warning { background: #fffbeb; color: #b45309; border-color: var(--yellow-warning); }

.logs-container {
    max-height: 28rem; /* 450px */
    overflow-y: auto;
    background: var(--gray-100);
    border-radius: 0.75rem; /* 12px */
    padding: 1rem; /* 16px */
    font-family: 'Fira Code', 'Courier New', monospace; /* Monospace font for logs */
    font-size: 0.8rem; /* 13px */
    color: #4b5563;
    border: 1px solid var(--gray-300);
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
}

.log-item {
    padding: 0.75rem; /* 12px */
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    line-height: 1.4;
}

.log-item:last-child { border-bottom: none; }

.log-timestamp {
    color: var(--gray-500);
    margin-right: 0.75rem; /* 12px */
    font-weight: 600;
    flex-shrink: 0;
    min-width: 8rem; /* Ensure timestamp takes enough space */
}

.log-action {
    font-weight: 600;
    color: var(--gray-700);
    margin-right: 0.625rem; /* 10px */
}
.log-item .bx {
    font-size: 1.1rem;
    margin-right: 0.4rem;
    color: var(--blue-info); /* Consistent log icon color */
}
.log-action.success { color: var(--green-success); }
.log-action.error { color: var(--red-error); }
.log-action.warning { color: var(--yellow-warning); }
.log-action.info { color: var(--blue-info); }


/* Search Results Dropdown */
.search-results {
    position: absolute;
    top: calc(100% + 5px); /* Slightly below input */
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--gray-300);
    border-radius: 0.75rem; /* 12px */
    max-height: 20rem; /* 320px */
    overflow-y: auto;
    z-index: 100;
    display: none;
    box-shadow: var(--shadow-md);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.search-results.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.search-result-item {
    padding: 0.75rem 1rem; /* 12px 16px */
    border-bottom: 1px solid var(--gray-200);
    cursor: pointer;
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--gray-700);
    font-size: 0.9rem;
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--gray-100); }

.search-result-type {
    font-size: 0.65rem; /* 10px */
    background: var(--primary-green);
    color: white;
    padding: 0.15rem 0.4rem; /* 3px 6px */
    border-radius: 0.6rem; /* 10px */
    margin-right: 0.4rem; /* 6px */
    font-weight: 600;
    text-transform: uppercase;
}

/* Notification Dropdown */
.notification-dropdown {
    position: absolute;
    top: calc(100% + 5px); /* Below icon */
    right: 0;
    background: white;
    border: 1px solid var(--gray-300);
    border-radius: 1rem; /* 16px */
    width: 22rem; /* 352px */
    max-height: 28rem; /* 450px */
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    z-index: 200;
    display: none;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.notification-dropdown.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}


.notification-header {
    padding: 1rem 1.25rem; /* 16px 20px */
    border-bottom: 1px solid var(--gray-300);
    font-weight: 700;
    color: var(--gray-900);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.1rem;
}
.notification-header i {
    font-size: 1.4rem;
    color: var(--primary-green);
}


.notification-item {
    padding: 1rem 1.25rem; /* 16px 20px */
    border-bottom: 1px solid var(--gray-200);
    cursor: pointer;
    transition: background 0.2s ease;
}

.notification-item:last-child { border-bottom: none; }
.notification-item:hover { background: var(--gray-100); }
.notification-item.unread {
    background: #e9ffee; /* Lighter background for unread */
    border-left: 4px solid var(--primary-green); /* Green border for unread */
    padding-left: 1.1rem; /* Adjust padding for border */
}

.notification-title {
    font-weight: 600;
    font-size: 0.9rem; /* 14px */
    margin-bottom: 0.25rem; /* 4px */
    color: var(--gray-900);
}

.notification-message {
    font-size: 0.8rem; /* 13px */
    color: var(--gray-700);
    margin-bottom: 0.25rem; /* 4px */
}

.notification-time {
    font-size: 0.7rem; /* 11px */
    color: var(--gray-500);
}

/* Tag Selector */
.tag-selector { position: relative; }

.tag-input {
    width: 100%;
    padding: 0.75rem 1rem; /* 12px 16px */
    border: 1px solid var(--gray-300);
    border-radius: 0.75rem; /* 12px */
    font-size: 0.9rem; /* 14px */
    transition: all 0.3s ease-in-out;
    color: var(--gray-900);
}
.tag-input:focus {
    border-color: var(--primary-green);
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.15);
    outline: none;
}

.tag-suggestions {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--gray-300);
    border-radius: 0.75rem; /* 12px */
    max-height: 10rem; /* 160px */
    overflow-y: auto;
    z-index: 50;
    display: none;
    box-shadow: var(--shadow-md);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.tag-suggestions.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.tag-suggestion {
    padding: 0.75rem 1rem; /* 12px 16px */
    cursor: pointer;
    font-size: 0.85rem; /* 14px */
    border-bottom: 1px solid var(--gray-200);
    color: var(--gray-700);
}

.tag-suggestion:last-child { border-bottom: none; }
.tag-suggestion:hover { background: var(--gray-100); }

/* Color Picker */
.color-picker {
    display: flex;
    gap: 0.5rem; /* 8px */
    margin-top: 0.75rem; /* 12px */
    flex-wrap: wrap;
}

.color-option {
    width: 1.5rem; /* 24px */
    height: 1.5rem; /* 24px */
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent; /* 2px */
    transition: all 0.3s ease-in-out;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.1);
}

.color-option.selected {
    border-color: white; /* White border for selected */
    transform: scale(1.25); /* More prominent scale */
    box-shadow: 0 0 0 4px var(--primary-green); /* Green ring for selected */
}

/* Message Status */
.message-status {
    font-size: 0.7rem; /* 11px */
    color: var(--gray-500);
    margin-top: 0.2rem; /* 3px */
    text-align: right;
    opacity: 0.8;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.2rem;
}
.message-status i {
    font-size: 0.8rem;
}

.whatsapp-status-sent { color: var(--gray-500); } /* Gray for sent */
.whatsapp-status-delivered { color: var(--primary-green); } /* Green for delivered */
.whatsapp-status-read { color: var(--blue-info); } /* Blue for read */
.whatsapp-status-failed { color: var(--red-error); }

/* Form Layouts */
.form-row {
    display: flex;
    gap: 1rem; /* 16px */
    margin-bottom: 1rem; /* 16px */
    flex-wrap: wrap;
}

.form-row .form-group { flex: 1; min-width: 12rem; /* 192px for responsiveness */ }

.card-actions {
    display: flex;
    gap: 0.75rem; /* 12px */
    flex-wrap: wrap;
    justify-content: flex-end;
}
.card-actions .btn { margin-left: 0.5rem; } /* Space between buttons */

/* Feature Toggles (Settings) */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr)); /* 304px */
    gap: 1rem; /* 16px */
}

.feature-toggle {
    display: flex;
    align-items: center;
    padding: 0.9rem 1.2rem; /* 15px 20px */
    background: var(--gray-100);
    border-radius: 0.75rem; /* 12px */
    cursor: pointer;
    border: 1px solid var(--gray-300);
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.feature-toggle:hover {
    background: var(--gray-200);
    border-color: var(--blue-info);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.feature-toggle input[type="checkbox"] { display: none; }

.toggle-slider {
    width: 3.5rem; /* 56px */
    height: 1.8rem; /* 29px */
    background-color: var(--gray-300);
    border-radius: 0.9rem; /* 14.5px */
    position: relative;
    margin-right: 1rem; /* 16px */
    transition: 0.3s;
    flex-shrink: 0;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 1.4rem; /* 22px */
    width: 1.4rem; /* 22px */
    left: 0.2rem; /* 3px */
    top: 0.2rem; /* 3px */
    background-color: white;
    border-radius: 50%;
    transition: 0.3s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

.feature-toggle input:checked + .toggle-slider { background-color: var(--blue-info); }
.feature-toggle input:checked + .toggle-slider::before { transform: translateX(1.7rem); /* 27px */ }

.feature-info { display: flex; flex-direction: column; }
.feature-info strong { font-weight: 700; color: var(--gray-900); margin-bottom: 0.2rem; /* 3px */ }
.feature-info small { color: var(--gray-700); font-size: 0.8rem; /* 13px */ line-height: 1.3; }

/* System Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr)); /* 304px */
    gap: 1.25rem; /* 20px */
}

.stat-category {
    background: var(--gray-100);
    border-radius: 0.75rem; /* 12px */
    padding: 1rem; /* 16px */
    border-left: 4px solid var(--blue-info); /* Thicker left border */
    box-shadow: var(--shadow-sm);
}

.stat-category h4 {
    margin: 0 0 1rem 0; /* 16px */
    color: var(--gray-800);
    font-size: 1.1rem; /* 18px */
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.stat-category h4 i {
    font-size: 1.3rem;
    color: var(--blue-info);
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0; /* 6px 0 */
    border-bottom: 1px solid var(--gray-200);
}

.stat-item:last-child { border-bottom: none; }
.stat-label { font-weight: 500; color: var(--gray-700); font-size: 0.875rem; /* 14px */ }
.stat-value { font-weight: 700; color: var(--gray-900); font-size: 0.9rem; /* 14.5px */ }

.status-indicator.stat {
    width: 0.75rem; /* 12px */
    height: 0.75rem; /* 12px */
    border-radius: 50%;
    margin-left: 0.4rem; /* 6px */
    display: inline-block;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.1);
}

.status-indicator.active { background-color: var(--green-success); }
.status-indicator.inactive { background-color: var(--red-error); }

/* System Action Buttons */
.action-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); /* 208px */
    gap: 0.75rem; /* 12px */
}
.action-buttons .btn { width: 100%; justify-content: center; }


/* Responsive Adjustments */
@media (max-width: 767px) { 

    .messages-container {
        height: calc(100vh - 12rem); 
        min-height: 25rem; 
    }

    .main-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto 1fr; /* Filters (sidebar), then chat, then details (if shown) */
        min-height: auto; /* Let content height expand */
        height: auto;
    }
    .sidebar {
        height: auto;
        max-height: 25rem; /* Limit sidebar height on small screens */
        margin-bottom: 1.5rem;
    }
    .chat-panel {
        /* MODIFICADO: Altura calculada para el chat-panel en pantallas pequeñas */
        height: calc(100vh - (var(--header-height-base) + var(--nav-height-base) + (var(--container-margin-vertical) * 2) + 25rem)); /* Suma de todas las alturas fijas/máximas */
        min-height: 25rem; /* Asegura un tamaño mínimo si el cálculo es muy pequeño */
        flex-shrink: 1; /* Permite que se encoja un poco si el espacio es limitado */
    }
    .details-panel {
        display: none; /* Hidden by default on small screens */
    }
    .header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    .header h1 {
        font-size: 1.8rem;
        gap: 0.5rem;
    }
    .header h1 .bx {
        font-size: 2.2rem;
    }
    .header-search {
        max-width: 100%;
        margin: 0;
    }
    .user-info {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.8rem;
    }
    .nav-tabs { flex-wrap: wrap; justify-content: center;}
    .nav-tab { min-width: 6.5rem; font-size: 0.8rem; padding: 0.6rem 0.9rem; }
    .form-row { flex-direction: column; gap: 0; }
    .features-grid, .stats-grid, .action-buttons { grid-template-columns: 1fr; }
    .card-actions { flex-direction: column; width: 100%; }
    .card-actions .btn { margin-left: 0; } /* Reset margin for stack */
    .modal-content {
        padding: 1.5rem 1.75rem;
        border-radius: 1rem;
    }
    .modal-header h3 {
        font-size: 1.3rem;
    }
    .modal-header h3 .bx {
        font-size: 1.6rem;
    }
    .stat-card { padding: 1.25rem; }
    .stat-card i { font-size: 2.5rem; }
    .stat-number { font-size: 2rem; }
}

@media (min-width: 768px) and (max-width: 1439px) { /* Medium screens (tablets, smaller laptops) */
    .main-layout {
        grid-template-columns: 20rem 1fr; /* Sidebar fixed width, chat fills remaining */
        /* MODIFICADO: Altura total para pantallas medianas */
        height: calc(100vh - (var(--header-height-base) + var(--nav-height-base) + (var(--container-margin-vertical) * 2)));
        min-height: auto;
    }
    .details-panel {
        display: none; /* Hide details panel on medium screens */
    }
    .sidebar {
        height: 100%; 
        max-height: none; 
    }
    .chat-panel {
        height: calc(100vh - 8rem); 
        min-height: 30rem;
    }

}


@media (min-width: 1440px) { /* Large screens (desktop) */
    .main-layout {
        grid-template-columns: 22rem 1fr 28rem; /* Three columns: Sidebar, Chat, Details */
        /* MODIFICADO: Altura total para pantallas grandes */
        height: calc(100vh - (var(--header-height-base) + var(--nav-height-base) + (var(--container-margin-vertical) * 2)));
    }
    .details-panel {
        display: flex; /* Show details panel on large screens */
    }
    .sidebar, .chat-panel, .details-panel {
        height: 100%; /* Fill remaining vertical space */
        min-height: 0;
    }
}

/* Estilos para el sidebar y detalles que se convertirán en sidebars deslizantes en móvil */
.sidebar, .details-panel {
    /* Mantén tus estilos base de flexbox/grid aquí */
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border-radius: 1.5rem;
    overflow: hidden;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    border: 1px solid var(--gray-300);
    height: 100%;
    min-height: 0; /* Important for flex/grid */
    
    /* Nuevas propiedades para el comportamiento de sidebar */
    position: fixed; /* Posiciona respecto a la ventana del navegador */
    top: 0;
    width: 85%; /* Ancho del sidebar en móvil (ej. 85% de la pantalla) */
    max-width: 20rem; /* Limita el ancho del sidebar para pantallas más grandes, ajusta si es necesario */
    height: 100vh; /* Ocupa toda la altura de la ventana */
    z-index: 1000; /* Asegura que esté por encima del contenido principal */
    transition: transform 0.3s ease-in-out; /* Transición suave para el deslizamiento */
    pointer-events: none; /* Deshabilita clics cuando está oculto para que no bloquee el contenido */
}

.sidebar {
    left: 0;
    transform: translateX(-100%); /* Oculta el sidebar izquierdo fuera de la pantalla */
}

.details-panel {
    right: 0;
    transform: translateX(100%); /* Oculta el sidebar derecho fuera de la pantalla */
}

/* Clases para mostrar los sidebars */
.sidebar.active {
    transform: translateX(0); /* Desliza el sidebar izquierdo hacia la vista */
    pointer-events: auto; /* Habilita clics cuando está activo */
}

.details-panel.active {
    transform: translateX(0); /* Desliza el sidebar derecho hacia la vista */
    pointer-events: auto; /* Habilita clics cuando está activo */
}

/* Estilos para el overlay cuando un sidebar está abierto (para oscurecer el fondo) */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5); /* Color oscuro semi-transparente */
    z-index: 999; /* Debajo de los sidebars, pero encima del contenido principal */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
}

.overlay.active {
    opacity: 1;
    visibility: visible;
}

@media (max-width: 767px) {
    .main-layout {
        /* En móvil, solo necesitamos que el main-layout contenga el chat-panel */
        grid-template-columns: 1fr; /* Una sola columna para el chat */
        grid-template-rows: 1fr; /* El chat-panel tomará el resto del espacio */
        height: calc(100vh - (var(--header-height-base) + var(--nav-height-base) + (var(--container-margin-vertical) * 2) + 0rem)); /* Ajusta la altura del main-layout */
        /* Eliminamos la dependencia de la altura del sidebar en este cálculo del main-layout,
           ya que el sidebar ahora es fixed y no ocupa espacio en el flujo normal */
        min-height: 0;
        overflow: hidden; /* Evita el scroll horizontal si los sidebars se salen temporalmente */
    }

    .sidebar, .details-panel {
        display: flex; /* Asegura que siempre sean flexbox en móvil para poder activarlos */
    }

    .chat-panel {
        height: 100%;
        min-height: 0; 
    }

    .filters {
        display: none;
    }
    .tickets-list {
    }

}

@media (min-width: 768px) {
    .main-layout {
        grid-template-columns: 20rem 1fr; 
        height: calc(100vh - (var(--header-height-base) + var(--nav-height-base) + (var(--container-margin-vertical) * 2)));
        min-height: 0;
    }

    .details-panel {
        display: none; 
    }

    .sidebar, .details-panel {
        position: static; 
        transform: translateX(0); 
        width: auto; 
        height: 100%; 
        z-index: auto; 
        pointer-events: auto; 
        max-width: none; 
    }
    
    .filters {
        display: grid; 
    }

    .overlay {
        display: none; 
    }
}

@media (min-width: 1440px) { 
    .main-layout {
        grid-template-columns: 22rem 1fr 28rem; 
    }
    .details-panel {
        display: flex; 
    }
}

#mobileFloatingButtons {
    position: fixed;
    bottom: 20px; 
    width: 100%;
    display: flex;
    justify-content: space-between; 
    padding: 0 20px; 
    z-index: 900; 
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

#mobileFloatingButtons.active {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}

.sidebar.active, .details-panel.active {
    transform: translateX(0);
    pointer-events: auto;
}

@media (max-width: 767px) {
    .mobile-only-floating {
        display: flex !important; /* Muestra como flex en móvil */
    }

    /* Oculta los filtros de la barra lateral en la vista de tickets */
    .filters {
        display: none;
    }
}

.floating-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem; 
    box-shadow: var(--shadow-md); /* Sombra para efecto flotante */
    cursor: pointer;
    border: none;
    flex-shrink: 0; /* Evita que los botones se encojan */
    transition: transform 0.2s ease;
}

.floating-btn:hover {
    transform: scale(1.1);
}

/* Colores específicos para los botones flotantes */
.floating-btn.left {
    background-color: var(--primary-green);
    color: white;
}

.floating-btn.right {
    background-color: var(--blue-info);
    color: white;
}

/* Asegura que los botones flotantes solo se muestren en móviles */
.mobile-only-floating {
    display: none !important; /* Oculto por defecto en desktop */
}

@media (max-width: 767px) {
    .mobile-only-floating {
        display: flex !important; /* Muestra como flex en móvil */
    }

    /* Oculta los tabs de navegación principales en móvil para evitar duplicidad y usar los flotantes */
    .nav-tabs {
        flex-wrap: wrap; /* Permitir que se envuelvan */
        justify-content: center; /* Centrar los tabs */
        padding: 0.5rem;
        gap: 0.25rem; /* Reducir el espacio entre tabs */
    }

    .nav-tab {
        min-width: auto; /* Quitar ancho mínimo fijo */
        flex: 0 1 auto; /* Permitir que se ajusten al contenido */
        padding: 0.5rem 0.75rem; /* Reducir padding */
        font-size: 0.75rem; /* Texto más pequeño */
        white-space: nowrap; /* Evitar salto de línea en el texto */
    }

    /* También podemos ocultar los filtros de la barra lateral en la vista de tickets
       en móvil, ya que el sidebar de tickets flotará y los contendrá */
    .filters {
        display: none;
    }
}

/* En pantallas más grandes (desktop), asegúrate de que los filtros y nav-tabs vuelvan a ser visibles.
   Ya tienes estas reglas, pero es bueno verificarlas. */
@media (min-width: 768px) {
    .nav-tabs {
        display: flex; /* Muestra los tabs de navegación en desktop */
    }
    .filters {
        display: grid; /* Muestra los filtros en desktop */
    }
}

@media (max-width: 480px) { /* Extra small screens */
    .container { padding: 1rem; margin: 1rem auto; }
    .header { padding: 1rem 1.25rem; border-radius: 1rem; }
    .header h1 { font-size: 1.6rem; }
    .header h1 .bx { font-size: 2rem; }
    .search-input { padding: 0.6rem 2.5rem 0.6rem 1rem; font-size: 0.875rem; }
    .search-button { width: 2rem; height: 2rem; font-size: 1rem; }
    .notifications-icon { width: 2.4rem; height: 2.4rem; font-size: 1.2rem; }
    .nav-tabs { padding: 0.4rem; border-radius: 0.75rem; }
    .nav-tab { min-width: auto; padding: 0.5rem 0.75rem; font-size: 0.7rem; }
    .main-layout { gap: 1rem; }
    .sidebar, .chat-panel, .details-panel { border-radius: 1rem; }
    .sidebar-header, .details-header, .chat-header { padding: 1rem 1.25rem; font-size: 1.1rem; }
    .sidebar-header i, .details-header i { font-size: 1.4rem; }
    .filters { padding: 1rem 1.25rem; }
    .ticket-item { padding: 0.8rem; border-radius: 0.8rem; }
    .customer-name { font-size: 0.95rem; }
    .customer-avatar { width: 2rem; height: 2rem; font-size: 0.8rem; }
    .messages-container { padding: 1rem; gap: 0.75rem; }
    .message-input { padding: 1rem; }
    .message-textarea { min-height: 2.5rem; font-size: 0.875rem; }
    .btn { padding: 0.5rem 1rem; font-size: 0.8rem; }
    .btn i { font-size: 1rem; }
    .detail-section { margin-bottom: 1rem; padding-bottom: 1rem; }
    .detail-title { font-size: 1rem; }
    .detail-title i { font-size: 1.25rem; }
    .card { padding: 1.25rem; border-radius: 1rem; }
    .card-header { margin-bottom: 1rem; padding-bottom: 0.75rem; }
    .card-title { font-size: 1.1rem; }
    .card-title i { font-size: 1.4rem; }
    .table th, .table td { padding: 0.75rem 1rem; font-size: 0.8rem; }
    .comment-item { padding: 0.75rem; border-radius: 0.6rem; }
    .logs-container { padding: 0.75rem; font-size: 0.7rem; }
    .log-item { padding: 0.5rem; }
    .log-timestamp { font-size: 0.7rem; min-width: 6rem; }
    .login-form { padding: 2rem; border-radius: 1rem; }
    .login-header h1 { font-size: 1.8rem; }
    .login-header h1 .bx { font-size: 2.2rem; }
    .qr-container { padding: 1rem; margin: 1rem 0; }
}

.notification-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--red-error);
    color: white;
    border-radius: 50%;
    min-width: 18px;
    height: 18px;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.notification-badge.hidden {
    display: none;
}

.notifications-icon {
    position: relative;
    background: none;
    border: none;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.notifications-icon:hover {
    background-color: var(--gray-100);
}

.notifications-icon i {
    font-size: 20px;
    color: var(--gray-700);
}

.media-message {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: rgba(0,0,0,0.05);
    border-radius: 8px;
    margin: 0.25rem 0;
}

.media-message span {
    font-weight: 500;
    color: var(--gray-700);
}

.media-caption,
.document-name,
.location-address,
.contact-name {
    font-size: 0.85rem;
    color: var(--gray-600);
    margin-top: 0.25rem;
}

.audio-duration {
    font-size: 0.75rem;
    color: var(--gray-500);
    background: rgba(0,0,0,0.1);
    padding: 0.125rem 0.375rem;
    border-radius: 12px;
}

.customer-name-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}

.customer-name-text {
    flex: 1;
}

.unread-badge {
    background: var(--red-error);
    color: white;
    border-radius: 50%;
    min-width: 18px;
    height: 18px;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    flex-shrink: 0;
}

.ticket-item.active .unread-badge {
    background: var(--gray-400);
}

/* Ajustar el customer-name para usar flex */
.customer-name {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

/* Imágenes */
.message-image {
    max-width: 250px;
    max-height: 200px;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s;
    object-fit: cover;
}

.message-image:hover {
    transform: scale(1.02);
}

/* Videos */
.message-video {
    max-width: 250px;
    max-height: 200px;
    border-radius: 8px;
}

/* Stickers */
.message-sticker {
    width: 120px;
    height: 120px;
    object-fit: contain;
}

/* Audio Player */
.audio-player {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 200px;
    padding: 0.5rem;
    background: rgba(0,0,0,0.05);
    border-radius: 8px;
}

.audio-play-btn {
    background: var(--primary-green);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s;
}

.audio-play-btn:hover {
    background: var(--primary-green-dark);
}

.audio-progress {
    flex: 1;
    height: 4px;
    background: rgba(0,0,0,0.2);
    border-radius: 2px;
    position: relative;
    cursor: pointer;
}

.audio-progress-bar {
    height: 100%;
    background: var(--primary-green);
    border-radius: 2px;
    width: 0%;
    transition: width 0.1s;
}

.audio-duration {
    font-size: 0.75rem;
    color: var(--gray-600);
    min-width: 35px;
}

/* Documentos */
.document-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.document-download {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--blue-info);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
}

.document-download:hover {
    text-decoration: underline;
}

/* Ubicación */
.location-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.location-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--blue-info);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
}

.location-link:hover {
    text-decoration: underline;
}

/* Contactos */
.contact-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.contact-phone {
    font-size: 0.8rem;
    color: var(--gray-600);
}

/* Modal de imagen */
.image-modal {
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.image-modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-modal img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    cursor: default;
}

.image-modal-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #ffffff;
    font-size: 35px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10001;
    background: rgba(0,0,0,0.5);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-modal-close:hover {
    background: rgba(0,0,0,0.8);
}

/* Estilos para mensajes multimedia */
.media-message {
    margin: 8px 0;
    padding: 12px;
    border-radius: 8px;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    max-width: 100%;
}

.message-image {
    max-width: 300px;
    max-height: 300px;
    border-radius: 8px;
    cursor: pointer;
    object-fit: cover;
    transition: transform 0.2s ease;
}

.message-image:hover {
    transform: scale(1.02);
}

.message-video {
    max-width: 300px;
    max-height: 200px;
    border-radius: 8px;
}

.message-sticker {
    max-width: 150px;
    max-height: 150px;
    border-radius: 8px;
}

.media-caption {
    margin-top: 8px;
    font-size: 0.9rem;
    color: #6c757d;
    font-style: italic;
}

.media-fallback {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #6c757d;
    font-style: italic;
}

/* Reproductor de audio */
.audio-player {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    background-color: #ffffff;
    border-radius: 8px;
    border: 1px solid #dee2e6;
    min-width: 250px;
}

.audio-play-btn, .audio-download-btn {
    background-color: var(--primary-green);
    color: white;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.audio-play-btn:hover, .audio-download-btn:hover {
    background-color: var(--primary-green-dark);
}

.audio-progress {
    flex: 1;
    height: 6px;
    background-color: #e9ecef;
    border-radius: 3px;
    cursor: pointer;
    position: relative;
}

.audio-progress-bar {
    height: 100%;
    background-color: var(--primary-green);
    border-radius: 3px;
    width: 0%;
    transition: width 0.1s ease;
}

.audio-duration {
    font-size: 0.85rem;
    color: #6c757d;
    font-family: monospace;
    min-width: 40px;
}

/* Documentos */
.document-message {
    max-width: 300px;
}

.document-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.document-details {
    flex: 1;
}

.document-name {
    font-weight: 600;
    color: #212529;
    margin-bottom: 4px;
    word-break: break-word;
}

.document-size {
    font-size: 0.8rem;
    color: #6c757d;
}

/* Ubicaciones */
.location-message {
    max-width: 280px;
}

.location-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.location-details {
    flex: 1;
}

.location-name {
    font-weight: 600;
    color: #212529;
    margin-bottom: 4px;
}

.location-coords {
    font-size: 0.8rem;
    color: #6c757d;
    margin-bottom: 8px;
    font-family: monospace;
}

.location-btn {
    background-color: var(--red-error);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: background-color 0.2s ease;
}

.location-btn:hover {
    background-color: #dc2626;
}

/* Contactos */
.contact-message {
    max-width: 250px;
}

.contact-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.contact-details {
    flex: 1;
}

.contact-name {
    font-weight: 600;
    color: #212529;
    margin-bottom: 4px;
}

.contact-phone {
    font-size: 0.9rem;
    color: #6c757d;
    margin-bottom: 8px;
    font-family: monospace;
}

.contact-btn {
    background-color: var(--blue-info);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: background-color 0.2s ease;
}

.contact-btn:hover {
    background-color: #0ea5e9;
}

/* Botones de descarga generales */
.media-download-btn {
    background-color: var(--gray-600);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    transition: background-color 0.2s ease;
}

.media-download-btn:hover {
    background-color: var(--gray-700);
}

/* Modal de imagen mejorado */
.image-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.image-modal-close {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #ffffff;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10001;
    transition: color 0.2s ease;
}

.image-modal-close:hover {
    color: #ccc;
}

.image-modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    max-width: 95vw;
    max-height: 95vh;
}

.image-modal-content img {
    max-width: 100%;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.image-modal-actions {
    margin-top: 15px;
    display: flex;
    justify-content: center;
    gap: 10px;
}

.image-download-btn {
    background-color: var(--primary-green);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 10px 20px;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s ease;
}

.image-download-btn:hover {
    background-color: var(--primary-green-dark);
}

/* Adaptaciones responsive */
@media (max-width: 768px) {
    .media-message {
        max-width: calc(100vw - 120px);
    }
    
    .message-image, .message-video {
        max-width: 100%;
        max-height: 200px;
    }
    
    .audio-player {
        min-width: 200px;
    }
    
    .document-message, .location-message, .contact-message {
        max-width: 100%;
    }
    
    .image-modal-content {
        max-width: 98vw;
        max-height: 98vh;
    }
    
    .image-modal-close {
        top: 10px;
        right: 15px;
        font-size: 30px;
    }
}

/* Estados de error para multimedia */
.media-message .media-error {
    color: var(--red-error);
    font-style: italic;
    display: flex;
    align-items: center;
    gap: 8px;
}

.audio-play-btn:disabled {
    background-color: var(--gray-400);
    cursor: not-allowed;
}

/* Indicadores de carga */
.media-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--gray-600);
    font-style: italic;
}

.media-loading::before {
    content: "";
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--primary-green);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Agregar este CSS a tu archivo de estilos */
@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

.typing-indicator {
    animation: fadeIn 0.3s ease-in;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 5px;
}

.status-indicator.active {
    background-color: var(--green-success);
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
}

.status-indicator.inactive {
    background-color: var(--gray-400);
}

.activity-indicator:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.ai-status-indicator {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 8px;
}

.ai-status-indicator.active {
    background-color: var(--green-success);
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.6);
}

.ai-status-indicator.inactive {
    background-color: var(--gray-400);
}

.ai-test-result {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 12px;
    margin-top: 12px;
}

.ai-log-item {
    border-bottom: 1px solid #eee;
    padding: 8px 0;
}

.ai-log-item:last-child {
    border-bottom: none;
}