/* ═══════════════════════════════════════════════════════════════
   📋 PLAN HISTORY - ESTILOS
   ═══════════════════════════════════════════════════════════════ */

/* ──────────── PANEL LATERAL ──────────── */
#planHistoryPanel {
    position: fixed;
    top: 0;
    right: -420px;
    width: 400px;
    height: 100vh;
    background: var(--bg-secondary, #0a0a0a);
    border-left: 1px solid var(--border, rgba(255,255,255,0.1));
    z-index: 1100;
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.5);
}

#planHistoryPanel.open {
    right: 0;
}

/* Overlay detrás del panel */
.history-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1099;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.history-overlay.visible {
    opacity: 1;
    visibility: visible;
}

/* ──────────── PANEL INTERNO ──────────── */
.history-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-glass, rgba(20,20,20,0.9));
    backdrop-filter: var(--glass-blur);
    position: sticky;
    top: 0;
    z-index: 10;
}

.history-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.history-close-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.history-close-btn:hover {
    background: rgba(255, 68, 68, 0.2);
    border-color: rgba(255, 68, 68, 0.5);
    color: #ff6b6b;
}

/* ──────────── BUSCADOR ──────────── */
.history-search {
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

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

.history-search-icon {
    position: absolute;
    left: 12px;
    font-size: 0.9rem;
    opacity: 0.5;
    pointer-events: none;
}

.history-search-input {
    width: 100%;
    padding: 0.6rem 0.75rem 0.6rem 2.2rem;
    background: var(--bg-tertiary, #111);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 8px);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.history-search-input:focus {
    border-color: var(--primary, #00ff88);
    box-shadow: 0 0 0 2px rgba(0, 255, 136, 0.1);
}

.history-search-clear {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 4px;
}

/* ──────────── TABS ──────────── */
.history-tabs {
    display: flex;
    gap: 0;
    padding: 0 1rem;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
}

.history-tabs::-webkit-scrollbar { display: none; }

.history-tab {
    flex: 1;
    padding: 0.6rem 0.5rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    white-space: nowrap;
}

.history-tab:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.03);
}

.history-tab.active {
    color: var(--primary, #00ff88);
    border-bottom-color: var(--primary, #00ff88);
    font-weight: 600;
}

.history-tab-count {
    background: rgba(255,255,255,0.1);
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
}

.history-tab.active .history-tab-count {
    background: rgba(0, 255, 136, 0.15);
    color: var(--primary);
}

/* ──────────── LISTA ──────────── */
.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* ──────────── CARD ──────────── */
.history-card {
    background: var(--bg-glass, rgba(20,20,20,0.7));
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 8px);
    padding: 0.75rem;
    transition: all 0.2s;
    cursor: default;
}

.history-card:hover {
    border-color: var(--border-glow, rgba(0,255,136,0.3));
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    transform: translateY(-1px);
}

.history-card-nutrition { border-left: 3px solid #22c55e; }
.history-card-training { border-left: 3px solid #3b82f6; }
.history-card-recipe { border-left: 3px solid #ffd700; }

.history-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.4rem;
}

.history-card-type-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(255,255,255,0.06);
}

.history-card-nutrition .history-card-type-badge { color: #22c55e; }
.history-card-training .history-card-type-badge { color: #3b82f6; }
.history-card-recipe .history-card-type-badge { color: #ffd700; }

.history-card-time {
    font-size: 0.7rem;
    color: var(--text-muted, #606060);
}

.history-card-body {
    margin-bottom: 0.5rem;
}

.history-card-client {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 2px 0;
}

.history-card-title {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin: 0 0 3px 0;
}

.history-card-summary {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin: 0;
    font-family: 'JetBrains Mono', monospace;
}

.history-card-tags {
    display: flex;
    gap: 4px;
    margin-top: 6px;
}

.history-tag {
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: 8px;
    background: rgba(0, 255, 136, 0.08);
    color: var(--primary);
    border: 1px solid rgba(0, 255, 136, 0.15);
}

.history-card-actions {
    display: flex;
    gap: 4px;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

.history-card-actions .btn-sm {
    flex: 1;
    padding: 4px 8px;
    font-size: 0.7rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.05);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.history-card-actions .btn-primary { color: var(--primary); border-color: rgba(0,255,136,0.2); }
.history-card-actions .btn-primary:hover { background: rgba(0,255,136,0.1); }
.history-card-actions .btn-preset { color: #ffd700; border-color: rgba(255,215,0,0.2); }
.history-card-actions .btn-preset:hover { background: rgba(255,215,0,0.1); border-color: rgba(255,215,0,0.4); }
.history-card-actions .btn-secondary:hover { background: rgba(255,255,255,0.08); }
.history-card-actions .btn-danger { color: #ff6b6b; border-color: rgba(255,68,68,0.2); flex: 0; }
.history-card-actions .btn-danger:hover { background: rgba(255,68,68,0.1); }

/* ──────────── EMPTY STATE ──────────── */
.history-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    text-align: center;
    color: var(--text-muted);
}

.history-empty-icon { font-size: 3rem; margin-bottom: 1rem; }
.history-empty h4 { margin: 0 0 0.5rem; color: var(--text-secondary); }
.history-empty p { font-size: 0.8rem; margin: 0; }

.history-empty-inline {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem 1rem;
    text-align: center;
    background: var(--bg-glass);
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
}

.history-empty-inline .history-empty-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.history-empty-inline p { margin: 0; font-size: 0.85rem; }
.history-empty-inline small { font-size: 0.75rem; opacity: 0.7; }

/* ──────────── INLINE HISTORY (dentro de módulos) ──────────── */
.history-inline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.history-inline-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-secondary);
}

.history-view-all-btn {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.8rem;
    cursor: pointer;
    font-family: inherit;
}

.history-view-all-btn:hover {
    text-decoration: underline;
}

.history-inline-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.history-inline-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: var(--bg-glass);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.history-inline-card:hover {
    border-color: var(--primary);
    background: rgba(0, 255, 136, 0.03);
}

.history-inline-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.history-inline-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
}

.history-inline-summary {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.history-inline-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ──────────── FOOTER ──────────── */
.history-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    border-top: 1px solid var(--border);
    background: var(--bg-glass);
    position: sticky;
    bottom: 0;
}

.history-count {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.history-footer-actions {
    display: flex;
    gap: 6px;
}

.history-export-btn, .history-clear-btn {
    padding: 4px 10px;
    font-size: 0.72rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.05);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.history-export-btn:hover { background: rgba(0,255,136,0.1); color: var(--primary); }
.history-clear-btn:hover { background: rgba(255,68,68,0.1); color: #ff6b6b; }

/* ──────────── BOTÓN FLOTANTE PARA ABRIR ──────────── */
.history-floating-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: none;
    color: #000;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(0, 255, 136, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.history-floating-btn:hover {
    transform: scale(1.1) rotate(-5deg);
    box-shadow: 0 6px 30px rgba(0, 255, 136, 0.5);
}

.history-floating-btn .badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ff4444;
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ──────────── RESPONSIVE ──────────── */
@media (max-width: 768px) {
    #planHistoryPanel {
        width: 100%;
        right: -100%;
    }

    #planHistoryPanel.open {
        right: 0;
    }

    .history-card-actions {
        flex-wrap: wrap;
    }

    .history-card-actions .btn-sm {
        font-size: 0.68rem;
        padding: 5px 6px;
    }

    .history-floating-btn {
        bottom: 16px;
        right: 16px;
        width: 48px;
        height: 48px;
        font-size: 1.2rem;
    }

    .history-tab {
        font-size: 0.72rem;
        padding: 0.5rem 0.3rem;
    }

    .history-header {
        padding: 1rem;
    }

    .history-search {
        padding: 0.5rem 1rem;
    }
}

@media (max-width: 480px) {
    .history-card-actions .btn-sm {
        font-size: 0.65rem;
        padding: 4px 5px;
    }

    .history-card-client {
        font-size: 0.82rem;
    }

    .history-card-summary {
        font-size: 0.68rem;
    }
}
