/* ==========================================================================
   Statistics CSS - Funnel, Kanban, Tabs, Filters
   ========================================================================== */

/* Funnel/Kanban Styles */
.funnel-container {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    padding: 20px 0;
}

.funnel-stage {
    flex: 1;
    min-width: 280px;
    background: var(--color-gray-100);
    border-radius: 10px;
    padding: 15px;
    box-shadow: var(--shadow-sm);
}

.funnel-stage-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    text-align: center;
}

.funnel-stage-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 5px;
}

.funnel-stage-count {
    font-size: 24px;
    font-weight: bold;
}

.funnel-stage-subtitle {
    font-size: 12px;
    margin-top: 5px;
    opacity: 0.9;
}

.funnel-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 200px;
}

/* Opportunity Card */
.opportunity-card {
    background: white;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.3s;
    border-left: 4px solid var(--color-primary);
}

.opportunity-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

/* Partner Card */
.partner-card {
    background: white;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.3s;
    border-left: 4px solid var(--color-primary);
}

.partner-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

/* Dashboard Button */
.btn-dashboard {
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.btn-dashboard:hover {
    background: var(--color-primary-dark);
    transform: scale(1.1);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
}

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

/* Estados de previsión */
.card-vencido {
    background: #ffebee !important;
}

.card-sin-prevision {
    background: #fff9c4 !important;
}

/* Estados de seguimiento */
.card-seguimiento-rojo {
    background: #ffebee !important;
    border-left-color: #e53935 !important;
}

.card-seguimiento-naranja {
    background: #fff3e0 !important;
    border-left-color: #fb8c00 !important;
}

.card-seguimiento-verde {
    background: #e8f5e9 !important;
    border-left-color: #43a047 !important;
}

.card-id {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.card-id a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color 0.2s;
    flex: 1;
}

.card-id a:hover {
    color: var(--color-primary-dark);
}

/* Card ID Buttons Container */
.card-id-buttons {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

/* Send Email Button */
.btn-send-email {
    background: #327EFF;
    color: white;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.btn-send-email:hover {
    background: #2563eb;
    transform: scale(1.1);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
}

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

.btn-send-email:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.btn-send-email-success {
    background: #27ae60 !important;
}

/* Botón de email con emoji (sobre cerrado / sobre abierto) */
.btn-icon-email {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    padding: 2px;
    transition: transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon-email:hover {
    transform: scale(1.25);
}

.btn-icon-email:active {
    transform: scale(0.9);
}

.btn-icon-email:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-icon-email.btn-email-enviado {
    opacity: 0.85;
}

/* Email tracking cell */
.email-cell {
    display: flex;
    align-items: center;
    gap: 4px;
}

.email-track-badge {
    font-size: 13px;
    line-height: 1;
    cursor: default;
}

.track-delivered {
    opacity: 0.7;
}

.track-opened {
    color: #27ae60;
    font-weight: 600;
}

.track-clicked {
    color: #2563eb;
    font-weight: 600;
}

.track-sent {
    opacity: 0.5;
}

/* Botoneras de rango de fechas */
.seg-botoneras {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.seg-botonera {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.seg-botonera-label {
    font-size: 13px;
    font-weight: 600;
    color: #555;
    min-width: 120px;
}

.seg-botonera-btns {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.seg-btn {
    padding: 5px 12px;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    background: #fff;
    color: #555;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}

.seg-btn:hover {
    background: #f0f4ff;
    border-color: #4285f4;
    color: #1a73e8;
}

.seg-btn.active {
    background: #1a73e8;
    color: #fff;
    border-color: #1a73e8;
}

/* Barra de acciones en lote */
.barra-acciones-lote {
    display: flex;
    align-items: center;
    gap: 16px;
    background: #e8f0fe;
    border: 1px solid #4285f4;
    border-radius: 8px;
    padding: 10px 20px;
    margin-bottom: 12px;
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.barra-acciones-lote span {
    font-weight: 600;
    color: #1a73e8;
    font-size: 14px;
}

.btn-enviar-lote {
    background: #1a73e8;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 18px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s;
}

.btn-enviar-lote:hover {
    background: #1557b0;
}

.btn-enviar-lote:disabled {
    background: #93b4e0;
    cursor: not-allowed;
}

.btn-enviar-lote .btn-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: btn-spin 0.8s linear infinite;
    display: inline-block;
}

.btn-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: btn-spin 0.8s linear infinite;
}

@keyframes btn-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Ficha Deal Button */
.btn-ficha-deal {
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.btn-ficha-deal:hover {
    background: #229954;
    transform: scale(1.1);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
}

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

/* Card Info */
.card-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 13px;
    color: var(--color-gray-600);
}

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

.card-label {
    font-weight: 600;
    color: #888;
}

.card-value {
    color: var(--color-gray-800);
}

.card-collaborator {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #eee;
    font-size: 12px;
    color: var(--color-gray-500);
}

.empty-stage {
    text-align: center;
    padding: 40px 20px;
    color: var(--color-gray-500);
    font-style: italic;
}

/* Colores por etapa */
.funnel-stage:nth-child(1) .funnel-stage-header {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
}

.funnel-stage:nth-child(1) .opportunity-card,
.funnel-stage:nth-child(1) .partner-card {
    border-left-color: #3498db;
}

.funnel-stage:nth-child(2) .funnel-stage-header {
    background: linear-gradient(135deg, #9b59b6 0%, #8e44ad 100%);
}

.funnel-stage:nth-child(2) .opportunity-card,
.funnel-stage:nth-child(2) .partner-card {
    border-left-color: #9b59b6;
}

.funnel-stage:nth-child(3) .funnel-stage-header {
    background: linear-gradient(135deg, #e67e22 0%, #d35400 100%);
}

.funnel-stage:nth-child(3) .opportunity-card,
.funnel-stage:nth-child(3) .partner-card {
    border-left-color: #e67e22;
}

.funnel-stage:nth-child(4) .funnel-stage-header {
    background: linear-gradient(135deg, #27ae60 0%, #229954 100%);
}

.funnel-stage:nth-child(4) .opportunity-card,
.funnel-stage:nth-child(4) .partner-card {
    border-left-color: #27ae60;
}

/* Statistics Tabs */
.stats-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
}

.tab-button {
    flex: 1;
    padding: 15px 30px;
    background: #f0f0f0;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    color: var(--color-gray-600);
}

.tab-button:hover {
    background: #e0e0e0;
    transform: none;
}

.tab-button.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.stats-section {
    display: none;
}

.stats-section.active {
    display: block;
}

/* Header con botón volver */
.header-with-back {
    display: flex;
    align-items: center;
    gap: 20px;
}

.btn-back {
    background: #f0f0f0;
    color: var(--color-gray-600);
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
}

.btn-back:hover {
    background: #e0e0e0;
    color: var(--color-gray-800);
    transform: translateX(-3px);
    box-shadow: none;
}

/* Botón Análisis IA */
.btn-analisis-ia {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s;
    margin-left: 15px;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-analisis-ia:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.5);
}

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

/* Estilos para filtros */
.filters-container {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    align-items: end;
}

.filter-item {
    display: flex;
    flex-direction: column;
}

.filter-label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: var(--color-gray-800);
    font-size: 14px;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: white;
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.btn-block {
    width: 100%;
}

/* Estilos para búsqueda predictiva de partners */
.autocomplete-wrapper {
    position: relative;
}

.partner-suggestions {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.partner-suggestions::-webkit-scrollbar {
    width: 8px;
}

.partner-suggestions::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.partner-suggestions::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.partner-suggestions::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.partner-suggestion {
    padding: 10px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s;
    font-size: 14px;
}

.partner-suggestion:hover {
    background-color: #f5f5f5;
}

.partner-suggestion:last-child {
    border-bottom: none;
}

/* Clickable Cell */
.clickable-cell {
    cursor: pointer;
    transition: all 0.2s;
}

.clickable-cell:hover {
    background-color: #e3f2fd !important;
    transform: scale(1.05);
}
