/**
 * TLS Linky - Estilos v3
 *
 * Mini Linky en header + Card en métricas
 * SIN inline styles - todo por clases
 *
 * @package     The_Linkers_System
 * @since       2.1.0
 */

/* ===========================================
   VARIABLES DE ESTADO
   =========================================== */
:root {
    --linky-primary: #FF5C39;
    --linky-super-feliz: #22c55e;
    --linky-feliz: #84cc16;
    --linky-normal: #eab308;
    --linky-medio-triste: #f97316;
    --linky-muy-triste: #ef4444;
    --linky-dormido: #6b7280;
}

/* ===========================================
   MINI LINKY EN HEADER
   =========================================== */
.linky-mini {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-right: 12px;
    overflow: hidden;
    max-height: 40px;
    position: relative;
}

.linky-mini:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.linky-mini-img {
    width: 28px;
    height: 28px;
    max-width: 28px;
    max-height: 28px;
    object-fit: contain;
    flex-shrink: 0;
}

.linky-mini-info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.linky-mini-name {
    font-size: 11px;
    font-weight: 600;
    color: white;
    opacity: 0.9;
}

.linky-mini-status {
    font-size: 10px;
    color: white;
    opacity: 0.7;
    display: flex;
    align-items: center;
    gap: 4px;
}

.linky-mini-bar {
    width: 40px;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    overflow: hidden;
}

.linky-mini-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* Colores de barra mini por estado */
.linky-mini.linky-estado-super_feliz .linky-mini-bar-fill { background: var(--linky-super-feliz); }
.linky-mini.linky-estado-feliz .linky-mini-bar-fill { background: var(--linky-feliz); }
.linky-mini.linky-estado-normal .linky-mini-bar-fill { background: var(--linky-normal); }
.linky-mini.linky-estado-medio_triste .linky-mini-bar-fill { background: var(--linky-medio-triste); }
.linky-mini.linky-estado-muy_triste .linky-mini-bar-fill { background: var(--linky-muy-triste); }
.linky-mini.linky-estado-dormido .linky-mini-bar-fill { background: var(--linky-dormido); }

/* Animación mini según estado */
.linky-mini.linky-estado-super_feliz .linky-mini-img { animation: miniBounce 0.6s ease-in-out infinite; }
.linky-mini.linky-estado-feliz .linky-mini-img { animation: miniWag 0.5s ease-in-out infinite; }
.linky-mini.linky-estado-muy_triste .linky-mini-img { animation: miniShake 0.3s ease-in-out infinite; }

@keyframes miniBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

@keyframes miniWag {
    0%, 100% { transform: rotate(-3deg); }
    50% { transform: rotate(3deg); }
}

@keyframes miniShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-1px); }
    75% { transform: translateX(1px); }
}

/* ===========================================
   CARD LINKY EN MÉTRICAS (5ta card)
   =========================================== */
.tls-metric-card.linky-card {
    background: linear-gradient(135deg, #FFF7ED 0%, #FFFFFF 100%);
    border: 2px solid #FFEDD5;
    position: relative;
    overflow: hidden;
}

.tls-metric-card.linky-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--linky-primary), #FF8C69);
}

.linky-card-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    overflow: hidden;
}

.linky-card-img {
    width: 60px;
    height: 60px;
    max-width: 60px;
    max-height: 60px;
    object-fit: contain;
    margin-bottom: 8px;
    flex-shrink: 0;
}

