/* ==========================================================================
   Panel de Asesores - MiMejorPrepaga
   Basado en styles.css del sitio principal
   ========================================================================== */

/* ==========================================================================
   1. Variables (heredadas de styles.css)
   ========================================================================== */
:root {
    --primary: #0056b3;
    --primary-dark: #003d82;
    --accent: #00c853;
    --orange: #ff6f00;
    --orange-hover: #e65100;
    --text-main: #2c3e50;
    --text-light: #5f6c7b;
    --bg-light: #f4f7f6;
    --white: #ffffff;
    --radius: 12px;
    --shadow-card: 0 10px 30px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 15px 35px rgba(0, 0, 0, 0.12);

    /* Extensiones para el panel */
    --border: #e0e6ed;
    --border-light: #f0f4f8;
    --success: #00c853;
    --warning: #ff9800;
    --danger: #f44336;
    --info: #2196f3;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Lato', sans-serif;
    color: var(--text-main);
    background-color: var(--bg-light);
    line-height: 1.6;
}

/* ==========================================================================
   2. Header del Panel
   ========================================================================== */
.panel-header {
    background: var(--primary);
    padding: 15px 20px;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.panel-header-content {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-logo-img {
    height: 40px;
    width: auto;
}

.asesor-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.15);
    padding: 8px 16px;
    border-radius: 50px;
    backdrop-filter: blur(8px);
}

.asesor-avatar {
    width: 34px;
    height: 34px;
    background: var(--white);
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    font-size: 0.85rem;
}

.asesor-name {
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    color: var(--white);
    font-size: 0.95rem;
}

/* ==========================================================================
   3. Stats Bar - Filtros Clickeables
   ========================================================================== */
.stats-bar {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 12px 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.stats-content {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 50px;
    border: 1px solid var(--border);
    background: var(--white);
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.stat-item:hover {
    background: var(--bg-light);
    border-color: var(--text-light);
}

.stat-item.active {
    background: #e3f2fd;
    border-color: var(--primary);
}

.stat-item.active .stat-label,
.stat-item.active .stat-count {
    color: var(--primary);
}

.stat-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.stat-dot.nuevo {
    background: var(--info);
}

.stat-dot.contactado {
    background: var(--warning);
}

.stat-dot.cita {
    background: #9c27b0;
}

.stat-dot.propuesta {
    background: #00bcd4;
}

.stat-dot.ganado {
    background: var(--success);
}

.stat-dot.perdido {
    background: var(--danger);
}

.stat-dot.sin-interes {
    background: #9e9e9e;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-light);
    font-weight: 600;
}

.stat-count {
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-main);
}


/* ==========================================================================
   4. Main Content
   ========================================================================== */
.panel-main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 25px 20px 40px;
}

/* ==========================================================================
   5. Loading State
   ========================================================================== */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px;
    gap: 15px;
}

.spinner {
    width: 44px;
    height: 44px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==========================================================================
   6. Lead Cards
   ========================================================================== */
.leads-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.lead-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-card);
}

.lead-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.lead-card.hidden {
    display: none;
}

.lead-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 20px;
    gap: 15px;
    flex-wrap: wrap;
}

.lead-info {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
    min-width: 200px;
}

.lead-avatar {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--white);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.lead-name {
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--text-main);
    margin-bottom: 4px;
}

.lead-meta {
    display: flex;
    gap: 15px;
    color: var(--text-light);
    font-size: 0.9rem;
    flex-wrap: wrap;
}

.lead-meta-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.lead-meta-item svg {
    width: 15px;
    height: 15px;
    opacity: 0.6;
}

.lead-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* WhatsApp Button - inline (next to phone) */
.wa-btn-inline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: #25D366;
    color: var(--white);
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-left: 4px;
}

.wa-btn-inline:hover {
    background: #1fb855;
    transform: scale(1.1);
}

.wa-btn-inline svg {
    width: 14px;
    height: 14px;
}

/* WhatsApp Button - standalone (legacy, kept for reference) */
.wa-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 10px 14px;
    background: #25D366;
    color: var(--white);
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 700;
    transition: all 0.2s ease;
    box-shadow: 0 4px 10px rgba(37, 211, 102, 0.3);
}

.wa-btn:hover {
    background: #1fb855;
    transform: translateY(-2px);
}

.wa-btn svg {
    width: 18px;
    height: 18px;
}

/* Status Dropdown */
.status-select {
    appearance: none;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 36px 10px 14px;
    color: var(--text-main);
    font-family: 'Lato', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%235f6c7b' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: all 0.2s ease;
}

.status-select:hover {
    border-color: var(--primary);
}

.status-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 86, 179, 0.1);
}

.status-select.nuevo {
    border-left: 4px solid var(--info);
}

.status-select.contactado {
    border-left: 4px solid var(--warning);
}

.status-select.cita {
    border-left: 4px solid #9c27b0;
}

.status-select.propuesta {
    border-left: 4px solid #00bcd4;
}

.status-select.ganado {
    border-left: 4px solid var(--success);
}

.status-select.perdido {
    border-left: 4px solid var(--danger);
}

.status-select.sin-interes {
    border-left: 4px solid #9e9e9e;
}

/* ==========================================================================
   7. Lead Details
   ========================================================================== */
.lead-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 15px;
    padding: 0 20px 20px;
    border-bottom: 1px solid var(--border-light);
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.detail-item.full-width {
    grid-column: 1 / -1;
}

.detail-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-light);
    font-weight: 700;
}

.detail-value {
    font-size: 0.95rem;
    color: var(--text-main);
}

/* ==========================================================================
   8. Notes Section
   ========================================================================== */
.lead-notes {
    padding: 15px 20px;
    background: var(--bg-light);
}

.notes-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.notes-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-light);
    font-weight: 700;
}

.notes-status {
    font-size: 0.8rem;
    color: var(--success);
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.notes-status.visible {
    opacity: 1;
}

.notes-textarea {
    width: 100%;
    min-height: 80px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    color: var(--text-main);
    font-family: 'Lato', sans-serif;
    font-size: 0.95rem;
    line-height: 1.5;
    resize: vertical;
    transition: all 0.2s ease;
}

.notes-textarea::placeholder {
    color: #aab4be;
}

.notes-textarea:hover {
    border-color: var(--text-light);
}

.notes-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 86, 179, 0.1);
}

/* ==========================================================================
   9. Links
   ========================================================================== */
.phone-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
}

.phone-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* ==========================================================================
   10. Empty State
   ========================================================================== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
}

.empty-state svg {
    width: 70px;
    height: 70px;
    margin-bottom: 15px;
    opacity: 0.4;
    color: var(--text-light);
}

.empty-state p {
    font-size: 1.1rem;
}

/* ==========================================================================
   11. Access Denied
   ========================================================================== */
.access-denied {
    text-align: center;
    padding: 80px 20px;
    max-width: 420px;
    margin: 0 auto;
}

.access-denied-icon {
    font-size: 4.5rem;
    margin-bottom: 15px;
}

.access-denied h2 {
    font-family: 'Poppins', sans-serif;
    color: var(--text-main);
    margin-bottom: 10px;
    font-size: 1.6rem;
}

.access-denied p {
    color: var(--text-light);
    font-size: 1.05rem;
}

/* ==========================================================================
   12. Error State
   ========================================================================== */
.error-state {
    background: #ffebee;
    border: 1px solid #ffcdd2;
    border-radius: var(--radius);
    padding: 30px;
    text-align: center;
    color: var(--danger);
}

.error-state p {
    font-weight: 600;
    margin-bottom: 8px;
}

.error-state code {
    display: block;
    font-size: 0.8rem;
    color: var(--text-light);
    word-break: break-all;
    background: rgba(0, 0, 0, 0.05);
    padding: 8px;
    border-radius: 6px;
    margin-top: 10px;
}