.linky-card-felicidad {
    font-size: 24px;
    font-weight: 700;
    color: var(--tls-dark, #1F2937);
    line-height: 1;
}

.linky-card-label {
    font-size: 13px;
    color: var(--tls-gray-600, #4B5563);
    margin-top: 4px;
}

.linky-card-estado {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    color: white;
    margin-top: 8px;
}

/* Estados para badge de card */
.linky-card-estado.linky-estado-super_feliz { background: var(--linky-super-feliz); }
.linky-card-estado.linky-estado-feliz { background: var(--linky-feliz); }
.linky-card-estado.linky-estado-normal { background: var(--linky-normal); }
.linky-card-estado.linky-estado-medio_triste { background: var(--linky-medio-triste); }
.linky-card-estado.linky-estado-muy_triste { background: var(--linky-muy-triste); }
.linky-card-estado.linky-estado-dormido { background: var(--linky-dormido); }

/* Animaciones para imagen en card */
.linky-card.linky-estado-super_feliz .linky-card-img { animation: cardBounce 0.6s ease-in-out infinite; }
.linky-card.linky-estado-feliz .linky-card-img { animation: cardWag 0.5s ease-in-out infinite; }
.linky-card.linky-estado-muy_triste .linky-card-img { animation: cardShake 0.3s ease-in-out infinite; }
.linky-card.linky-estado-dormido .linky-card-img { animation: cardSleep 3s ease-in-out infinite; }

@keyframes cardBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

@keyframes cardWag {
    0%, 100% { transform: rotate(-2deg); }
    50% { transform: rotate(2deg); }
}

@keyframes cardShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
}

@keyframes cardSleep {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

/* ===========================================
   DROPDOWN/MODAL LINKY (desde header)
   =========================================== */
.linky-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    padding: 16px;
    width: 280px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

.linky-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.linky-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #E5E7EB;
}

.linky-dropdown-title {
    font-size: 16px;
    font-weight: 700;
    color: #1F2937;
}

.linky-dropdown-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #9CA3AF;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}

.linky-dropdown-close:hover {
    color: #1F2937;
}

.linky-dropdown-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
    position: relative;
}

.linky-dropdown-img {
    width: 100px;
    height: 100px;
    max-width: 100px;
    max-height: 100px;
    object-fit: contain;
    margin-bottom: 8px;
    flex-shrink: 0;
}

.linky-dropdown-msg {
    font-size: 13px;
    color: #6B7280;
    text-align: center;
    margin-bottom: 12px;
    font-style: italic;
}

.linky-dropdown-bar {
    width: 100%;
    height: 8px;
    background: #E5E7EB;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.linky-dropdown-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* Colores barra dropdown */
.linky-dropdown.linky-estado-super_feliz .linky-dropdown-bar-fill { background: var(--linky-super-feliz); }
.linky-dropdown.linky-estado-feliz .linky-dropdown-bar-fill { background: var(--linky-feliz); }
.linky-dropdown.linky-estado-normal .linky-dropdown-bar-fill { background: var(--linky-normal); }
.linky-dropdown.linky-estado-medio_triste .linky-dropdown-bar-fill { background: var(--linky-medio-triste); }
.linky-dropdown.linky-estado-muy_triste .linky-dropdown-bar-fill { background: var(--linky-muy-triste); }
.linky-dropdown.linky-estado-dormido .linky-dropdown-bar-fill { background: var(--linky-dormido); }

.linky-dropdown-stats {
    display: flex;
    justify-content: space-between;
    width: 100%;
    font-size: 12px;
    color: #6B7280;
    margin-bottom: 12px;
}

.linky-dropdown-btn {
    width: 100%;
    padding: 10px;
    background: linear-gradient(135deg, var(--linky-primary), #FF8C69);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.linky-dropdown-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 92, 57, 0.3);
}

.linky-dropdown-btn:disabled {
    background: #D1D5DB;
    cursor: not-allowed;
}

/* ===========================================
   RESPONSIVE
   =========================================== */
@media (max-width: 768px) {
    .linky-mini-info {
        display: none;
    }
    
    .linky-mini {
        padding: 6px;
    }
    
    .linky-dropdown {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        border-radius: 16px 16px 0 0;
        margin-top: 0;
    }
}

/* Grid de métricas con 5 cards */
@media (min-width: 992px) {
    .tls-metrics-grid.has-linky {
        grid-template-columns: repeat(5, 1fr);
    }
}

@media (max-width: 991px) and (min-width: 768px) {
    .tls-metrics-grid.has-linky {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 767px) {
    .tls-metrics-grid.has-linky {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .tls-metric-card.linky-card {
        grid-column: span 2;
    }
}

/* =========================================================================
   NOTIFICACIONES TOAST v5
   ========================================================================= */

.linky-toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 350px;
    pointer-events: none;
}

.linky-toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: white;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    border-left: 4px solid #eab308;
    transform: translateX(120%);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    pointer-events: auto;
}

.linky-toast.show {
    transform: translateX(0);
    opacity: 1;
}

.linky-toast-icon {
    font-size: 28px;
    flex-shrink: 0;
    animation: toastBounce 0.5s ease;
}

@keyframes toastBounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

.linky-toast-content {
    flex: 1;
    min-width: 0;
}

.linky-toast-title {
    font-weight: 700;
    font-size: 14px;
    color: #111827;
    margin-bottom: 4px;
}

.linky-toast-message {
    font-size: 13px;
    color: #6b7280;
    line-height: 1.4;
}

.linky-toast-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #9ca3af;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

.linky-toast-close:hover {
    color: #111827;
}

/* Badge de notificaciones en mini */
.linky-notif-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: white;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    animation: badgePulse 2s infinite;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.4);
}