/* ==========================================================================
   13. Toast Notifications
   ========================================================================== */
.toast-container {
    position: fixed;
    bottom: 25px;
    right: 25px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow-hover);
    animation: slideIn 0.3s ease;
    font-size: 0.95rem;
    font-weight: 600;
}

.toast.success {
    border-left: 4px solid var(--success);
}

.toast.success span:first-child {
    color: var(--success);
}

.toast.error {
    border-left: 4px solid var(--danger);
}

.toast.error span:first-child {
    color: var(--danger);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ==========================================================================
   14. Responsive
   ========================================================================== */

/* Tablets */
@media (max-width: 1024px) {
    .panel-header {
        padding: 12px 15px;
    }

    .panel-logo-img {
        height: 35px;
    }

    .stats-bar {
        padding: 10px 15px;
    }

    .stats-content {
        gap: 6px;
    }

    .stat-item {
        padding: 6px 12px;
    }

    .panel-main {
        padding: 20px 15px;
    }
}

/* Móviles */
@media (max-width: 768px) {
    .panel-header {
        padding: 10px 12px;
    }

    .panel-logo-img {
        height: 30px;
    }

    .asesor-badge {
        padding: 6px 12px;
    }

    .asesor-name {
        font-size: 0.85rem;
    }

    .stats-bar {
        padding: 10px 12px;
    }

    .stats-content {
        gap: 5px;
    }

    .stat-item {
        padding: 5px 10px;
        font-size: 0.8rem;
    }

    .stat-label {
        display: none;
    }

    .stat-dot {
        width: 8px;
        height: 8px;
    }

    .panel-main {
        padding: 15px 12px;
    }

    .leads-grid {
        gap: 12px;
    }

    .lead-header {
        padding: 15px;
    }

    .lead-info {
        width: 100%;
    }

    .lead-avatar {
        width: 44px;
        height: 44px;
        font-size: 1rem;
    }

    .lead-name {
        font-size: 1.05rem;
    }

    .lead-actions {
        width: 100%;
        justify-content: space-between;
        margin-top: 10px;
    }

    .status-select {
        flex: 1;
    }

    .lead-details {
        padding: 12px 15px;
        gap: 12px;
    }

    .lead-notes {
        padding: 12px 15px;
    }

    .notes-textarea {
        min-height: 70px;
    }
}

/* Móviles pequeños */
@media (max-width: 480px) {
    .asesor-badge {
        padding: 5px 10px;
        gap: 8px;
    }

    .asesor-avatar {
        width: 28px;
        height: 28px;
        font-size: 0.75rem;
    }

    .asesor-name {
        font-size: 0.8rem;
    }

    .lead-header {
        padding: 12px;
    }

    .lead-avatar {
        width: 40px;
        height: 40px;
        border-radius: 10px;
    }

    .wa-btn {
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    .wa-btn svg {
        width: 16px;
        height: 16px;
    }

    .asesor-select {
        font-size: 0.85rem;
        padding: 8px 30px 8px 10px;
    }

    .asesor-filter-bar {
        padding: 8px 12px;
    }

    .asesor-filter-pill {
        padding: 5px 10px;
        font-size: 0.8rem;
    }

    .asesor-badge-card {
        font-size: 0.65rem;
        padding: 1px 6px;
    }
}

/* Custom Tooltip */
[data-tooltip] {
    position: relative;
    cursor: help;
}

[data-tooltip]:hover::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    transform: translateX(-50%);
    left: 50%;
    margin-bottom: 8px;
    padding: 6px 10px;
    background: #333;
    color: white;
    font-size: 0.75rem;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 10;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    opacity: 0;
    animation: fadeIn 0.2s forwards;
    pointer-events: none;
}

[data-tooltip]:hover::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #333;
    margin-bottom: -2px;
    opacity: 0;
    animation: fadeIn 0.2s forwards;
    pointer-events: none;
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

/* Entry Animations */
@keyframes fadeInSlideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-in {
    animation: fadeInSlideDown 0.5s ease-out forwards;
}

/* ==========================================================================
   15b. Coordinator Role - Asesor Filter Bar
   ========================================================================== */
.asesor-filter-bar {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 10px 20px;
    display: none;
}

.asesor-filter-content {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.asesor-filter-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-right: 4px;
}

.asesor-filter-pill {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    border-radius: 50px;
    border: 1px solid var(--border);
    background: var(--white);
    font-family: 'Lato', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.asesor-filter-pill:hover {
    background: var(--bg-light);
    border-color: var(--text-light);
}

.asesor-filter-pill.active {
    background: #e8f5e9;
    border-color: var(--success);
    color: #2e7d32;
}

/* ==========================================================================
   15c. Coordinator Role - Asesor Badge on Card
   ========================================================================== */
.asesor-badge-card {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    margin-left: 8px;
    vertical-align: middle;
}

.asesor-badge-card.assigned {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #c8e6c9;
}

.asesor-badge-card.unassigned {
    background: #fff3e0;
    color: #e65100;
    border: 1px solid #ffe0b2;
}

/* ==========================================================================
   15d. Coordinator Role - Asesor Select Dropdown
   ========================================================================== */
.asesor-select {
    appearance: none;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 36px 10px 14px;
    color: var(--text-main);
    font-family: 'Lato', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border-left: 4px solid var(--success);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%235f6c7b' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: all 0.2s ease;
}

.asesor-select:hover {
    border-color: var(--success);
}

.asesor-select:focus {
    outline: none;
    border-color: var(--success);
    box-shadow: 0 0 0 3px rgba(0, 200, 83, 0.1);
}

/* ==========================================================================
   15e. Coordinator Role - Role Badge in Header
   ========================================================================== */
.rol-badge {
    display: none;
    padding: 3px 10px;
    border-radius: 50px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: rgba(0, 200, 83, 0.2);
    color: #a5d6a7;
    margin-left: 8px;
}

/* ==========================================================================
   15. Chips UI (Zonas de Trabajo)
   ========================================================================== */
.chips-container {
    position: relative;
    width: 100%;
}

.chips-input {
    width: 100%;
    min-height: 50px;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    transition: border-color 0.2s;
    background: white;
}

.chips-input:hover {
    border-color: var(--primary);
}

.chips-input.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 86, 179, 0.1);
}