@keyframes badgePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Responsive para toasts */
@media (max-width: 480px) {
    .linky-toast-container {
        left: 10px;
        right: 10px;
        max-width: none;
    }
    
    .linky-toast {
        padding: 12px;
    }
    
    .linky-toast-icon {
        font-size: 24px;
    }
}

/* Animación especial para caricia */
.linky-toast .linky-toast-icon.heart-beat {
    animation: heartBeat 0.8s ease;
}

@keyframes heartBeat {
    0%, 100% { transform: scale(1); }
    25% { transform: scale(1.3); }
    50% { transform: scale(1); }
    75% { transform: scale(1.2); }
}

/* =========================================================================
   PUSH NOTIFICATIONS - BOTÓN Y UI
   ========================================================================= */

.linky-dropdown-push {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed rgba(255, 92, 57, 0.3);
    text-align: center;
    width: 100%;
}

/* BOTÓN PUSH - ESTADO INACTIVO (NARANJA) */
button.linky-push-toggle,
.linky-dropdown button.linky-push-toggle,
.linky-push-toggle {
    width: 100%;
    padding: 12px 16px !important;
    border: 2px solid #FF5C39 !important;
    border-radius: 12px !important;
    background: linear-gradient(135deg, #FFF5F3 0%, #FFEDE8 100%) !important;
    color: #FF5C39 !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    outline: none;
    box-sizing: border-box;
}

button.linky-push-toggle:hover,
.linky-dropdown button.linky-push-toggle:hover,
.linky-push-toggle:hover {
    background: linear-gradient(135deg, #FF5C39 0%, #FF8C42 100%) !important;
    color: white !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 92, 57, 0.3);
}

button.linky-push-toggle:active,
.linky-push-toggle:active {
    transform: translateY(0);
}

/* BOTÓN PUSH - ESTADO ACTIVO (VERDE) */
button.linky-push-toggle.active,
.linky-dropdown button.linky-push-toggle.active,
.linky-push-toggle.active {
    background: linear-gradient(135deg, #10B981 0%, #059669 100%) !important;
    border-color: #10B981 !important;
    color: white !important;
}

button.linky-push-toggle.active:hover,
.linky-dropdown button.linky-push-toggle.active:hover,
.linky-push-toggle.active:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%) !important;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.linky-push-hint {
    margin: 8px 0 0;
    font-size: 12px;
    color: #9ca3af;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

/* Badge de push activo en mini */
.linky-push-status {
    position: absolute;
    bottom: -2px;
    right: -2px;
    font-size: 10px;
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    animation: pushPulse 2s infinite;
}

@keyframes pushPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* =========================================================================
   PUSH TOAST FALLBACK
   ========================================================================= */

.tls-push-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 14px 24px;
    border-radius: 16px;
    font-weight: 600;
    font-size: 14px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.25);
    z-index: 999999;
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 0;
    transition: all 0.3s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.tls-push-toast--visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.tls-push-toast--success {
    background: linear-gradient(135deg, #10B981, #059669);
    color: white;
}

.tls-push-toast--error {
    background: linear-gradient(135deg, #EF4444, #DC2626);
    color: white;
}

.tls-push-toast--warning {
    background: linear-gradient(135deg, #F59E0B, #D97706);
    color: white;
}

.tls-push-toast--info {
    background: linear-gradient(135deg, #3B82F6, #2563EB);
    color: white;
}

@media (max-width: 480px) {
    .tls-push-toast {
        left: 16px;
        right: 16px;
        transform: translateY(20px);
        width: auto;
    }
    
    .tls-push-toast--visible {
        transform: translateY(0);
    }
}