.chips-placeholder {
    color: #999;
    font-size: 0.95rem;
}

.chip {
    display: inline-flex;
    align-items: center;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 6px 10px;
    border-radius: 20px;
    font-size: 0.85rem;
    animation: chipIn 0.2s ease;
}

@keyframes chipIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.chip-remove {
    margin-left: 8px;
    cursor: pointer;
    opacity: 0.8;
    font-size: 1.1rem;
    line-height: 1;
}

.chip-remove:hover {
    opacity: 1;
}

.zone-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    max-height: 300px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}

.zone-dropdown.open {
    display: block;
    animation: dropIn 0.2s ease;
}

@keyframes dropIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.zone-dropdown-section {
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}

.zone-dropdown-section:last-child {
    border-bottom: none;
}

.zone-dropdown-section-title {
    padding: 8px 16px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.zone-dropdown-item {
    padding: 12px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: background 0.15s;
    font-size: 0.95rem;
    color: var(--text-main);
}

.zone-dropdown-item:hover {
    background: #f8f9fa;
}

.zone-dropdown-item.selected {
    background: #eef1ff;
    color: var(--primary);
}

.zone-dropdown-item.select-all-item {
    font-weight: 600;
    color: var(--primary);
}

.zone-dropdown-check {
    width: 20px;
    margin-right: 10px;
    color: var(--primary);
    font-weight: bold;
}